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.
31 from build_utils import *
32 from waf_extensions import *
34 # to be moved to wx when it supports more configs
35 from wxpresets import *
37 wk_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../..'))
39 if sys.platform.startswith('win'):
40 if not 'WXWIN' in os.environ:
41 print "Please set WXWIN to the directory containing wxWidgets."
44 wx_root = os.environ['WXWIN']
46 wx_root = commands.getoutput('wx-config --prefix')
48 jscore_dir = os.path.join(wk_root, 'JavaScriptCore')
49 webcore_dir = os.path.join(wk_root, 'WebCore')
50 wklibs_dir = os.path.join(wk_root, 'WebKitLibraries')
57 common_frameworks = []
98 'platform/graphics/transforms',
99 'platform/image-decoders',
100 'platform/image-decoders/bmp',
101 'platform/image-decoders/gif',
102 'platform/image-decoders/ico',
103 'platform/image-decoders/jpeg',
104 'platform/image-decoders/png',
105 'platform/image-decoders/xbm',
106 'platform/image-decoders/zlib',
117 config_file = os.path.join(wk_root, 'WebKitBuild', 'Configuration')
120 if os.path.exists(config_file):
121 config = open(config_file).read()
123 output_dir = os.path.join(wk_root, 'WebKitBuild', config)
125 waf_configname = config.upper()
128 building_on_win32 = sys.platform.startswith('win')
130 if building_on_win32:
131 if config == 'Release':
132 waf_configname = waf_configname + ' CRT_MULTITHREADED_DLL'
134 waf_configname = waf_configname + ' CRT_MULTITHREADED_DLL_DBG'
136 create_hash_table = wk_root + "/JavaScriptCore/create_hash_table"
137 if building_on_win32:
138 create_hash_table = get_output('cygpath --unix "%s"' % create_hash_table)
139 os.environ['CREATE_HASH_TABLE'] = create_hash_table
141 feature_defines = ['ENABLE_DATABASE', 'ENABLE_XSLT', 'ENABLE_JAVASCRIPT_DEBUGGER']
143 def common_set_options(opt):
145 Initialize common options provided to the user.
147 opt.tool_options('compiler_cxx')
148 opt.tool_options('compiler_cc')
149 opt.tool_options('python')
151 opt.add_option('--wxpython', action='store_true', default=False, help='Create the wxPython bindings.')
153 def common_configure(conf):
155 Configuration used by all targets, called from the target's configure() step.
157 conf.check_tool('compiler_cxx')
158 conf.check_tool('compiler_cc')
159 conf.check_tool('python')
160 conf.check_python_headers()
162 if sys.platform.startswith('darwin'):
163 conf.check_tool('osx')
165 msvc_version = 'msvc2008'
166 if building_on_win32:
167 found_versions = conf.get_msvc_versions()
168 if found_versions[0][0] == 'msvc 9.0':
169 msvc_version = 'msvc2008'
170 elif found_versions[0][0] == 'msvc 8.0':
171 msvc_version = 'msvc2005'
174 if build_port == "wx":
175 update_wx_deps(wk_root, msvc_version)
176 msvclibs_dir = os.path.join(wklibs_dir, msvc_version, 'win')
178 conf.env.append_value('CXXDEFINES', ['BUILDING_WX__=1', 'WTF_USE_WXGC=1'])
180 if building_on_win32:
181 conf.env.append_value('LIBPATH', os.path.join(msvclibs_dir, 'lib'))
183 wxdefines, wxincludes, wxlibs, wxlibpaths = get_wxmsw_settings(wx_root, shared=True, unicode=True, wxPython=True)
184 conf.env['CXXDEFINES_WX'] = wxdefines
185 conf.env['CPPPATH_WX'] = wxincludes
186 conf.env['LIB_WX'] = wxlibs
187 conf.env['LIBPATH_WX'] = wxlibpaths
189 if sys.platform.startswith('darwin'):
190 conf.env['LIB_ICU'] = ['icucore']
191 # Apple does not ship the ICU headers with Mac OS X, so WebKit includes a copy of 3.2 headers
192 conf.env['CPPPATH_ICU'] = [os.path.join(jscore_dir, 'icu'), os.path.join(webcore_dir, 'icu')]
194 conf.env.append_value('CPPPATH', wklibs_dir)
195 conf.env.append_value('LIBPATH', wklibs_dir)
197 #conf.env['PREFIX'] = output_dir
200 if building_on_win32:
203 conf.env['LIB_JSCORE'] = [libprefix + 'jscore']
204 conf.env['LIB_WEBCORE'] = [libprefix + 'webcore']
205 conf.env['LIB_WXWEBKIT'] = ['wxwebkit']
206 conf.env['CXXDEFINES_WXWEBKIT'] = ['WXUSINGDLL_WEBKIT']
208 conf.env.append_value('CXXDEFINES', feature_defines)
209 if config == 'Release':
210 conf.env.append_value('CPPDEFINES', 'NDEBUG')
212 if building_on_win32:
213 conf.env.append_value('CPPPATH', [
214 os.path.join(jscore_dir, 'os-win32'),
215 os.path.join(msvclibs_dir, 'include'),
216 os.path.join(msvclibs_dir, 'include', 'pthreads'),
217 os.path.join(msvclibs_dir, 'lib'),
220 conf.env.append_value('LIB', ['libpng', 'libjpeg', 'pthreadVC2'])
222 conf.env.append_value('LIB', [
223 'kernel32', 'user32','gdi32','comdlg32','winspool','winmm',
224 'shell32', 'comctl32', 'ole32', 'oleaut32', 'uuid', 'advapi32',
225 'wsock32', 'gdiplus'])
227 conf.env['LIB_ICU'] = ['icudt', 'icule', 'iculx', 'icuuc', 'icuin', 'icuio', 'icutu']
230 conf.env['LIB_CURL'] = ['libcurl']
233 conf.env['CPPPATH_SQLITE3'] = [os.path.join(msvclibs_dir, 'include', 'SQLite')]
234 conf.env['LIB_SQLITE3'] = ['sqlite3']
237 conf.env['LIB_XML'] = ['libxml2']
240 conf.env['LIB_XSLT'] = ['libxslt']
242 if build_port == 'wx':
243 conf.env.append_value('LIB', ['png', 'pthread'])
244 conf.env.append_value('LIBPATH', os.path.join(wklibs_dir, 'unix', 'lib'))
245 conf.env.append_value('CPPPATH', os.path.join(wklibs_dir, 'unix', 'include'))
246 conf.env.append_value('CXXFLAGS', ['-fPIC', '-DPIC'])
248 conf.check_cfg(path='wx-config', args='--cxxflags --libs', package='', uselib_store='WX')
250 conf.check_cfg(path='xslt-config', args='--cflags --libs', package='', uselib_store='XSLT')
251 conf.check_cfg(path='xml2-config', args='--cflags --libs', package='', uselib_store='XML')
252 conf.check_cfg(path='curl-config', args='--cflags --libs', package='', uselib_store='CURL')
253 if sys.platform.startswith('darwin'):
254 conf.env.append_value('LIB', ['WebCoreSQLite3'])
256 if not sys.platform.startswith('darwin'):
257 conf.check_cfg(package='cairo', args='--cflags --libs', uselib_store='WX')
258 conf.check_cfg(package='pango', args='--cflags --libs', uselib_store='WX')
259 conf.check_cfg(package='gtk+-2.0', args='--cflags --libs', uselib_store='WX')
260 conf.check_cfg(package='sqlite3', args='--cflags --libs', uselib_store='SQLITE3')
261 conf.check_cfg(path='icu-config', args='--cflags --ldflags', package='', uselib_store='ICU')