1# Copyright (C) 2009 Kevin Ollivier All rights reserved. 2# 3# Redistribution and use in source and binary forms, with or without 4# modification, are permitted provided that the following conditions 5# are met: 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. 11# 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. 23# 24# Common elements of the waf build system shared by all projects. 25 26import commands 27import os 28import platform 29import sys 30 31from build_utils import * 32from waf_extensions import * 33 34# to be moved to wx when it supports more configs 35from wxpresets import * 36 37wk_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../..')) 38 39if sys.platform.startswith('win'): 40 if not 'WXWIN' in os.environ: 41 print "Please set WXWIN to the directory containing wxWidgets." 42 sys.exit(1) 43 44 wx_root = os.environ['WXWIN'] 45else: 46 wx_root = commands.getoutput('wx-config --prefix') 47 48jscore_dir = os.path.join(wk_root, 'JavaScriptCore') 49webcore_dir = os.path.join(wk_root, 'WebCore') 50wklibs_dir = os.path.join(wk_root, 'WebKitLibraries') 51 52common_defines = [] 53common_cxxflags = [] 54common_includes = [] 55common_libs = [] 56common_libpaths = [] 57common_frameworks = [] 58 59jscore_dirs = [ 60 'API', 61 'bytecode', 62 'bytecompiler', 63 'debugger', 64 'DerivedSources', 65 'interpreter', 66 'jit', 67 'parser', 68 'pcre', 69 'profiler', 70 'runtime', 71 'wtf', 72 'wtf/unicode', 73 'wtf/unicode/icu', 74] 75 76webcore_dirs = [ 77 'accessibility', 78 'bindings/js', 79 'bridge', 80 'bridge/c', 81 'css', 82 'DerivedSources', 83 'dom', 84 'dom/default', 85 'editing', 86 'history', 87 'html', 88 'inspector', 89 'loader', 90 'loader/appcache', 91 'loader/archive', 92 'loader/icon', 93 'page', 94 'page/animation', 95 'platform', 96 'platform/animation', 97 'platform/graphics', 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', 107 'platform/network', 108 'platform/sql', 109 'platform/text', 110 'plugins', 111 'rendering', 112 'rendering/style', 113 'storage', 114 'xml' 115] 116 117config_file = os.path.join(wk_root, 'WebKitBuild', 'Configuration') 118config = 'Debug' 119 120if os.path.exists(config_file): 121 config = open(config_file).read() 122 123output_dir = os.path.join(wk_root, 'WebKitBuild', config) 124 125waf_configname = config.upper() 126 127build_port = "wx" 128building_on_win32 = sys.platform.startswith('win') 129 130if building_on_win32: 131 if config == 'Release': 132 waf_configname = waf_configname + ' CRT_MULTITHREADED_DLL' 133 else: 134 waf_configname = waf_configname + ' CRT_MULTITHREADED_DLL_DBG' 135 136create_hash_table = wk_root + "/JavaScriptCore/create_hash_table" 137if building_on_win32: 138 create_hash_table = get_output('cygpath --unix "%s"' % create_hash_table) 139os.environ['CREATE_HASH_TABLE'] = create_hash_table 140 141feature_defines = ['ENABLE_DATABASE', 'ENABLE_XSLT', 'ENABLE_JAVASCRIPT_DEBUGGER'] 142 143def common_set_options(opt): 144 """ 145 Initialize common options provided to the user. 146 """ 147 opt.tool_options('compiler_cxx') 148 opt.tool_options('compiler_cc') 149 opt.tool_options('python') 150 151 opt.add_option('--wxpython', action='store_true', default=False, help='Create the wxPython bindings.') 152 153def common_configure(conf): 154 """ 155 Configuration used by all targets, called from the target's configure() step. 156 """ 157 conf.check_tool('compiler_cxx') 158 conf.check_tool('compiler_cc') 159 conf.check_tool('python') 160 conf.check_python_headers() 161 162 if sys.platform.startswith('darwin'): 163 conf.check_tool('osx') 164 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' 172 173 msvclibs_dir = '' 174 if build_port == "wx": 175 update_wx_deps(wk_root, msvc_version) 176 msvclibs_dir = os.path.join(wklibs_dir, msvc_version, 'win') 177 178 conf.env.append_value('CXXDEFINES', ['BUILDING_WX__=1', 'WTF_USE_WXGC=1']) 179 180 if building_on_win32: 181 conf.env.append_value('LIBPATH', os.path.join(msvclibs_dir, 'lib')) 182 # wx settings 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 188 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')] 193 194 conf.env.append_value('CPPPATH', wklibs_dir) 195 conf.env.append_value('LIBPATH', wklibs_dir) 196 197 #conf.env['PREFIX'] = output_dir 198 199 libprefix = '' 200 if building_on_win32: 201 libprefix = 'lib' 202 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'] 207 208 conf.env.append_value('CXXDEFINES', feature_defines) 209 if config == 'Release': 210 conf.env.append_value('CPPDEFINES', 'NDEBUG') 211 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'), 218 ]) 219 220 conf.env.append_value('LIB', ['libpng', 'libjpeg', 'pthreadVC2']) 221 # common win libs 222 conf.env.append_value('LIB', [ 223 'kernel32', 'user32','gdi32','comdlg32','winspool','winmm', 224 'shell32', 'comctl32', 'ole32', 'oleaut32', 'uuid', 'advapi32', 225 'wsock32', 'gdiplus']) 226 227 conf.env['LIB_ICU'] = ['icudt', 'icule', 'iculx', 'icuuc', 'icuin', 'icuio', 'icutu'] 228 229 #curl 230 conf.env['LIB_CURL'] = ['libcurl'] 231 232 #sqlite3 233 conf.env['CPPPATH_SQLITE3'] = [os.path.join(msvclibs_dir, 'include', 'SQLite')] 234 conf.env['LIB_SQLITE3'] = ['sqlite3'] 235 236 #libxml2 237 conf.env['LIB_XML'] = ['libxml2'] 238 239 #libxslt 240 conf.env['LIB_XSLT'] = ['libxslt'] 241 else: 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']) 247 248 conf.check_cfg(path='wx-config', args='--cxxflags --libs', package='', uselib_store='WX') 249 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']) 255 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') 262 263 264 265 266