Move JavaScriptCore to Source
[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 if build_port == "wx":
33     webcore_dirs.extend(['WebKit/wx', 'WebKit/wx/WebKitSupport'])
34
35 wk_includes = ['.', 'WebCore', 'WebCore/DerivedSources',
36                 os.path.join(wk_root, 'Source', 'JavaScriptCore'),
37                 os.path.join(wk_root, 'Source', 'JavaScriptCore', 'wtf', 'text'),
38                 os.path.join(wk_root, 'WebCore'),
39                 os.path.join(output_dir),
40                 'WebCore/platform/image-decoders',
41                 'WebCore/platform/win',
42                 'WebCore/workers',
43         ]
44
45 if build_port == "wx":
46     wk_includes.append(os.path.join(wk_root, 'WebKit/wx'))
47     wk_includes.append('WebCore/platform/wx/wxcode')
48
49 if sys.platform.startswith("win"):
50     wk_includes.append(os.path.join(wk_root, 'WebCore','platform','win'))
51     wk_includes.append(os.path.join(wk_root, 'WebCore','platform','graphics','win'))
52
53 windows_deps = [
54                 'lib/pthreadVC2.dll',
55                 'bin/icuuc40.dll', 'bin/icudt40.dll', 'bin/icuin40.dll',
56                 'bin/libcurl.dll', 'bin/libeay32.dll', 'bin/ssleay32.dll', 'bin/zlib1.dll',
57                 'lib/sqlite3.dll', 'bin/libxml2.dll', 'bin/libxslt.dll', 'bin/iconv.dll',
58                 ]
59
60 webcore_sources = {}
61
62 if build_port == "wx":
63     webcore_sources['wx'] = ['WebCore/platform/KillRingNone.cpp', 'WebCore/bindings/cpp/WebDOMEventTarget.cpp']  
64
65     if building_on_win32:
66         # make sure platform/wx comes after this so we get the right
67         # FontPlatformData.h
68         webcore_dirs.extend(['WebCore/platform/wx/wxcode/win', 'WebCore/plugins/win'])
69         webcore_sources['wx-win'] = [
70                'WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp',
71                'WebCore/platform/graphics/win/TransformationMatrixWin.cpp',
72                'WebCore/platform/ScrollAnimatorWin.cpp',
73                # wxTimer on Windows has a bug that causes it to eat crashes in callbacks
74                # so we need to use the Win port's implementation until the wx bug fix is
75                # widely available (it was fixed in 2.8.10).
76                'WebCore/platform/win/SharedTimerWin.cpp',
77                'WebCore/platform/win/WebCoreInstanceHandle.cpp',
78                # Use the Windows plugin architecture
79                #'WebCore/plugins/win/PluginDataWin.cpp',
80                'WebCore/plugins/win/PluginDatabaseWin.cpp',
81                'WebCore/plugins/win/PluginMessageThrottlerWin.cpp',
82                'WebCore/plugins/win/PluginPackageWin.cpp',
83                'WebCore/plugins/win/PluginViewWin.cpp',
84         ]
85     elif sys.platform.startswith('darwin'):
86         webcore_dirs.append('WebCore/plugins/mac')
87         webcore_dirs.append('WebCore/platform/wx/wxcode/mac/carbon')
88         webcore_dirs.append('WebCore/platform/mac')
89         webcore_dirs.append('WebCore/platform/text/mac')
90         webcore_sources['wx-mac'] = [
91                'WebCore/platform/mac/PurgeableBufferMac.cpp',
92                'WebCore/platform/mac/WebCoreNSStringExtras.mm',
93                'WebCore/platform/mac/WebCoreSystemInterface.mm',
94                'WebCore/platform/graphics/cg/FloatSizeCG.cpp',
95                'WebCore/platform/graphics/mac/ComplexTextController.cpp',
96                'WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp',
97                'WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp',
98                'WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp',
99                'WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm',
100                'WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp',
101                'WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm',
102                'WebCore/platform/text/mac/ShapeArabic.c',
103                'WebCore/platform/wx/wxcode/mac/carbon/fontprops.mm',
104                'WebCore/plugins/mac/PluginPackageMac.cpp',
105                'WebCore/plugins/mac/PluginViewMac.mm'
106         ]
107     else:
108         webcore_sources['wx-gtk'] = [
109                'WebCore/plugins/PluginViewNone.cpp',
110                'WebCore/plugins/PluginPackageNone.cpp'
111         ]
112         webcore_dirs.append('WebCore/platform/wx/wxcode/gtk')
113         
114 import TaskGen
115 from TaskGen import taskgen, feature, after
116 import Task, ccroot
117
118 def generate_webcore_derived_sources():
119     # build the derived sources
120     derived_sources_dir = os.path.join(webcore_dir, 'DerivedSources')
121     wc_dir = webcore_dir
122     if building_on_win32:
123         wc_dir = get_output('cygpath --unix "%s"' % wc_dir)
124     if not os.path.exists(derived_sources_dir):
125         os.mkdir(derived_sources_dir)
126
127     olddir = os.getcwd()
128     os.chdir(derived_sources_dir)
129     
130     # DerivedSources.make expects Cygwin (i.e. Unix-style) python, so use that instead.
131     if building_on_win32:
132         oldpath = os.environ["PATH"]
133         os.environ["PATH"] = "/usr/bin" + os.pathsep + os.environ["PATH"]
134     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)))
135     if building_on_win32:
136         os.environ["PATH"] = oldpath
137     os.chdir(olddir)
138
139 def generate_jscore_derived_sources():
140     # build the derived sources
141     js_dir = jscore_dir
142     if building_on_win32:
143         js_dir = get_output('cygpath --unix "%s"' % js_dir)
144     derived_sources_dir = os.path.join(jscore_dir, 'DerivedSources')
145     if not os.path.exists(derived_sources_dir):
146         os.mkdir(derived_sources_dir)
147
148     olddir = os.getcwd()
149     os.chdir(derived_sources_dir)
150
151     # DerivedSources.make expects Cygwin (i.e. Unix-style) python, so use that instead.
152     if building_on_win32:
153         oldpath = os.environ["PATH"]
154         os.environ["PATH"] = "/usr/bin" + os.pathsep + os.environ["PATH"]
155     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))
156     os.system(command)
157     if building_on_win32:
158         os.environ["PATH"] = oldpath
159     os.chdir(olddir)
160
161 def set_options(opt):
162     common_set_options(opt)
163
164 def configure(conf):
165     common_configure(conf)
166     generate_jscore_derived_sources()
167     generate_webcore_derived_sources()
168     if build_port == "wx" and sys.platform.startswith('win'):
169         graphics_dir = os.path.join(wk_root, 'WebCore', 'platform', 'graphics')
170         # HACK ALERT: MSVC automatically adds the source file's directory as the first entry in the
171         # path. Unfortunately, that means when compiling these files we will end up including
172         # win/FontPlatformData.h, which breaks wx compilation. So we copy the files to the wx dir.
173         for afile in ['UniscribeController.h', 'UniscribeController.cpp', 'GlyphPageTreeNodeCairoWin.cpp']:
174             shutil.copy(os.path.join(graphics_dir, 'win', afile), os.path.join(graphics_dir, 'wx'))
175
176     webcore_out_dir = os.path.join(output_dir, 'WebCore')
177     if not os.path.exists(webcore_out_dir):
178         os.makedirs(webcore_out_dir)
179     shutil.copy('WebCore/platform/mac/WebCoreSystemInterface.h', os.path.join(output_dir, 'WebCore', 'WebCoreSystemInterface.h'))
180     jscore_out_dir = os.path.join(output_dir, 'JavaScriptCore')
181     if not os.path.exists(jscore_out_dir):
182         os.makedirs(jscore_out_dir)
183     for api_file in glob.glob(os.path.join(jscore_dir, 'API/*.h')):
184         shutil.copy(api_file, os.path.join(jscore_out_dir, os.path.basename(api_file)))
185
186     if build_port == "wx" and Options.options.wxpython:
187         common_configure(conf)
188         conf.check_tool('swig', tooldir='WebKit/wx/bindings/python')
189         conf.check_swig_version('1.3.29')
190
191 def build(bld):  
192     import TaskGen
193     global wk_includes
194
195     # FIXME: Does this need to be Source/JavaScriptCore?
196     bld.add_subdirs('JavaScriptCore')
197
198     if sys.platform.startswith('darwin'):
199         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cxx']
200         TaskGen.task_gen.mappings['.m'] = TaskGen.task_gen.mappings['.cxx']
201
202     features = [build_port]
203     exclude_patterns = ['*AllInOne.cpp', '*Brew.cpp', '*CFNet.cpp', '*Chromium*.cpp', 
204             '*Efl.cpp', '*Gtk.cpp', '*Haiku.cpp', '*Mac.cpp', '*None.cpp', '*Qt.cpp', '*Safari.cpp',
205             'test*bindings.*', '*WinCE.cpp', "WebDOMCanvas*.cpp", "WebDOMSVG*.cpp"]
206     if build_port == 'wx':
207         features.append('curl')
208         exclude_patterns.append('*Win.cpp')
209         
210     if sys.platform.startswith('darwin'):
211         features.append('cf')
212         
213     else:
214         exclude_patterns.append('*CF.cpp')
215
216     full_dirs = get_dirs_for_features(wk_root, features=features, dirs=webcore_dirs)
217
218     jscore_dir = os.path.join(wk_root, 'Source', 'JavaScriptCore')
219     for item in os.listdir(jscore_dir):
220         fullpath = os.path.join(jscore_dir, item)
221         if os.path.isdir(fullpath) and not item == "os-win32" and not item == 'icu':
222             wk_includes.append(fullpath)
223
224     wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode'))
225     wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode', 'icu'))
226     wk_includes += common_includes + full_dirs
227     if sys.platform.startswith('darwin'):
228         wk_includes.append(os.path.join(webcore_dir, 'icu'))
229
230     cxxflags = []
231     if building_on_win32:
232         cxxflags.append('/FIWebCorePrefix.h')
233     else:
234         cxxflags.extend(['-include', 'WebCorePrefix.h'])
235
236     webcore = bld.new_task_gen(
237         features = 'cc cxx cshlib',
238         includes = ' '.join(wk_includes),
239         source = ' '.join(flattenSources(webcore_sources.values())),
240         cxxflags = cxxflags,
241         defines = ['WXMAKINGDLL_WEBKIT', 'BUILDING_WebCore'],
242         libpath = [output_dir],
243         target = 'wxwebkit',
244         uselib = 'WX ICU XML XSLT CURL SQLITE3 WKINTERFACE ' + get_config(),
245         uselib_local = 'jscore',
246         install_path = output_dir,
247         )
248         
249     excludes = []
250     
251     if build_port == 'wx':
252         excludes = get_excludes(webcore_dir, exclude_patterns)
253         excludes.extend(['UserStyleSheetLoader.cpp', 'RenderMediaControls.cpp'])
254
255         # intermediate sources
256         excludes.append('DocTypeStrings.cpp')
257         excludes.append('HTMLEntityNames.cpp')
258         excludes.append('tokenizer.cpp')
259
260         # Qt specific file in common sources
261         excludes.append('ContextShadow.cpp')
262
263         # FIXME: these three require headers that I can't seem to find in trunk.
264         # Investigate how to resolve these issues.
265         excludes.append('JSAbstractView.cpp')
266         excludes.append('JSPositionCallback.cpp')
267         excludes.append('JSInspectorController.cpp')
268         
269         # The bindings generator seems to think these are ref-counted, while they aren't in trunk.
270         excludes.append('JSElementTimeControl.cpp')
271         excludes.append('JSSVGAnimatedPathData.cpp')
272         excludes.append('JSSVGAnimatedPoints.cpp')
273         excludes.append('JSSVGExternalResourcesRequired.cpp')
274         excludes.append('JSSVGFilterPrimitiveStandardAttributes.cpp')
275         excludes.append('JSSVGLocatable.cpp')
276         excludes.append('JSSVGStyleTable.cpp')
277         excludes.append('JSSVGTests.cpp')
278         excludes.append('JSSVGStylable.cpp')
279         excludes.append('JSSVGZoomAndPan.cpp')
280         
281         # These are files that expect methods not in the base C++ class, usually XYZAnimated methods.
282         excludes.append('JSSVGFitToViewBox.cpp')
283         excludes.append('JSSVGLangSpace.cpp')
284         excludes.append('JSSVGTransformable.cpp')
285         excludes.append('JSSVGURIReference.cpp')
286         
287         # These are C++ DOM Bindings that won't compile because they look for things not in trunk.
288         excludes.append('WebDOMEventTarget.cpp')
289         excludes.append('WebDOMAbstractView.cpp')
290         excludes.append('WebDOMBlobBuilder.cpp')
291         excludes.append('WebDOMEventListenerCustom.cpp')
292         excludes.append('WebDOMElementTimeControl.cpp')
293         excludes.append('WebDOMImageData.cpp')
294         excludes.append('WebDOMInspectorBackend.cpp')
295         excludes.append('WebDOMScriptProfile.cpp')
296         excludes.append('WebDOMScriptProfileNode.cpp')
297         excludes.append('WebNativeEventListener.cpp')
298         
299         if building_on_win32:
300             excludes.append('SharedTimerWx.cpp')
301             excludes.append('RenderThemeWin.cpp')
302             excludes.append('KeyEventWin.cpp')
303             
304         if building_on_win32 or sys.platform.startswith('darwin'):
305             excludes.append('GlyphMapWx.cpp')
306         excludes.append('AuthenticationCF.cpp')
307         excludes.append('LoaderRunLoopCF.cpp')
308         excludes.append('ResourceErrorCF.cpp')
309         
310         if sys.platform.startswith('darwin'):
311             webcore.includes += ' WebKit/mac/WebCoreSupport WebCore/platform/mac'
312             webcore.source += " WebKit/mac/WebCoreSupport/WebSystemInterface.mm"
313             
314         if building_on_win32:
315             for wxlib in bld.env['LIB_WX']:
316                 wxlibname = os.path.join(bld.env['LIBPATH_WX'][0], wxlib + '_vc.dll')
317                 if os.path.exists(wxlibname):
318                     bld.install_files(webcore.install_path, [wxlibname])
319         
320             for dep in windows_deps:
321                 bld.install_files(webcore.install_path, [os.path.join(msvclibs_dir, dep)])
322
323     webcore.find_sources_in_dirs(full_dirs, excludes = excludes, exts=['.c', '.cpp'])
324
325     bld.add_group()
326     
327     if build_port == "wx":    
328         bld.add_subdirs(['Tools/DumpRenderTree', 'Tools/wx/browser', 'WebKit/wx/bindings/python'])