[wx] Build fix, do not build WebCore as a convenience library as this leads to
[WebKit-https.git] / wscript
1 #! /usr/bin/env python
2
3 # Copyright (C) 2009 Kevin Ollivier  All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
25 #
26 # WebCore build script for the waf build system
27
28 import Options
29
30 from settings import *
31
32 webcore_dirs.extend(['WebKit/wx', 'WebKit/wx/WebKitSupport'])
33
34 wk_includes = ['.', 'WebCore', 'WebCore/DerivedSources',
35                 os.path.join(wk_root, 'JavaScriptCore'),
36                 os.path.join(wk_root, 'JavaScriptCore', 'wtf', 'text'),
37                 os.path.join(wk_root, 'WebCore'),
38                 os.path.join(wk_root, 'WebKit/wx'),
39                 os.path.join(output_dir),
40                 'WebCore/platform/image-decoders',
41                 'WebCore/platform/win',
42                 'WebCore/platform/wx/wxcode',
43                 'WebCore/workers',
44         ]
45
46 if sys.platform.startswith("win"):
47     wk_includes.append(os.path.join(wk_root, 'WebCore','platform','win'))
48
49 windows_deps = [
50                 'lib/pthreadVC2.dll',
51                 'bin/icuuc40.dll', 'bin/icudt40.dll', 'bin/icuin40.dll',
52                 'bin/libcurl.dll', 'bin/libeay32.dll', 'bin/ssleay32.dll', 'bin/zlib1.dll',
53                 'lib/sqlite3.dll', 'bin/libxml2.dll', 'bin/libxslt.dll', 'bin/iconv.dll',
54                 ]
55
56 webcore_sources = {}
57
58 if build_port == "wx":
59     webcore_sources['wx'] = ['WebCore/platform/KillRingNone.cpp', 'WebCore/bindings/cpp/WebDOMEventTarget.cpp']  
60
61     if building_on_win32:
62         # make sure platform/wx comes after this so we get the right
63         # FontPlatformData.h
64         webcore_dirs.extend(['WebCore/platform/wx/wxcode/win', 'WebCore/plugins/win'])
65         webcore_sources['wx-win'] = [
66                'WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp',
67                'WebCore/platform/graphics/win/TransformationMatrixWin.cpp',
68                # wxTimer on Windows has a bug that causes it to eat crashes in callbacks
69                # so we need to use the Win port's implementation until the wx bug fix is
70                # widely available (it was fixed in 2.8.10).
71                'WebCore/platform/win/SharedTimerWin.cpp',
72                'WebCore/platform/win/WebCoreInstanceHandle.cpp',
73                # Use the Windows plugin architecture
74                #'WebCore/plugins/win/PluginDataWin.cpp',
75                'WebCore/plugins/win/PluginDatabaseWin.cpp',
76                'WebCore/plugins/win/PluginMessageThrottlerWin.cpp',
77                'WebCore/plugins/win/PluginPackageWin.cpp',
78                'WebCore/plugins/win/PluginViewWin.cpp',
79         ]
80     elif sys.platform.startswith('darwin'):
81         webcore_dirs.append('WebCore/plugins/mac')
82         webcore_dirs.append('WebCore/platform/wx/wxcode/mac/carbon')
83         webcore_dirs.append('WebCore/platform/mac')
84         webcore_dirs.append('WebCore/platform/text/mac')
85         webcore_sources['wx-mac'] = [
86                'WebCore/platform/mac/PurgeableBufferMac.cpp',
87                'WebCore/platform/mac/WebCoreNSStringExtras.mm',
88                'WebCore/platform/mac/WebCoreSystemInterface.mm',
89                'WebCore/platform/graphics/cg/FloatSizeCG.cpp',
90                'WebCore/platform/graphics/mac/ComplexTextController.cpp',
91                'WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp',
92                'WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp',
93                'WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp',
94                'WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm',
95                'WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp',
96                'WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm',
97                'WebCore/platform/text/mac/ShapeArabic.c',
98                'WebCore/platform/wx/wxcode/mac/carbon/fontprops.mm',
99                'WebCore/plugins/mac/PluginPackageMac.cpp',
100                'WebCore/plugins/mac/PluginViewMac.mm'
101         ]
102     else:
103         webcore_sources['wx-gtk'] = [
104                'WebCore/plugins/PluginViewNone.cpp',
105                'WebCore/plugins/PluginPackageNone.cpp'
106         ]
107         webcore_dirs.append('WebCore/platform/wx/wxcode/gtk')
108         
109 import TaskGen
110 from TaskGen import taskgen, feature, after
111 import Task, ccroot
112
113 def generate_webcore_derived_sources():
114     # build the derived sources
115     derived_sources_dir = os.path.join(webcore_dir, 'DerivedSources')
116     wc_dir = webcore_dir
117     if building_on_win32:
118         wc_dir = get_output('cygpath --unix "%s"' % wc_dir)
119     if not os.path.exists(derived_sources_dir):
120         os.mkdir(derived_sources_dir)
121
122     olddir = os.getcwd()
123     os.chdir(derived_sources_dir)
124     
125     # DerivedSources.make expects Cygwin (i.e. Unix-style) python, so use that instead.
126     if building_on_win32:
127         oldpath = os.environ["PATH"]
128         os.environ["PATH"] = "/usr/bin" + os.pathsep + os.environ["PATH"]
129     os.system('make -f %s/DerivedSources.make WebCore=%s SOURCE_ROOT=%s all FEATURE_DEFINES="%s"' % (wc_dir, wc_dir, wc_dir, ' '.join(feature_defines)))
130     if building_on_win32:
131         os.environ["PATH"] = oldpath
132     os.chdir(olddir)
133
134 def generate_jscore_derived_sources():
135     # build the derived sources
136     js_dir = jscore_dir
137     if building_on_win32:
138         js_dir = get_output('cygpath --unix "%s"' % js_dir)
139     derived_sources_dir = os.path.join(jscore_dir, 'DerivedSources')
140     if not os.path.exists(derived_sources_dir):
141         os.mkdir(derived_sources_dir)
142
143     olddir = os.getcwd()
144     os.chdir(derived_sources_dir)
145
146     # DerivedSources.make expects Cygwin (i.e. Unix-style) python, so use that instead.
147     if building_on_win32:
148         oldpath = os.environ["PATH"]
149         os.environ["PATH"] = "/usr/bin" + os.pathsep + os.environ["PATH"]
150     command = 'make -f %s/DerivedSources.make JavaScriptCore=%s BUILT_PRODUCTS_DIR=%s all FEATURE_DEFINES="%s"' % (js_dir, js_dir, js_dir, ' '.join(feature_defines))
151     os.system(command)
152     if building_on_win32:
153         os.environ["PATH"] = oldpath
154     os.chdir(olddir)
155
156 def set_options(opt):
157     common_set_options(opt)
158
159 def configure(conf):
160     common_configure(conf)
161     generate_jscore_derived_sources()
162     generate_webcore_derived_sources()
163     if sys.platform.startswith('win'):
164         graphics_dir = os.path.join(wk_root, 'WebCore', 'platform', 'graphics')
165         # HACK ALERT: MSVC automatically adds the source file's directory as the first entry in the
166         # path. Unfortunately, that means when compiling these files we will end up including
167         # win/FontPlatformData.h, which breaks wx compilation. So we copy the files to the wx dir.
168         for afile in ['UniscribeController.h', 'UniscribeController.cpp', 'GlyphPageTreeNodeCairoWin.cpp']:
169             shutil.copy(os.path.join(graphics_dir, 'win', afile), os.path.join(graphics_dir, 'wx'))
170
171     webcore_out_dir = os.path.join(output_dir, 'WebCore')
172     if not os.path.exists(webcore_out_dir):
173         os.makedirs(webcore_out_dir)
174     shutil.copy('WebCore/platform/mac/WebCoreSystemInterface.h', os.path.join(output_dir, 'WebCore', 'WebCoreSystemInterface.h'))
175     jscore_out_dir = os.path.join(output_dir, 'JavaScriptCore')
176     if not os.path.exists(jscore_out_dir):
177         os.makedirs(jscore_out_dir)
178     for api_file in glob.glob(os.path.join(jscore_dir, 'API/*.h')):
179         shutil.copy(api_file, os.path.join(jscore_out_dir, os.path.basename(api_file)))
180
181     if Options.options.wxpython:
182         common_configure(conf)
183         conf.check_tool('swig', tooldir='WebKit/wx/bindings/python')
184         conf.check_swig_version('1.3.29')
185
186 def build(bld):  
187     import TaskGen
188     global wk_includes
189
190     bld.add_subdirs('JavaScriptCore')
191
192     if sys.platform.startswith('darwin'):
193         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cxx']
194         TaskGen.task_gen.mappings['.m'] = TaskGen.task_gen.mappings['.cxx']
195
196     features = [build_port]
197     exclude_patterns = ['*AllInOne.cpp', '*Brew.cpp', '*CFNet.cpp', '*Chromium*.cpp', 
198             '*Efl.cpp', '*Gtk.cpp', '*Haiku.cpp', '*Mac.cpp', '*None.cpp', '*Qt.cpp', '*Safari.cpp',
199             'test*bindings.*', '*Wince.cpp', "WebDOMCanvas*.cpp", "WebDOMSVG*.cpp"]
200     if build_port == 'wx':
201         features.append('curl')
202         exclude_patterns.append('*Win.cpp')
203         
204     if sys.platform.startswith('darwin'):
205         features.append('cf')
206         
207     else:
208         exclude_patterns.append('*CF.cpp')
209
210     full_dirs = get_dirs_for_features(wk_root, features=features, dirs=webcore_dirs)
211
212     jscore_dir = os.path.join(wk_root, 'JavaScriptCore')
213     for item in os.listdir(jscore_dir):
214         fullpath = os.path.join(jscore_dir, item)
215         if os.path.isdir(fullpath) and not item == "os-win32" and not item == 'icu':
216             wk_includes.append(fullpath)
217
218     wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode'))
219     wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode', 'icu'))
220     wk_includes += common_includes + full_dirs
221     if sys.platform.startswith('darwin'):
222         wk_includes.append(os.path.join(webcore_dir, 'icu'))
223
224     cxxflags = []
225     if building_on_win32:
226         cxxflags.append('/FIWebCorePrefix.h')
227     else:
228         cxxflags.extend(['-include', 'WebCorePrefix.h'])
229
230     webcore = bld.new_task_gen(
231         features = 'cc cxx cshlib',
232         includes = ' '.join(wk_includes),
233         source = ' '.join(flattenSources(webcore_sources.values())),
234         cxxflags = cxxflags,
235         defines = ['WXMAKINGDLL_WEBKIT', 'BUILDING_WebCore'],
236         libpath = [output_dir],
237         target = 'wxwebkit',
238         uselib = 'WX ICU XML XSLT CURL SQLITE3 WKINTERFACE ' + get_config(),
239         uselib_local = 'jscore',
240         install_path = output_dir,
241         )
242         
243     excludes = []
244     
245     if build_port == 'wx':
246         excludes = get_excludes(webcore_dir, exclude_patterns)
247         excludes.extend(['UserStyleSheetLoader.cpp', 'RenderMediaControls.cpp'])
248
249         # intermediate sources
250         excludes.append('ColorData.cpp')
251         excludes.append('CSSValueKeywords.cpp')
252         excludes.append('CSSPropertyNames.cpp')
253         excludes.append('DocTypeStrings.cpp')
254         excludes.append('HTMLEntityNames.cpp')
255         excludes.append('tokenizer.cpp')
256
257         # FIXME: these three require headers that I can't seem to find in trunk.
258         # Investigate how to resolve these issues.
259         excludes.append('JSAbstractView.cpp')
260         excludes.append('JSPositionCallback.cpp')
261         excludes.append('JSInspectorController.cpp')
262         
263         # The bindings generator seems to think these are ref-counted, while they aren't in trunk.
264         excludes.append('JSElementTimeControl.cpp')
265         excludes.append('JSSVGAnimatedPathData.cpp')
266         excludes.append('JSSVGAnimatedPoints.cpp')
267         excludes.append('JSSVGExternalResourcesRequired.cpp')
268         excludes.append('JSSVGFilterPrimitiveStandardAttributes.cpp')
269         excludes.append('JSSVGLocatable.cpp')
270         excludes.append('JSSVGStyleTable.cpp')
271         excludes.append('JSSVGTests.cpp')
272         excludes.append('JSSVGStylable.cpp')
273         excludes.append('JSSVGZoomAndPan.cpp')
274         
275         # These are files that expect methods not in the base C++ class, usually XYZAnimated methods.
276         excludes.append('JSSVGFitToViewBox.cpp')
277         excludes.append('JSSVGLangSpace.cpp')
278         excludes.append('JSSVGTransformable.cpp')
279         excludes.append('JSSVGURIReference.cpp')
280         
281         # These are C++ DOM Bindings that won't compile because they look for things not in trunk.
282         excludes.append('WebDOMEventTarget.cpp')
283         excludes.append('WebDOMAbstractView.cpp')
284         excludes.append('WebDOMBlobBuilder.cpp')
285         excludes.append('WebDOMEventListenerCustom.cpp')
286         excludes.append('WebDOMElementTimeControl.cpp')
287         excludes.append('WebDOMImageData.cpp')
288         excludes.append('WebDOMInspectorBackend.cpp')
289         excludes.append('WebDOMScriptProfile.cpp')
290         excludes.append('WebDOMScriptProfileNode.cpp')
291         excludes.append('WebNativeEventListener.cpp')
292         
293         if building_on_win32:
294             excludes.append('SharedTimerWx.cpp')
295             excludes.append('RenderThemeWin.cpp')
296             excludes.append('KeyEventWin.cpp')
297             
298         if building_on_win32 or sys.platform.startswith('darwin'):
299             excludes.append('GlyphMapWx.cpp')
300         excludes.append('AuthenticationCF.cpp')
301         excludes.append('LoaderRunLoopCF.cpp')
302         excludes.append('ResourceErrorCF.cpp')
303         
304         if sys.platform.startswith('darwin'):
305             webcore.includes += ' WebKit/mac/WebCoreSupport WebCore/platform/mac'
306             webcore.source += " WebKit/mac/WebCoreSupport/WebSystemInterface.mm"
307             
308     webcore.find_sources_in_dirs(full_dirs, excludes = excludes, exts=['.c', '.cpp'])
309
310     bld.add_group()
311     
312     bld.add_subdirs(['WebKitTools/DumpRenderTree', 'WebKitTools/wx/browser', 'WebKit/wx/bindings/python'])