1 # Copyright (C) 2009 Kevin Ollivier All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions
6 # 1. Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution.
12 # THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
13 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
16 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 # Common elements of the waf build system shared by all projects.
34 from build_utils import *
35 from waf_extensions import *
37 # to be moved to wx when it supports more configs
38 from wxpresets import *
40 wk_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../..'))
42 if sys.platform.startswith('win'):
43 if not 'WXWIN' in os.environ:
44 print "Please set WXWIN to the directory containing wxWidgets."
47 wx_root = os.environ['WXWIN']
49 wx_root = commands.getoutput('wx-config --prefix')
51 jscore_dir = os.path.join(wk_root, 'Source', 'JavaScriptCore')
52 webcore_dir = os.path.join(wk_root, 'Source', 'WebCore')
53 wklibs_dir = os.path.join(wk_root, 'WebKitLibraries')
60 common_frameworks = []
77 'wx': ['CURL', 'WXGC'],
99 'Source/WebCore/accessibility',
100 'Source/WebCore/bindings',
101 'Source/WebCore/bindings/cpp',
102 'Source/WebCore/bindings/generic',
103 'Source/WebCore/bindings/js',
104 'Source/WebCore/bridge',
105 'Source/WebCore/bridge/c',
106 'Source/WebCore/bridge/jsc',
107 'Source/WebCore/css',
108 'Source/WebCore/DerivedSources',
109 'Source/WebCore/dom',
110 'Source/WebCore/dom/default',
111 'Source/WebCore/editing',
112 'Source/WebCore/fileapi',
113 'Source/WebCore/history',
114 'Source/WebCore/html',
115 'Source/WebCore/html/canvas',
116 'Source/WebCore/html/parser',
117 'Source/WebCore/html/shadow',
118 'Source/WebCore/inspector',
119 'Source/WebCore/loader',
120 'Source/WebCore/loader/appcache',
121 'Source/WebCore/loader/archive',
122 'Source/WebCore/loader/cache',
123 'Source/WebCore/loader/icon',
124 'Source/WebCore/notifications',
125 'Source/WebCore/page',
126 'Source/WebCore/page/animation',
127 'Source/WebCore/platform',
128 'Source/WebCore/platform/animation',
129 'Source/WebCore/platform/graphics',
130 'Source/WebCore/platform/graphics/filters',
131 'Source/WebCore/platform/graphics/transforms',
132 'Source/WebCore/platform/image-decoders',
133 'Source/WebCore/platform/image-decoders/bmp',
134 'Source/WebCore/platform/image-decoders/gif',
135 'Source/WebCore/platform/image-decoders/ico',
136 'Source/WebCore/platform/image-decoders/jpeg',
137 'Source/WebCore/platform/image-decoders/png',
138 'Source/WebCore/platform/image-decoders/webp',
139 'Source/WebCore/platform/mock',
140 'Source/WebCore/platform/network',
141 'Source/WebCore/platform/sql',
142 'Source/WebCore/platform/text',
143 'Source/WebCore/platform/text/transcoder',
144 'Source/WebCore/plugins',
145 'Source/WebCore/rendering',
146 'Source/WebCore/rendering/style',
147 'Source/WebCore/rendering/svg',
148 'Source/WebCore/storage',
149 'Source/WebCore/svg',
150 'Source/WebCore/svg/animation',
151 'Source/WebCore/svg/graphics',
152 'Source/WebCore/svg/graphics/filters',
153 'Source/WebCore/svg/properties',
154 'Source/WebCore/websockets',
155 'Source/WebCore/xml',
158 config = get_config(wk_root)
159 config_dir = config + git_branch_name()
161 output_dir = os.path.join(wk_root, 'WebKitBuild', config_dir)
164 building_on_win32 = sys.platform.startswith('win')
167 waf_configname = config.upper().strip()
168 if building_on_win32:
169 isReleaseCRT = (config == 'Release')
170 if build_port == 'wx':
171 if Options.options.wxpython:
175 waf_configname = waf_configname + ' CRT_MULTITHREADED_DLL'
177 waf_configname = waf_configname + ' CRT_MULTITHREADED_DLL_DBG'
179 return waf_configname
181 create_hash_table = wk_root + "/Source/JavaScriptCore/create_hash_table"
182 if building_on_win32:
183 create_hash_table = get_output('cygpath --unix "%s"' % create_hash_table)
184 os.environ['CREATE_HASH_TABLE'] = create_hash_table
186 feature_defines = ['ENABLE_DATABASE', 'ENABLE_XSLT', 'ENABLE_JAVASCRIPT_DEBUGGER',
187 'ENABLE_SVG', 'ENABLE_SVG_USE', 'ENABLE_FILTERS', 'ENABLE_SVG_FONTS',
188 'ENABLE_SVG_ANIMATION', 'ENABLE_SVG_AS_IMAGE', 'ENABLE_SVG_FOREIGN_OBJECT',
189 'ENABLE_JIT', 'BUILDING_%s' % build_port.upper()]
191 msvc_version = 'msvc2008'
193 msvclibs_dir = os.path.join(wklibs_dir, msvc_version, 'win')
195 def get_path_to_wxconfig():
196 if 'WX_CONFIG' in os.environ:
197 return os.environ['WX_CONFIG']
201 def common_set_options(opt):
203 Initialize common options provided to the user.
205 opt.tool_options('compiler_cxx')
206 opt.tool_options('compiler_cc')
207 opt.tool_options('python')
209 opt.add_option('--wxpython', action='store_true', default=False, help='Create the wxPython bindings.')
210 opt.add_option('--wx-compiler-prefix', action='store', default='vc',
211 help='Specify a different compiler prefix (do this if you used COMPILER_PREFIX when building wx itself)')
212 opt.add_option('--macosx-version', action='store', default='', help="Version of OS X to build for.")
213 opt.add_option('--msvc-version', action='store', default='', help="MSVC version to use to build. Use 8 for 2005, 9 for 2008")
215 def common_configure(conf):
217 Configuration used by all targets, called from the target's configure() step.
220 conf.env['MSVC_TARGETS'] = ['x86']
222 if Options.options.msvc_version and Options.options.msvc_version != '':
223 print "msvc version = %s" % Options.options.msvc_version
224 conf.env['MSVC_VERSIONS'] = ['msvc %s.0' % Options.options.msvc_version]
226 print "msvc not set!"
227 conf.env['MSVC_VERSIONS'] = ['msvc 9.0', 'msvc 8.0']
229 if sys.platform.startswith('cygwin'):
230 print "ERROR: You must use the Win32 Python from python.org, not Cygwin Python, when building on Windows."
233 if sys.platform.startswith('darwin') and build_port == 'wx':
235 if platform.release().startswith('10'): # Snow Leopard
236 # wx currently only supports 32-bit compilation, so we want gcc-4.0 instead of 4.2 on Snow Leopard
237 # unless the user has explicitly set a different compiler.
238 if not "CC" in os.environ:
239 conf.env['CC'] = 'gcc-4.0'
240 if not "CXX" in os.environ:
241 conf.env['CXX'] = 'g++-4.0'
242 conf.check_tool('compiler_cxx')
243 conf.check_tool('compiler_cc')
244 if Options.options.wxpython:
245 conf.check_tool('python')
246 conf.check_python_headers()
248 if sys.platform.startswith('darwin'):
249 conf.check_tool('osx')
256 if building_on_win32:
259 found = conf.get_msvc_versions()
261 for version in found:
262 found_versions.append(version[0])
264 if 'msvc 9.0' in conf.env['MSVC_VERSIONS'] and 'msvc 9.0' in found_versions:
265 msvc_version = 'msvc2008'
266 elif 'msvc 8.0' in conf.env['MSVC_VERSIONS'] and 'msvc 8.0' in found_versions:
267 msvc_version = 'msvc2005'
269 msvclibs_dir = os.path.join(wklibs_dir, msvc_version, 'win')
271 # Disable several warnings which occur many times during the build.
272 # Some of them are harmless (4099, 4344, 4396, 4800) and working around
273 # them in WebKit code is probably just not worth it. We can simply do
274 # nothing about the others (4503). A couple are possibly valid but
275 # there are just too many of them in the code so fixing them is
276 # impossible in practice and just results in tons of distracting output
277 # (4244, 4291). Finally 4996 is actively harmful as it is given for
278 # just about any use of standard C/C++ library facilities.
279 conf.env.append_value('CXXFLAGS', [
280 '/wd4099', # type name first seen using 'struct' now seen using 'class'
281 '/wd4244', # conversion from 'xxx' to 'yyy', possible loss of data:
282 '/wd4291', # no matching operator delete found (for placement new)
283 '/wd4344', # behaviour change in template deduction
284 '/wd4396', # inline can't be used in friend declaration
285 '/wd4503', # decorated name length exceeded, name was truncated
286 '/wd4800', # forcing value to bool 'true' or 'false'
287 '/wd4996', # deprecated function
290 # This one also occurs in C code, so disable it there as well.
291 conf.env.append_value('CCFLAGS', ['/wd4996'])
293 if build_port == "wx":
294 update_wx_deps(conf, wk_root, msvc_version)
296 conf.env.append_value('CXXDEFINES', ['BUILDING_WX__=1', 'JS_NO_EXPORT'])
298 if building_on_win32:
299 conf.env.append_value('LIBPATH', os.path.join(msvclibs_dir, 'lib'))
302 is_debug = (config == 'Debug')
303 wxdefines, wxincludes, wxlibs, wxlibpaths = get_wxmsw_settings(wx_root, shared=True, unicode=True, debug=is_debug, wxPython=Options.options.wxpython)
304 conf.env['CXXDEFINES_WX'] = wxdefines
305 conf.env['CPPPATH_WX'] = wxincludes
306 conf.env['LIB_WX'] = wxlibs
307 conf.env['LIBPATH_WX'] = wxlibpaths
309 if sys.platform.startswith('darwin'):
310 conf.env['LIB_ICU'] = ['icucore']
312 conf.env.append_value('CPPPATH', wklibs_dir)
313 conf.env.append_value('LIBPATH', wklibs_dir)
317 mac_target = 'MACOSX_DEPLOYMENT_TARGET'
318 if Options.options.macosx_version != '':
319 min_version = Options.options.macosx_version
321 # WebKit only supports 10.4+, but ppc systems often set this to earlier systems
323 min_version = commands.getoutput('sw_vers -productVersion')[:4]
324 if min_version in ['10.1','10.2','10.3']:
327 os.environ[mac_target] = conf.env[mac_target] = min_version
329 sdk_version = min_version
330 if min_version == "10.4":
332 conf.env.append_value('LIB_WKINTERFACE', ['WebKitSystemInterfaceTiger'])
334 # NOTE: There is a WebKitSystemInterfaceSnowLeopard, but when we use that
335 # on 10.6, we get a strange missing symbol error, and this library seems to
336 # work fine for wx's purposes.
337 conf.env.append_value('LIB_WKINTERFACE', ['WebKitSystemInterfaceLeopard'])
339 sdkroot = '/Developer/SDKs/MacOSX%s.sdk' % sdk_version
340 sdkflags = ['-arch', 'i386', '-isysroot', sdkroot]
342 conf.env.append_value('CPPFLAGS', sdkflags)
343 conf.env.append_value('LINKFLAGS', sdkflags)
345 conf.env.append_value('CPPPATH_SQLITE3', [os.path.join(wklibs_dir, 'WebCoreSQLite3')])
346 conf.env.append_value('LIB_SQLITE3', ['WebCoreSQLite3'])
348 conf.env.append_value('CXXDEFINES', feature_defines)
349 if config == 'Release':
350 conf.env.append_value('CPPDEFINES', 'NDEBUG')
352 if building_on_win32:
353 conf.env.append_value('CPPPATH', [
354 os.path.join(jscore_dir, 'os-win32'),
355 os.path.join(msvclibs_dir, 'include'),
356 os.path.join(msvclibs_dir, 'include', 'pthreads'),
357 os.path.join(msvclibs_dir, 'lib'),
360 conf.env.append_value('LIB', ['libpng', 'libjpeg', 'pthreadVC2'])
362 conf.env.append_value('LIB', [
363 'kernel32', 'user32','gdi32','comdlg32','winspool','winmm',
364 'shell32', 'shlwapi', 'comctl32', 'ole32', 'oleaut32', 'uuid', 'advapi32',
365 'wsock32', 'gdiplus', 'usp10','version'])
367 conf.env['LIB_ICU'] = ['icudt', 'icule', 'iculx', 'icuuc', 'icuin', 'icuio', 'icutu']
370 conf.env['LIB_CURL'] = ['libcurl']
373 conf.env['CPPPATH_SQLITE3'] = [os.path.join(msvclibs_dir, 'include', 'SQLite')]
374 conf.env['LIB_SQLITE3'] = ['sqlite3']
377 conf.env['LIB_XML'] = ['libxml2']
380 conf.env['LIB_XSLT'] = ['libxslt']
382 if build_port == 'wx':
383 port_uses['wx'].append('PTHREADS')
384 conf.env.append_value('LIB', ['jpeg', 'png', 'pthread'])
385 conf.env.append_value('LIBPATH', os.path.join(wklibs_dir, 'unix', 'lib'))
386 conf.env.append_value('CPPPATH', os.path.join(wklibs_dir, 'unix', 'include'))
387 conf.env.append_value('CXXFLAGS', ['-fPIC', '-DPIC'])
389 conf.check_cfg(path=get_path_to_wxconfig(), args='--cxxflags --libs', package='', uselib_store='WX', mandatory=True)
391 conf.check_cfg(msg='Checking for libxslt', path='xslt-config', args='--cflags --libs', package='', uselib_store='XSLT', mandatory=True)
392 conf.check_cfg(path='xml2-config', args='--cflags --libs', package='', uselib_store='XML', mandatory=True)
393 if sys.platform.startswith('darwin') and min_version and min_version == '10.4':
394 conf.check_cfg(path=os.path.join(wklibs_dir, 'unix', 'bin', 'curl-config'), args='--cflags --libs', package='', uselib_store='CURL', mandatory=True)
396 conf.check_cfg(path='curl-config', args='--cflags --libs', package='', uselib_store='CURL', mandatory=True)
398 if not sys.platform.startswith('darwin'):
399 conf.check_cfg(package='cairo', args='--cflags --libs', uselib_store='WX', mandatory=True)
400 conf.check_cfg(package='pango', args='--cflags --libs', uselib_store='WX', mandatory=True)
401 conf.check_cfg(package='gtk+-2.0', args='--cflags --libs', uselib_store='WX', mandatory=True)
402 conf.check_cfg(package='sqlite3', args='--cflags --libs', uselib_store='SQLITE3', mandatory=True)
403 conf.check_cfg(path='icu-config', args='--cflags --ldflags', package='', uselib_store='ICU', mandatory=True)
405 for use in port_uses[build_port]:
406 conf.env.append_value('CXXDEFINES', ['WTF_USE_%s' % use])