3 # Copyright (C) 2009 Kevin Ollivier All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
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.
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.
26 # WebCore build script for the waf build system
30 from settings import *
33 from TaskGen import taskgen, feature, after
36 def generate_webcore_derived_sources(conf):
37 # build the derived sources
38 derived_sources_dir = os.path.join(webcore_dir, 'DerivedSources')
41 wc_dir = get_output('cygpath --unix "%s"' % wc_dir)
42 if not os.path.exists(derived_sources_dir):
43 os.mkdir(derived_sources_dir)
46 os.chdir(derived_sources_dir)
48 # DerivedSources.make expects Cygwin (i.e. Unix-style) python, so use that instead.
50 oldpath = os.environ["PATH"]
51 os.environ["PATH"] = "/usr/bin" + os.pathsep + os.environ["PATH"]
52 os.system('make -f %s/DerivedSources.make WebCore=%s SOURCE_ROOT=%s all FEATURE_DEFINES="%s"' % (wc_dir, wc_dir, wc_dir, conf.env["FEATURE_DEFINES"]))
54 os.environ["PATH"] = oldpath
57 def generate_jscore_derived_sources(conf):
58 # build the derived sources
61 js_dir = get_output('cygpath --unix "%s"' % js_dir)
62 derived_sources_dir = os.path.join(jscore_dir, 'DerivedSources')
63 if not os.path.exists(derived_sources_dir):
64 os.mkdir(derived_sources_dir)
67 os.chdir(derived_sources_dir)
69 # DerivedSources.make expects Cygwin (i.e. Unix-style) python, so use that instead.
71 oldpath = os.environ["PATH"]
72 os.environ["PATH"] = "/usr/bin" + os.pathsep + os.environ["PATH"]
73 command = 'make -f %s/DerivedSources.make JavaScriptCore=%s BUILT_PRODUCTS_DIR=%s all FEATURE_DEFINES="%s"' % (js_dir, js_dir, js_dir, conf.env["FEATURE_DEFINES"])
76 os.environ["PATH"] = oldpath
80 common_set_options(opt)
83 common_configure(conf)
84 generate_jscore_derived_sources(conf)
85 generate_webcore_derived_sources(conf)
86 if Options.options.port == "wx" and sys.platform.startswith('win'):
87 graphics_dir = os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'graphics')
88 # HACK ALERT: MSVC automatically adds the source file's directory as the first entry in the
89 # path. Unfortunately, that means when compiling these files we will end up including
90 # win/FontPlatformData.h, which breaks wx compilation. So we copy the files to the wx dir.
91 for afile in ['UniscribeController.h', 'UniscribeController.cpp', 'GlyphPageTreeNodeCairoWin.cpp']:
92 shutil.copy(os.path.join(graphics_dir, 'win', afile), os.path.join(graphics_dir, 'wx'))
94 webcore_out_dir = os.path.join(output_dir, 'WebCore')
95 if not os.path.exists(webcore_out_dir):
96 os.makedirs(webcore_out_dir)
97 shutil.copy('Source/WebCore/platform/mac/WebCoreSystemInterface.h', os.path.join(output_dir, 'WebCore', 'WebCoreSystemInterface.h'))
98 jscore_out_dir = os.path.join(output_dir, 'JavaScriptCore')
99 if not os.path.exists(jscore_out_dir):
100 os.makedirs(jscore_out_dir)
101 for api_file in glob.glob(os.path.join(jscore_dir, 'API/*.h')):
102 shutil.copy(api_file, os.path.join(jscore_out_dir, os.path.basename(api_file)))
104 if Options.options.port == "wx" and Options.options.wxpython:
105 common_configure(conf)
106 conf.check_tool('swig', tooldir='Source/WebKit/wx/bindings/python')
107 conf.check_swig_version('1.3.29')
111 webcore_dirs = list(webcore_dirs_common)
113 if Options.options.port == "wx":
114 webcore_dirs.extend(['Source/WebKit/wx', 'Source/WebKit/wx/WebKitSupport'])
117 os.path.join(wk_root, 'Source', 'JavaScriptCore'),
118 os.path.join(wk_root, 'Source', 'JavaScriptCore', 'wtf', 'text'),
119 os.path.join(wk_root, 'Source', 'WebCore'),
120 os.path.join(wk_root, 'Source', 'WebCore', 'DerivedSources'),
121 os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'image-decoders'),
122 os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'win'),
123 os.path.join(wk_root, 'Source', 'WebCore', 'workers'),
124 os.path.join(output_dir),
127 if Options.options.port == "wx":
128 wk_includes.append(os.path.join(wk_root, 'Source', 'WebKit', 'wx'))
129 wk_includes.append(os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'wx', 'wxcode'))
131 if sys.platform.startswith("win"):
132 wk_includes.append(os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'win'))
133 wk_includes.append(os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'graphics', 'win'))
136 'lib/pthreadVC2.dll',
137 'bin/icuuc40.dll', 'bin/icudt40.dll', 'bin/icuin40.dll',
138 'bin/libcurl.dll', 'bin/libeay32.dll', 'bin/ssleay32.dll', 'bin/zlib1.dll',
139 'lib/sqlite3.dll', 'bin/libxml2.dll', 'bin/libxslt.dll', 'bin/iconv.dll',
144 if Options.options.port == "wx":
145 webcore_sources['wx'] = [
146 'Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp',
147 'Source/WebCore/platform/KillRingNone.cpp',
148 'Source/WebCore/platform/text/LocalizedNumberNone.cpp'
151 if building_on_win32:
152 # make sure platform/wx comes after this so we get the right
154 webcore_dirs.extend(['Source/WebCore/platform/wx/wxcode/win', 'Source/WebCore/plugins/win'])
155 webcore_sources['wx-win'] = [
156 'Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp',
157 'Source/WebCore/platform/graphics/win/TransformationMatrixWin.cpp',
158 'Source/WebCore/platform/ScrollAnimatorWin.cpp',
159 # wxTimer on Windows has a bug that causes it to eat crashes in callbacks
160 # so we need to use the Win port's implementation until the wx bug fix is
161 # widely available (it was fixed in 2.8.10).
162 'Source/WebCore/platform/win/SharedTimerWin.cpp',
163 'Source/WebCore/platform/win/WebCoreInstanceHandle.cpp',
164 # Use the Windows plugin architecture
165 #'Source/WebCore/plugins/win/PluginDataWin.cpp',
166 'Source/WebCore/plugins/win/PluginDatabaseWin.cpp',
167 'Source/WebCore/plugins/win/PluginMessageThrottlerWin.cpp',
168 'Source/WebCore/plugins/win/PluginPackageWin.cpp',
169 'Source/WebCore/plugins/win/PluginViewWin.cpp',
171 elif sys.platform.startswith('darwin'):
172 webcore_dirs.append('Source/WebCore/plugins/mac')
173 webcore_dirs.append('Source/WebCore/platform/wx/wxcode/mac/carbon')
174 webcore_dirs.append('Source/WebCore/platform/mac')
175 webcore_dirs.append('Source/WebCore/platform/text/mac')
176 webcore_sources['wx-mac'] = [
177 'Source/WebCore/platform/mac/PurgeableBufferMac.cpp',
178 'Source/WebCore/platform/mac/WebCoreNSStringExtras.mm',
179 'Source/WebCore/platform/mac/WebCoreSystemInterface.mm',
180 'Source/WebCore/platform/graphics/cg/FloatSizeCG.cpp',
181 'Source/WebCore/platform/graphics/mac/ComplexTextController.cpp',
182 'Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp',
183 'Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp',
184 'Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp',
185 'Source/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm',
186 'Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp',
187 'Source/WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm',
188 'Source/WebCore/platform/text/mac/ShapeArabic.c',
189 'Source/WebCore/platform/wx/wxcode/mac/carbon/fontprops.mm',
190 'Source/WebCore/plugins/mac/PluginPackageMac.cpp',
191 'Source/WebCore/plugins/mac/PluginViewMac.mm'
194 webcore_sources['wx-gtk'] = [
195 'Source/WebCore/plugins/PluginViewNone.cpp',
196 'Source/WebCore/plugins/PluginPackageNone.cpp'
198 webcore_dirs.append('Source/WebCore/platform/wx/wxcode/gtk')
203 # FIXME: Does this need to be Source/JavaScriptCore?
204 bld.add_subdirs('Source/JavaScriptCore')
206 if sys.platform.startswith('darwin'):
207 TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cxx']
208 TaskGen.task_gen.mappings['.m'] = TaskGen.task_gen.mappings['.cxx']
210 features = [Options.options.port.lower()]
211 exclude_patterns = ['*AllInOne.cpp', '*Brew.cpp', '*CFNet.cpp', '*Chromium*.cpp',
212 '*Efl.cpp', '*Gtk.cpp', '*Haiku.cpp', '*Mac.cpp', '*None.cpp', '*Qt.cpp', '*Safari.cpp',
213 'test*bindings.*', '*WinCE.cpp', "WebDOMCanvas*.cpp", "WebDOMSVG*.cpp"]
214 if Options.options.port == 'wx':
215 features.append('curl')
216 exclude_patterns.append('*Win.cpp')
218 if sys.platform.startswith('darwin'):
219 features.append('cf')
222 exclude_patterns.append('*CF.cpp')
224 full_dirs = get_dirs_for_features(wk_root, features=features, dirs=webcore_dirs)
226 jscore_dir = os.path.join(wk_root, 'Source', 'JavaScriptCore')
227 for item in os.listdir(jscore_dir):
228 fullpath = os.path.join(jscore_dir, item)
229 if os.path.isdir(fullpath) and not item == "os-win32" and not item == 'icu':
230 wk_includes.append(fullpath)
232 wk_includes.append('Source')
233 wk_includes.append(os.path.join(jscore_dir, 'collector', 'handles'))
234 wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode'))
235 wk_includes.append(os.path.join(jscore_dir, 'wtf', 'unicode', 'icu'))
236 wk_includes += common_includes + full_dirs
237 if sys.platform.startswith('darwin'):
238 wk_includes.append(os.path.join(webcore_dir, 'icu'))
241 if building_on_win32:
242 cxxflags.append('/FIWebCorePrefix.h')
243 # FIXME: We do this because in waf, local include dirs take precedence
244 # over global ones. This makes sense, but because unicode/utf8.h is both
245 # an ICU header name and a WebKit header name (in Source/JavaScriptCore/wtf)
246 # we have to make sure <unicode/utf8.h> picks up the ICU one first.
248 wk_includes.append(os.path.join(msvclibs_dir, 'include'))
250 cxxflags.extend(['-include', 'WebCorePrefix.h'])
252 webcore = bld.new_task_gen(
253 features = 'cc cxx cshlib',
254 includes = ' '.join(wk_includes),
255 source = ' '.join(flattenSources(webcore_sources.values())),
257 defines = ['WXMAKINGDLL_WEBKIT', 'BUILDING_WebCore'],
258 libpath = [output_dir],
260 uselib = 'WX ICU XML XSLT CURL SQLITE3 WKINTERFACE ' + get_config(),
261 uselib_local = 'jscore',
262 install_path = output_dir,
267 if Options.options.port == 'wx':
268 excludes = get_excludes(webcore_dir, exclude_patterns)
269 excludes.extend(['UserStyleSheetLoader.cpp', 'RenderMediaControls.cpp'])
271 # intermediate sources
272 excludes.append('DocTypeStrings.cpp')
273 excludes.append('HTMLEntityNames.cpp')
274 excludes.append('tokenizer.cpp')
276 # Qt specific file in common sources
277 excludes.append('ContextShadow.cpp')
279 # FIXME: these three require headers that I can't seem to find in trunk.
280 # Investigate how to resolve these issues.
281 excludes.append('JSAbstractView.cpp')
282 excludes.append('JSPositionCallback.cpp')
283 excludes.append('JSInspectorController.cpp')
285 # The bindings generator seems to think these are ref-counted, while they aren't in trunk.
286 excludes.append('JSElementTimeControl.cpp')
287 excludes.append('JSSVGAnimatedPathData.cpp')
288 excludes.append('JSSVGAnimatedPoints.cpp')
289 excludes.append('JSSVGExternalResourcesRequired.cpp')
290 excludes.append('JSSVGFilterPrimitiveStandardAttributes.cpp')
291 excludes.append('JSSVGLocatable.cpp')
292 excludes.append('JSSVGStyleTable.cpp')
293 excludes.append('JSSVGTests.cpp')
294 excludes.append('JSSVGStylable.cpp')
295 excludes.append('JSSVGZoomAndPan.cpp')
297 # These are files that expect methods not in the base C++ class, usually XYZAnimated methods.
298 excludes.append('JSSVGFitToViewBox.cpp')
299 excludes.append('JSSVGLangSpace.cpp')
300 excludes.append('JSSVGTransformable.cpp')
301 excludes.append('JSSVGURIReference.cpp')
303 # These are C++ DOM Bindings that won't compile because they look for things not in trunk.
304 excludes.append('WebDOMEventTarget.cpp')
305 excludes.append('WebDOMAbstractView.cpp')
306 excludes.append('WebDOMBlobBuilder.cpp')
307 excludes.append('WebDOMEventListenerCustom.cpp')
308 excludes.append('WebDOMElementTimeControl.cpp')
309 excludes.append('WebDOMImageData.cpp')
310 excludes.append('WebDOMInspectorBackend.cpp')
311 excludes.append('WebDOMScriptProfile.cpp')
312 excludes.append('WebDOMScriptProfileNode.cpp')
313 excludes.append('WebNativeEventListener.cpp')
315 # This file appears not to build with older versions of ICU
316 excludes.append('LocalizedNumberICU.cpp')
318 if building_on_win32:
319 excludes.append('SharedTimerWx.cpp')
320 excludes.append('RenderThemeWin.cpp')
321 excludes.append('KeyEventWin.cpp')
323 if building_on_win32 or sys.platform.startswith('darwin'):
324 excludes.append('GlyphMapWx.cpp')
325 excludes.append('AuthenticationCF.cpp')
326 excludes.append('LoaderRunLoopCF.cpp')
327 excludes.append('ResourceErrorCF.cpp')
329 # once we move over to the new FPD implementation, remove this.
330 excludes.append('FontPlatformData.cpp')
332 if sys.platform.startswith('darwin'):
333 webcore.includes += ' Source/WebKit/mac/WebCoreSupport WebCore/platform/mac'
334 webcore.source += ' Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm'
336 if building_on_win32:
337 for wxlib in bld.env['LIB_WX']:
338 wxlibname = os.path.join(bld.env['LIBPATH_WX'][0], wxlib + '_vc.dll')
339 if os.path.exists(wxlibname):
340 bld.install_files(webcore.install_path, [wxlibname])
342 for dep in windows_deps:
343 bld.install_files(webcore.install_path, [os.path.join(msvclibs_dir, dep)])
345 webcore.find_sources_in_dirs(full_dirs, excludes = excludes, exts=['.c', '.cpp'])
349 if Options.options.port == "wx":
350 bld.add_subdirs(['Tools/DumpRenderTree', 'Tools/wx/browser', 'Source/WebKit/wx/bindings/python'])