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 *
34 from TaskGen import taskgen, feature, after
37 def generate_webcore_derived_sources(conf):
38 # build the derived sources
39 derived_sources_dir = os.path.join(webcore_dir, 'DerivedSources')
42 wc_dir = get_output('cygpath --unix "%s"' % wc_dir)
43 if not os.path.exists(derived_sources_dir):
44 os.mkdir(derived_sources_dir)
47 os.chdir(derived_sources_dir)
49 # DerivedSources.make expects Cygwin (i.e. Unix-style) python, so use that instead.
51 oldpath = os.environ["PATH"]
52 os.environ["PATH"] = "/usr/bin" + os.pathsep + os.environ["PATH"]
53 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"]))
55 os.environ["PATH"] = oldpath
56 os.system('perl %s/Source/WebKit/scripts/generate-webkitversion.pl --outputDir=%s --config %s/Source/WebKit/mac/Configurations/Version.xcconfig' % (wk_root, derived_sources_dir, wk_root))
59 def generate_jscore_derived_sources(conf):
60 # build the derived sources
63 js_dir = get_output('cygpath --unix "%s"' % js_dir)
64 derived_sources_dir = os.path.join(jscore_dir, 'DerivedSources')
65 if not os.path.exists(derived_sources_dir):
66 os.mkdir(derived_sources_dir)
69 os.chdir(derived_sources_dir)
71 # DerivedSources.make expects Cygwin (i.e. Unix-style) python, so use that instead.
73 oldpath = os.environ["PATH"]
74 os.environ["PATH"] = "/usr/bin" + os.pathsep + os.environ["PATH"]
75 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"])
78 os.environ["PATH"] = oldpath
82 common_set_options(opt)
85 common_configure(conf)
86 generate_jscore_derived_sources(conf)
87 generate_webcore_derived_sources(conf)
88 if Options.options.port == "wx" and sys.platform.startswith('win'):
89 graphics_dir = os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'graphics')
90 # HACK ALERT: MSVC automatically adds the source file's directory as the first entry in the
91 # path. Unfortunately, that means when compiling these files we will end up including
92 # win/FontPlatformData.h, which breaks wx compilation. So we copy the files to the wx dir.
93 for afile in ['UniscribeController.h', 'UniscribeController.cpp', 'GlyphPageTreeNodeCairoWin.cpp']:
94 shutil.copy(os.path.join(graphics_dir, 'win', afile), os.path.join(graphics_dir, 'wx'))
96 webcore_out_dir = os.path.join(output_dir, 'WebCore')
97 if not os.path.exists(webcore_out_dir):
98 os.makedirs(webcore_out_dir)
99 shutil.copy('Source/WebCore/platform/mac/WebCoreSystemInterface.h', os.path.join(output_dir, 'WebCore', 'WebCoreSystemInterface.h'))
100 jscore_out_dir = os.path.join(output_dir, 'JavaScriptCore')
101 if not os.path.exists(jscore_out_dir):
102 os.makedirs(jscore_out_dir)
103 for api_file in glob.glob(os.path.join(jscore_dir, 'API/*.h')):
104 shutil.copy(api_file, os.path.join(jscore_out_dir, os.path.basename(api_file)))
106 if Options.options.port == "wx" and Options.options.wxpython:
107 common_configure(conf)
108 conf.check_tool('swig', tooldir='Source/WebKit/wx/bindings/python')
109 conf.check_swig_version('1.3.29')
113 webcore_dirs = list(webcore_dirs_common)
115 if Options.options.port == "wx":
116 webcore_dirs.extend(['Source/WebKit/wx', 'Source/WebKit/wx/WebKitSupport'])
119 os.path.join(wk_root, 'Source', 'WTF'),
120 os.path.join(wk_root, 'Source', 'WTF', 'wtf'),
121 os.path.join(wk_root, 'Source', 'JavaScriptCore'),
122 os.path.join(wk_root, 'Source', 'WebCore'),
123 os.path.join(wk_root, 'Source', 'WebCore', 'DerivedSources'),
124 os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'image-decoders'),
125 os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'win'),
126 os.path.join(wk_root, 'Source', 'WebCore', 'workers'),
127 os.path.join(output_dir),
130 if Options.options.port == "wx":
131 wk_includes.append(os.path.join(wk_root, 'Source', 'WebKit', 'wx'))
132 wk_includes.append(os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'wx', 'wxcode'))
134 if sys.platform.startswith("win"):
135 wk_includes.append(os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'win'))
136 wk_includes.append(os.path.join(wk_root, 'Source', 'WebCore', 'platform', 'graphics', 'win'))
139 'lib/pthreadVC2.dll',
140 'bin/icuuc40.dll', 'bin/icudt40.dll', 'bin/icuin40.dll',
141 'bin/libcurl.dll', 'bin/libeay32.dll', 'bin/ssleay32.dll', 'bin/zlib1.dll',
142 'lib/sqlite3.dll', 'bin/libxml2.dll', 'bin/libxslt.dll', 'bin/iconv.dll',
147 if Options.options.port == "wx":
148 webcore_sources['wx'] = [
149 'Source/WebCore/bindings/cpp/WebDOMEventTarget.cpp',
150 'Source/WebCore/platform/KillRingNone.cpp',
151 'Source/WebCore/platform/text/LocalizedDateNone.cpp',
152 'Source/WebCore/platform/text/LocalizedNumberNone.cpp',
153 'Source/WebCore/page/scrolling/ScrollingCoordinatorNone.cpp',
156 if building_on_win32:
157 # make sure platform/wx comes after this so we get the right
159 webcore_dirs.extend(['Source/WebCore/platform/wx/wxcode/win', 'Source/WebCore/plugins/win'])
160 webcore_sources['wx-win'] = [
161 'Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp',
162 'Source/WebCore/platform/graphics/win/TransformationMatrixWin.cpp',
163 'Source/WebCore/platform/ScrollAnimatorNone.cpp',
164 # wxTimer on Windows has a bug that causes it to eat crashes in callbacks
165 # so we need to use the Win port's implementation until the wx bug fix is
166 # widely available (it was fixed in 2.8.10).
167 'Source/WebCore/platform/win/SharedTimerWin.cpp',
168 'Source/WebCore/platform/win/SystemInfo.cpp',
169 'Source/WebCore/platform/win/WebCoreInstanceHandle.cpp',
170 # Use the Windows plugin architecture
171 #'Source/WebCore/plugins/win/PluginDataWin.cpp',
172 'Source/WebCore/plugins/win/PluginDatabaseWin.cpp',
173 'Source/WebCore/plugins/win/PluginMessageThrottlerWin.cpp',
174 'Source/WebCore/plugins/win/PluginPackageWin.cpp',
175 'Source/WebCore/plugins/win/PluginViewWin.cpp',
177 if Options.options.cairo:
178 webcore_dirs.append('Source/WebCore/platform/wx/wxcode/cairo')
180 webcore_dirs.append('Source/WebCore/platform/wx/wxcode/gdiplus')
181 elif sys.platform.startswith('darwin'):
182 webcore_dirs.append('Source/WebCore/plugins/mac')
183 webcore_dirs.append('Source/WebCore/platform/wx/wxcode/mac/carbon')
184 webcore_dirs.append('Source/WebCore/platform/text/mac')
185 webcore_sources['wx-mac'] = [
186 'Source/WebCore/platform/mac/PurgeableBufferMac.cpp',
187 'Source/WebCore/platform/mac/WebCoreNSStringExtras.mm',
188 'Source/WebCore/platform/mac/WebCoreSystemInterface.mm',
189 'Source/WebCore/platform/graphics/cg/FloatSizeCG.cpp',
190 'Source/WebCore/platform/graphics/mac/ComplexTextController.cpp',
191 'Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm',
192 'Source/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp',
193 'Source/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp',
194 'Source/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm',
195 'Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp',
196 'Source/WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm',
197 'Source/WebCore/platform/wx/wxcode/mac/carbon/fontprops.mm',
198 'Source/WebCore/plugins/mac/PluginPackageMac.cpp',
199 'Source/WebCore/plugins/mac/PluginViewMac.mm'
202 webcore_sources['wx-gtk'] = [
203 'Source/WebCore/plugins/PluginViewNone.cpp',
204 'Source/WebCore/plugins/PluginPackageNone.cpp'
206 webcore_dirs.append('Source/WebCore/platform/wx/wxcode/gtk')
207 webcore_dirs.append('Source/WebCore/platform/wx/wxcode/cairo')
212 bld.add_subdirs('Source/WTF Source/JavaScriptCore')
214 if sys.platform.startswith('darwin'):
215 TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cxx']
216 TaskGen.task_gen.mappings['.m'] = TaskGen.task_gen.mappings['.cxx']
218 features = [Options.options.port.lower()]
219 thisport = Options.options.port
221 exclude_patterns = ['*AllInOne.cpp', '*None.cpp',]
223 if sys.platform.startswith('darwin'):
224 features.append('cf')
226 # exclude the filename patterns for all other ports.
227 exclude_patterns.extend(get_port_excludes(Options.options.port))
229 if Options.options.port == 'wx':
230 features.append('curl')
231 exclude_patterns.extend(['*CFNet.cpp', 'test*bindings.*', "WebDOMCanvas*.cpp", "WebDOMSVG*.cpp"])
233 full_dirs = get_dirs_for_features(wk_root, features=features, dirs=webcore_dirs)
235 # make sure we don't use the CF networking engine
236 if Options.options.port == 'wx' and sys.platform.startswith('darwin'):
237 full_dirs.remove('Source/WebCore/platform/network/cf')
239 jscore_dir = os.path.join(wk_root, 'Source', 'JavaScriptCore')
240 for item in os.listdir(jscore_dir):
241 fullpath = os.path.join(jscore_dir, item)
242 if os.path.isdir(fullpath) and not item == "os-win32" and not item == 'icu':
243 wk_includes.append(fullpath)
245 wk_includes.append('Source')
246 wk_includes.append(os.path.join(jscore_dir, 'collector', 'handles'))
247 wk_includes += common_includes + full_dirs
248 if sys.platform.startswith('darwin'):
249 wk_includes.append(os.path.join(webcore_dir, 'icu'))
252 if building_on_win32:
253 cxxflags.append('/FIWebCorePrefix.h')
254 # FIXME: We do this because in waf, local include dirs take precedence
255 # over global ones. This makes sense, but because unicode/utf8.h is both
256 # an ICU header name and a WebKit header name (in Source/JavaScriptCore/wtf)
257 # we have to make sure <unicode/utf8.h> picks up the ICU one first.
259 wk_includes.append(os.path.join(msvclibs_dir, 'include'))
261 cxxflags.extend(['-include', 'WebCorePrefix.h'])
263 webcore = bld.new_task_gen(
264 features = 'cc cxx cshlib',
265 includes = ' '.join(wk_includes),
266 source = ' '.join(flattenSources(webcore_sources.values())),
268 defines = ['WXMAKINGDLL_WEBKIT', 'BUILDING_WebCore'],
269 libpath = [output_dir],
271 uselib = 'WX ICU XML XSLT CURL SQLITE3 WKINTERFACE ' + get_config(),
272 uselib_local = 'wtf jscore',
273 install_path = output_dir,
278 if Options.options.port == 'wx':
279 excludes = get_excludes(webcore_dir, exclude_patterns)
280 excludes.extend(['UserStyleSheetLoader.cpp', 'RenderMediaControls.cpp'])
282 # intermediate sources
283 excludes.append('DocTypeStrings.cpp')
284 excludes.append('HTMLEntityNames.cpp')
286 # Qt specific file in common sources
287 excludes.append('ContextShadow.cpp')
289 # FIXME: these three require headers that I can't seem to find in trunk.
290 # Investigate how to resolve these issues.
291 excludes.append('JSAbstractView.cpp')
292 excludes.append('JSPositionCallback.cpp')
293 excludes.append('JSInspectorController.cpp')
295 # The bindings generator seems to think these are ref-counted, while they aren't in trunk.
296 excludes.append('JSElementTimeControl.cpp')
297 excludes.append('JSSVGAnimatedPathData.cpp')
298 excludes.append('JSSVGAnimatedPoints.cpp')
299 excludes.append('JSSVGExternalResourcesRequired.cpp')
300 excludes.append('JSSVGFilterPrimitiveStandardAttributes.cpp')
301 excludes.append('JSSVGLocatable.cpp')
302 excludes.append('JSSVGStyleTable.cpp')
303 excludes.append('JSSVGTests.cpp')
304 excludes.append('JSSVGStylable.cpp')
305 excludes.append('JSSVGZoomAndPan.cpp')
307 # These are files that expect methods not in the base C++ class, usually XYZAnimated methods.
308 excludes.append('JSSVGFitToViewBox.cpp')
309 excludes.append('JSSVGLangSpace.cpp')
310 excludes.append('JSSVGTransformable.cpp')
311 excludes.append('JSSVGURIReference.cpp')
313 # These are C++ DOM Bindings that won't compile because they look for things not in trunk.
314 excludes.append('WebDOMEventTarget.cpp')
315 excludes.append('WebDOMAbstractView.cpp')
316 excludes.append('WebDOMBlobBuilder.cpp')
317 excludes.append('WebDOMEventListenerCustom.cpp')
318 excludes.append('WebDOMElementTimeControl.cpp')
319 excludes.append('WebDOMImageData.cpp')
320 excludes.append('WebDOMInspectorBackend.cpp')
321 excludes.append('WebDOMScriptProfile.cpp')
322 excludes.append('WebDOMScriptProfileNode.cpp')
323 excludes.append('WebNativeEventListener.cpp')
325 # FIXME: It appears these are no longer needed by any port, once this is confirmed,
326 # we should remove these sources from the tree.
327 excludes.append('WebDOMDOMWindowCustom.cpp')
328 excludes.append('WebDOMHTMLOptionsCollectionCustom.cpp')
329 excludes.append('WebDOMNodeCustom.cpp')
330 excludes.append('WebDOMHTMLDocumentCustom.cpp')
331 excludes.append('WebDOMHTMLCollectionCustom.cpp')
332 excludes.append('WebNativeNodeFilterCondition.cpp')
333 excludes.append('WebDOMNodeFilterCustom.cpp')
335 # this file is unused by any port, not sure why it was
337 excludes.append('GeneratedImage.cpp')
339 # features we don't build / use
340 excludes.append('JSNavigatorCustom.cpp')
341 excludes.append('WebGLContextEvent.cpp')
342 excludes.append('FileSystemPOSIX.cpp')
343 excludes.append('SharedBufferPOSIX.cpp')
346 # These files appear not to build with older versions of ICU
347 excludes.append('LocalizedNumberICU.cpp')
348 excludes.append('LocaleToScriptMappingICU.cpp')
350 if building_on_win32:
351 excludes.append('SharedTimerWx.cpp')
352 excludes.append('RenderThemeWin.cpp')
353 excludes.append('KeyEventWin.cpp')
355 if building_on_win32 or sys.platform.startswith('darwin'):
356 excludes.append('GlyphMapWx.cpp')
357 excludes.append('AuthenticationCF.cpp')
358 excludes.append('LoaderRunLoopCF.cpp')
359 excludes.append('ResourceErrorCF.cpp')
361 # once we move over to the new FPD implementation, remove this.
362 excludes.append('FontPlatformData.cpp')
364 # we don't use gestures currently
365 excludes.append('PlatformGestureRecognizer.cpp')
367 # we need a better system to exclude CF stuff
368 excludes.append('HyphenationCF.cpp')
370 if sys.platform.startswith('darwin'):
371 webcore.includes += ' Source/WebKit/mac/WebCoreSupport Source/WebCore/platform/mac'
372 webcore.source += ' Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm'
374 if building_on_win32:
375 for wxlib in bld.env['LIB_WX']:
376 wx_version = wxpresets.get_wx_version(os.environ['WXWIN'])
377 if int(wx_version[1]) % 2 == 1:
378 wxlib = wxlib.replace(''.join(wx_version[:2]), ''.join(wx_version))
379 wxlibname = os.path.join(bld.env['LIBPATH_WX'][0], wxlib + '_vc.dll')
380 print "Copying %s" % wxlibname
381 if os.path.exists(wxlibname):
382 bld.install_files(webcore.install_path, [wxlibname])
384 for dep in windows_deps:
385 bld.install_files(webcore.install_path, [os.path.join(msvclibs_dir, dep)])
387 if "CAIRO_ROOT" in os.environ and Options.options.cairo:
388 cairo_bin_dir = os.path.join(os.environ["CAIRO_ROOT"], "bin")
389 for dep in glob.glob(os.path.join(cairo_bin_dir, "*.dll")):
390 bld.install_files(webcore.install_path, [os.path.join(cairo_bin_dir, dep)])
392 webcore.find_sources_in_dirs(full_dirs, excludes = excludes, exts=['.c', '.cpp'])
396 if Options.options.port == "wx":
397 bld.add_subdirs(['Tools/DumpRenderTree', 'Tools/wx/browser', 'Source/WebKit/wx/bindings/python'])