| OLD | NEW |
| (Empty) |
| 1 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import os | |
| 6 import shutil | |
| 7 import sys | |
| 8 | |
| 9 | |
| 10 if sys.platform == 'win32': | |
| 11 console = 'con' | |
| 12 else: | |
| 13 console = '/dev/tty' | |
| 14 p = ARGUMENTS.get('PROGRESS') | |
| 15 if p == 'spinner': | |
| 16 Progress(['/\r', '|\r', '\\\r', '-\r'], interval=5, file=open(console, 'w')) | |
| 17 elif p == 'name': | |
| 18 Progress('$TARGET\r', overwrite=True, file=open(console, 'w')) | |
| 19 | |
| 20 | |
| 21 default_warnings = ['no-missing-sconscript', 'no-no-parallel-support'] | |
| 22 default_warnings = ['no-no-parallel-support'] | |
| 23 SetOption('warn', default_warnings + GetOption('warn')) | |
| 24 | |
| 25 | |
| 26 # Variables for controlling the build. | |
| 27 # | |
| 28 # The following variables can be set either on the command line | |
| 29 # or in the external environment when executing SCons, with the | |
| 30 # command line overriding any environment setting. | |
| 31 # | |
| 32 # BUILD_TARGET_DIR | |
| 33 # Specifies the target subdirectory name in which we'll | |
| 34 # build everything. This is intended to mimic the Visual | |
| 35 # Visual Studio "Debug\" and "Release\" subdirectories. | |
| 36 # The default value is "Hammer." | |
| 37 # | |
| 38 # | |
| 39 # CHROME_BUILD_TYPE | |
| 40 # When set, applies settings from the file | |
| 41 # build\internal\release_impl${CHROME_BUILD_TYPE}.scons | |
| 42 # to be applied to the construction environment. | |
| 43 # | |
| 44 # CHROMIUM_BUILD | |
| 45 # When set, applies settings from the file | |
| 46 # build\internal\chromium_build${CHROMIUM_BUILD}.scons | |
| 47 # to be applied to the construction environment. | |
| 48 # | |
| 49 # INCREMENTAL | |
| 50 # Controls whether or not libraries and executable programs are | |
| 51 # linked incrementally. When set to any True value (1, T, y, True), | |
| 52 # uses the /INCREMENTAL flag to the Microsoft linker. An | |
| 53 # explicit False value (0, f, N, false) uses the /INCREMENTAL:NO. | |
| 54 # When not set, the default is to link debug (developer) builds | |
| 55 # incrementally, but release builds use full links. | |
| 56 # | |
| 57 clvars = Variables('scons.opts', ARGUMENTS) | |
| 58 clvars.AddVariables( | |
| 59 ('BUILD_TARGET_DIR', '', 'Hammer'), | |
| 60 ('CHROME_BUILD_TYPE', '', os.environ.get('CHROME_BUILD_TYPE', '')), | |
| 61 ('CHROMIUM_BUILD', '', os.environ.get('CHROMIUM_BUILD', '')), | |
| 62 BoolVariable('INCREMENTAL', '', os.environ.get('INCREMENTAL')), | |
| 63 ) | |
| 64 | |
| 65 | |
| 66 if ARGUMENTS.get('_GYP'): | |
| 67 tool_list = ['chromium_builders'] | |
| 68 else: | |
| 69 tool_list = ['component_setup', | |
| 70 'chromium_builders', | |
| 71 'chromium_load_component', | |
| 72 'MSVSNew'] | |
| 73 | |
| 74 | |
| 75 root_env = Environment( | |
| 76 # MSVSNew in the base environment? Yes, the point is we can (and | |
| 77 # want to) generate Visual Studio project and solution files from | |
| 78 # any platform. | |
| 79 tools = tool_list, | |
| 80 variables = clvars, | |
| 81 | |
| 82 # Requested list of system (shared) libraries, from the comma separated | |
| 83 # SYSTEM_LIBS command-line argument | |
| 84 req_system_libs = [], | |
| 85 # All supported system libraries, for the help message | |
| 86 all_system_libs = [], | |
| 87 | |
| 88 CHROME_SRC_DIR = '$MAIN_DIR/..', | |
| 89 SRC_DIR = '$MAIN_DIR/..', | |
| 90 DESTINATION_ROOT = '$MAIN_DIR/$BUILD_TARGET_DIR', | |
| 91 | |
| 92 # Where ComponentTestProgram() will build test executables. | |
| 93 TESTS_DIR = '$DESTINATION_ROOT', | |
| 94 | |
| 95 # Where ComponentProgram() will build program executables. | |
| 96 STAGING_DIR = '$DESTINATION_ROOT', | |
| 97 | |
| 98 # TODO(hammer): when Hammer supports this... | |
| 99 # Have Hammer prefix all Library aliases with lib_ (to avoid | |
| 100 # collisions with the component names themselves). | |
| 101 #COMPONENT_LIBRARY_ALIAS = 'lib_$LIBNAME', | |
| 102 | |
| 103 # Disable running of tests thru scons for now. | |
| 104 COMPONENT_TEST_RUNNABLE = False, | |
| 105 | |
| 106 BASE_DIR = '$OBJ_ROOT/base', | |
| 107 BREAKPAD_DIR = '$OBJ_ROOT/breakpad', | |
| 108 CHROME_DIR = '$OBJ_ROOT/chrome', | |
| 109 GEARS_DIR = '$OBJ_ROOT/gears', | |
| 110 GOOGLE_UPDATE_DIR = '$OBJ_ROOT/google_update', | |
| 111 GOOGLEURL_DIR = '$OBJ_ROOT/googleurl', | |
| 112 MEDIA_DIR = '$OBJ_ROOT/media', | |
| 113 NET_DIR = '$OBJ_ROOT/net', | |
| 114 PRINTING_DIR = '$OBJ_ROOT/printing', | |
| 115 RLZ_DIR = '$OBJ_ROOT/rlz', | |
| 116 SANDBOX_DIR = '$OBJ_ROOT/sandbox', | |
| 117 SDCH_DIR = '$OBJ_ROOT/sdch', | |
| 118 SKIA_DIR = '$OBJ_ROOT/skia', | |
| 119 TESTING_DIR = '$OBJ_ROOT/testing', | |
| 120 THIRD_PARTY_DIR = '$OBJ_ROOT/third_party', | |
| 121 TOOLS_DIR = '$OBJ_ROOT/tools', | |
| 122 V8_DIR = '$OBJ_ROOT/v8', | |
| 123 WEBKIT_DIR = '$OBJ_ROOT/webkit', | |
| 124 | |
| 125 GTEST_DIR = '$TESTING_DIR/gtest', | |
| 126 | |
| 127 BSDIFF_DIR = '$THIRD_PARTY_DIR/bsdiff', | |
| 128 BSPATCH_DIR = '$THIRD_PARTY_DIR/bspatch', | |
| 129 BZIP2_DIR = '$THIRD_PARTY_DIR/bzip2', | |
| 130 ICU38_DIR = '$THIRD_PARTY_DIR/icu38', | |
| 131 LIBEVENT_DIR = '$THIRD_PARTY_DIR/libevent', | |
| 132 LIBJPEG_DIR = '$THIRD_PARTY_DIR/libjpeg', | |
| 133 LIBPNG_DIR = '$THIRD_PARTY_DIR/libpng', | |
| 134 LIBXML_DIR = '$THIRD_PARTY_DIR/libxml', | |
| 135 LIBXSLT_DIR = '$THIRD_PARTY_DIR/libxslt', | |
| 136 LZMA_SDK_DIR = '$THIRD_PARTY_DIR/lzma_sdk', | |
| 137 MODP_B64_DIR = '$THIRD_PARTY_DIR/modp_b64', | |
| 138 NPAPI_DIR = '$THIRD_PARTY_DIR/npapi', | |
| 139 SQLITE_DIR = '$THIRD_PARTY_DIR/sqlite', | |
| 140 ZLIB_DIR = '$THIRD_PARTY_DIR/zlib', | |
| 141 | |
| 142 THIRD_PARTY_WEBKIT_DIR = '$THIRD_PARTY_DIR/WebKit', | |
| 143 | |
| 144 GTK_CLIP_DUMP_DIR = '$TOOLS_DIR/gtk_clipboard_dump', | |
| 145 GRIT_DIR = '$TOOLS_DIR/grit', | |
| 146 | |
| 147 PYTHON=sys.executable, | |
| 148 | |
| 149 PERL = 'perl', | |
| 150 PERL_INCLUDE_FLAG = '-I ', | |
| 151 PERL_INCLUDE_SUFFIX = '', | |
| 152 _PERL_INCLUDE_FLAGS = ('${_concat(PERL_INCLUDE_FLAG, ' | |
| 153 'PERL_INCLUDE_PATH, ' | |
| 154 'PERL_INCLUDE_SUFFIX,' | |
| 155 '__env__, RDirs, TARGET, SOURCE)}'), | |
| 156 ) | |
| 157 | |
| 158 root_env['req_system_libs'] = ARGUMENTS.get('SYSTEM_LIBS', '').split(',') | |
| 159 root_env['_GYP'] = ARGUMENTS.get('GYP') and '_gyp' or '' | |
| 160 | |
| 161 def WantSystemLib(env, lib): | |
| 162 """ | |
| 163 Return true if lib has been requested as a system library in SYSTEM_LIBS. | |
| 164 """ | |
| 165 if lib not in env['all_system_libs']: | |
| 166 env['all_system_libs'].append(lib) | |
| 167 return (lib in env['req_system_libs']) | |
| 168 root_env.AddMethod(WantSystemLib, "WantSystemLib") | |
| 169 | |
| 170 | |
| 171 # TODO(bradnelson): pull this functionality into hammer. | |
| 172 # Auto select the number of processors | |
| 173 if root_env['PLATFORM'] in ['win32', 'cygwin']: | |
| 174 cpus = int(os.environ.get('NUMBER_OF_PROCESSORS', 1)) | |
| 175 elif root_env['PLATFORM'] in ['linux', 'linux2', 'posix']: | |
| 176 # TODO(evanm): this is Linux-specific, not posix. | |
| 177 # Parse /proc/cpuinfo for processor count. | |
| 178 cpus = len([l for l in open('/proc/cpuinfo') if l.startswith('processor\t')]) | |
| 179 else: | |
| 180 cpus = 1 | |
| 181 SetOption('num_jobs', cpus + 1) | |
| 182 | |
| 183 | |
| 184 # Use timestamps change, followed by MD5 for speed | |
| 185 root_env.Decider('MD5-timestamp') | |
| 186 | |
| 187 # Incorporate settings that should apply globally (primarily to provide | |
| 188 # an obvious place for developmental experimentation). | |
| 189 root_env.ApplySConscript(['$CHROME_SRC_DIR/build/common.scons']) | |
| 190 | |
| 191 # The list of all leaf (fully described) environments. | |
| 192 environment_list = [] | |
| 193 components = [] | |
| 194 | |
| 195 # Figure out what SConscript files to load based on the user's request. | |
| 196 # Default is to load all SConscript files for a full-tree build. | |
| 197 # The keyword arguments in the call below (base, breakpad, etc.) can be | |
| 198 # specified in the LOAD= argument to cut down on the build. | |
| 199 | |
| 200 Default(None) # Reset default target to empty. | |
| 201 if root_env.get('_GYP'): | |
| 202 webkit_sconscript = '$WEBKIT_DIR/tools/test_shell/test_shell_main${_GYP}.sco
ns' | |
| 203 else: | |
| 204 webkit_sconscript = '$WEBKIT_DIR/webkit_main${_GYP}.scons' | |
| 205 | |
| 206 sconscript_map = dict( | |
| 207 base = '$BASE_DIR/base_main${_GYP}.scons', | |
| 208 breakpad = '$BREAKPAD_DIR/SConscript', | |
| 209 chrome = '$CHROME_DIR/chrome_main${_GYP}.scons', | |
| 210 gears = '$GEARS_DIR/SConscript', | |
| 211 google_update = '$GOOGLE_UPDATE_DIR/SConscript', | |
| 212 googleurl = '$GOOGLEURL_DIR/googleurl.scons', | |
| 213 media = '$MEDIA_DIR/media.scons', | |
| 214 net = '$NET_DIR/net_main${_GYP}.scons', | |
| 215 printing = '$PRINTING_DIR/printing.scons', | |
| 216 rlz = '$RLZ_DIR/SConscript', | |
| 217 sandbox = '$SANDBOX_DIR/sandbox.scons', | |
| 218 sdch = '$SDCH_DIR/SConscript', | |
| 219 skia = '$SKIA_DIR/SConscript', | |
| 220 testing = '$TESTING_DIR/SConscript.gtest', | |
| 221 third_party = [ | |
| 222 '$BSDIFF_DIR/bsdiff.scons', | |
| 223 '$BSPATCH_DIR/bspatch.scons', | |
| 224 '$BZIP2_DIR/bzip2.scons', | |
| 225 '$ICU38_DIR/icu38_main${_GYP}.scons', | |
| 226 '$LIBJPEG_DIR/libjpeg${_GYP}.scons', | |
| 227 '$LIBPNG_DIR/libpng${_GYP}.scons', | |
| 228 '$LIBXML_DIR/libxml.scons', | |
| 229 '$LIBXSLT_DIR/libxslt.scons', | |
| 230 '$LZMA_SDK_DIR/lzma_sdk.scons', | |
| 231 '$MODP_B64_DIR/modp_b64.scons', | |
| 232 '$ZLIB_DIR/zlib${_GYP}.scons', | |
| 233 ], | |
| 234 tools = '$GTK_CLIP_DUMP_DIR/gcd.scons', | |
| 235 v8 = '$OBJ_ROOT/build/SConscript.v8', | |
| 236 webkit = webkit_sconscript, | |
| 237 ) | |
| 238 | |
| 239 if root_env.get('_GYP'): | |
| 240 Import('build_component') | |
| 241 sconscripts = [sconscript_map[build_component]] | |
| 242 components = [build_component] | |
| 243 else: | |
| 244 sconscripts = root_env.ChromiumLoadComponentSConscripts(**sconscript_map) | |
| 245 | |
| 246 # Add the final list into the root environment to be build in BuildComponents. | |
| 247 root_env.Append(BUILD_SCONSCRIPTS = sconscripts) | |
| 248 | |
| 249 if not root_env.WantSystemLib('sqlite') and not root_env.get('_GYP'): | |
| 250 root_env.Append(BUILD_SCONSCRIPTS = ['$SQLITE_DIR/SConscript']) | |
| 251 | |
| 252 | |
| 253 # -------------------------------------------------------------------------- | |
| 254 # Windows specific | |
| 255 | |
| 256 windows_env = root_env.Clone() | |
| 257 | |
| 258 # TODO(siggi) Remove this code once SCons plays well when the | |
| 259 # Platform SDK 6.1 is installed with VS2005 but not VS2008. | |
| 260 if root_env['PLATFORM'] in ['win32', 'cygwin']: | |
| 261 windows_env['MSVS_VERSION'] = '8.0' | |
| 262 | |
| 263 windows_env.Tool('target_platform_windows') | |
| 264 windows_env.Tool('component_targets_msvs') # Per target project support. | |
| 265 | |
| 266 # Hammer's target_platform_windows module added the stock SCons | |
| 267 # MSVSProject() and MSVSSolution() Builders, which we're going to | |
| 268 # replace with our newer, more flexible implementation. Wipe out the | |
| 269 # older ones so they don't interfere with our initialization and so | |
| 270 # SCons doesn't propagate them to cloned construction environments. | |
| 271 del windows_env['BUILDERS']['MSVSProject'] | |
| 272 del windows_env['BUILDERS']['MSVSSolution'] | |
| 273 windows_env.Tool('MSVSNew') | |
| 274 | |
| 275 windows_env.Tool('midl') | |
| 276 | |
| 277 # TODO(bradnelson): target_platform_windows defines a whole bunch of | |
| 278 # flags that we don't care about, including defining OS_WINDOWS in a | |
| 279 # way that we don't want, and (most especially) adding *_DEBUG and | |
| 280 # *_OPTIMIZED constructionv variables that add magic values to | |
| 281 # CCFLAGS. We override the normal variables (CPPDEFINES, CCFLAGS, | |
| 282 # LINKFLAGS, ARFLAGS) below, but get rid of the special Hammer ones | |
| 283 # here, until Hammer can be made a little nicer about htis. | |
| 284 | |
| 285 del windows_env['CCFLAGS_DEBUG'] | |
| 286 del windows_env['LINKFLAGS_DEBUG'] | |
| 287 del windows_env['CCFLAGS_OPTIMIZED'] | |
| 288 | |
| 289 windows_env['PDB'] = '${TARGET.base}.pdb' | |
| 290 windows_env['MSVC_BATCH'] = True | |
| 291 | |
| 292 # TODO(bradnelson): this should not need to be gated on host platform. | |
| 293 if root_env['PLATFORM'] in ['win32', 'cygwin']: | |
| 294 msvs_env = Environment(tools=['msvc', 'mslink'])['ENV'] | |
| 295 msvs_drive = msvs_env['PATH'][0] | |
| 296 else: | |
| 297 msvs_env = {'PATH': '', 'INCLUDE': '', 'LIB': ''} | |
| 298 msvs_drive = 'C' | |
| 299 | |
| 300 # Use the absolute path for MSVC because it might not be on the same drive | |
| 301 # as our source checkout. | |
| 302 visual_studio_path = msvs_drive + ':/Program Files/Microsoft Visual Studio 8' | |
| 303 | |
| 304 # If side-by-side platform sdk is not available try local copy. | |
| 305 platform_sdk_path = '$CHROME_SRC_DIR/third_party/platformsdk_win2008_6_1/files' | |
| 306 if (root_env['PLATFORM'] in ['win32', 'cygwin'] and | |
| 307 not os.path.exists(windows_env.subst(platform_sdk_path))): | |
| 308 platform_sdk_path = ( | |
| 309 msvs_drive + ':\\Program Files\\Microsoft SDKs\\Windows\\v6.1') | |
| 310 | |
| 311 windows_env.Replace( | |
| 312 CSCRIPT = 'c:\\Windows\\System32\\cscript', | |
| 313 | |
| 314 PLATFORMSDK_6_1 = platform_sdk_path, | |
| 315 VISUAL_STUDIO = visual_studio_path, | |
| 316 | |
| 317 CYGWIN_DIR = windows_env.Dir('$CHROME_SRC_DIR/third_party/cygwin'), | |
| 318 CYGWIN_BIN_DIR = '$CYGWIN_DIR/bin', | |
| 319 | |
| 320 PERL = '$CYGWIN_BIN_DIR/perl.exe', | |
| 321 | |
| 322 MSVS_ENV = msvs_env, | |
| 323 | |
| 324 YACC = '$CYGWIN_BIN_DIR/bison.exe', | |
| 325 | |
| 326 ARFLAGS = [ | |
| 327 '/nologo', | |
| 328 ], | |
| 329 | |
| 330 CCFLAGS = [ | |
| 331 '/nologo', | |
| 332 '/errorReport:prompt', | |
| 333 ], | |
| 334 | |
| 335 CPPDEFINES = [ | |
| 336 '_UNICODE', | |
| 337 'UNICODE', | |
| 338 ], | |
| 339 | |
| 340 | |
| 341 LIBS = [ | |
| 342 'advapi32.lib', | |
| 343 'comdlg32.lib', | |
| 344 'gdi32.lib', | |
| 345 'kernel32.lib', | |
| 346 'odbc32.lib', | |
| 347 'odbccp32.lib', | |
| 348 'ole32.lib', | |
| 349 'oleaut32.lib', | |
| 350 'shell32.lib', | |
| 351 'user32.lib', | |
| 352 'uuid.lib', | |
| 353 'winspool.lib', | |
| 354 | |
| 355 'DelayImp.lib', | |
| 356 ], | |
| 357 | |
| 358 LINKFLAGS = [ | |
| 359 '/nologo', | |
| 360 ], | |
| 361 | |
| 362 ICU_LIBS = ['icu'], | |
| 363 ) | |
| 364 | |
| 365 # Force scons to handle long include lines correctly. | |
| 366 pchcom_fixed = windows_env['PCHCOM'] | |
| 367 pchcom_fixed = pchcom_fixed.replace('${TARGETS[0]}', '$TARGET') | |
| 368 pchcom_fixed = pchcom_fixed.replace('${TARGETS[1]}', '$TARGETS1') | |
| 369 | |
| 370 # Below, we'll redefine $CXXFLAGS so its expansion doesn't include | |
| 371 # $CCFLAGS. Modify $PCHCOM, which was relying on this fact, so | |
| 372 # that $CCFLAGS still shows up in precompiled header compilations. | |
| 373 pchcom_fixed = pchcom_fixed.replace('$CXXFLAGS', '$CXXFLAGS $CCFLAGS') | |
| 374 | |
| 375 windows_env.Replace( | |
| 376 CCCOM = "${TEMPFILE('%s')}" % windows_env['CCCOM'], | |
| 377 CXXCOM = "${TEMPFILE('%s')}" % windows_env['CXXCOM'], | |
| 378 SHCCCOM = "${TEMPFILE('%s')}" % windows_env['SHCCCOM'], | |
| 379 SHCXXCOM = "${TEMPFILE('%s')}" % windows_env['SHCXXCOM'], | |
| 380 PCHCOM = "${TEMPFILE('%s')}" % pchcom_fixed, | |
| 381 TARGETS1 = '${TARGETS[1]}', | |
| 382 | |
| 383 # The SCons default for $CXXFLAGS contains $CCFLAGS, which is | |
| 384 # also on the $CCCOM command line string separately. Redefine | |
| 385 # $CXXFLAGS to avoid the duplication | |
| 386 CXXFLAGS = '$( /TP $)', | |
| 387 ) | |
| 388 | |
| 389 windows_env['ENV']['PROGRAMFILES'] = os.environ.get('PROGRAMFILES', '') | |
| 390 windows_env['ENV']['SystemDrive'] = os.environ.get('SystemDrive', '') | |
| 391 windows_env['ENV']['USERPROFILE'] = os.environ.get('USERPROFILE', '') | |
| 392 | |
| 393 windows_env.AppendENVPath('PATH', ';C:\\WINDOWS\\system32') | |
| 394 | |
| 395 windows_dbg = windows_env.Clone() | |
| 396 environment_list.append(windows_dbg) | |
| 397 windows_dbg.Replace( | |
| 398 BUILD_TYPE = 'dbg', | |
| 399 BUILD_TYPE_DESCRIPTION = 'Windows debug build', | |
| 400 ) | |
| 401 windows_dbg.Tool('target_debug') | |
| 402 windows_dbg.ApplySConscript(['$CHROME_SRC_DIR/build/debug.scons']) | |
| 403 windows_dbg.Append(BUILD_GROUPS = ['default']) | |
| 404 | |
| 405 windows_opt = windows_env.Clone() | |
| 406 environment_list.append(windows_opt) | |
| 407 windows_opt.Replace( | |
| 408 BUILD_TYPE = 'opt', | |
| 409 BUILD_TYPE_DESCRIPTION = 'Windows optimized build', | |
| 410 ) | |
| 411 windows_opt.Tool('target_optimized') | |
| 412 windows_opt.ApplySConscript(['$CHROME_SRC_DIR/build/release.scons']) | |
| 413 | |
| 414 # -------------------------------------------------------------------------- | |
| 415 # Platform-independent "msvs" mode for generating Visual Studio | |
| 416 # project and solution files from any platform. | |
| 417 | |
| 418 DeclareBit('msvs', 'Generate Visual Studio files') | |
| 419 | |
| 420 msvs_env = windows_env.Clone() | |
| 421 | |
| 422 msvs_env.Tool('target_platform_windows') | |
| 423 msvs_env.Tool('component_targets_msvs') # Per target project support. | |
| 424 | |
| 425 del msvs_env['BUILDERS']['MSVSProject'] | |
| 426 del msvs_env['BUILDERS']['MSVSSolution'] | |
| 427 msvs_env.Tool('MSVSNew') | |
| 428 | |
| 429 msvs_env.Tool('midl') | |
| 430 | |
| 431 environment_list.append(msvs_env) | |
| 432 msvs_env.Replace( | |
| 433 BUILD_TYPE = 'msvs', | |
| 434 BUILD_TYPE_DESCRIPTION = 'Generate Visual Studio files', | |
| 435 HOST_PLATFORMS = ['*'], | |
| 436 ICU_LIBS = [], | |
| 437 ) | |
| 438 msvs_env.SetBits('windows', 'msvs') | |
| 439 # TODO(sgk): turn into separate debug + release env adding | |
| 440 # to a common .sln file | |
| 441 msvs_env.Tool('target_debug') | |
| 442 | |
| 443 # -------------------------------------------------------------------------- | |
| 444 # Linux specific | |
| 445 | |
| 446 linux_env = root_env.Clone() | |
| 447 linux_env.Tool('target_platform_linux') | |
| 448 linux_env.Tool('yacc') | |
| 449 | |
| 450 # By default scons will depend on the first path element for any command line. | |
| 451 # For example, it will resolve 'gcc' with $PATH and depend on that for any | |
| 452 # action which runs gcc. This disables this behaviour: | |
| 453 linux_env['IMPLICIT_COMMAND_DEPENDENCIES'] = False | |
| 454 | |
| 455 # TODO(bradnelson): this is needed for now because target_platform_linux has | |
| 456 # OS_LINUX defined in a weird way. | |
| 457 linux_env.FilterOut(CPPDEFINES = ['OS_LINUX=OS_LINUX']) | |
| 458 | |
| 459 # Copy some environment variables from the outer environment to the | |
| 460 # SCons.Environment if they exist. | |
| 461 for envvar in ('CC', 'CXX', 'LINK'): | |
| 462 if envvar in os.environ: | |
| 463 linux_env[envvar] = os.environ[envvar] | |
| 464 linux_env['ENV'][envvar] = os.environ[envvar] | |
| 465 # Copy these environment variables from the outer environment to the | |
| 466 # environment that the build commands run in. | |
| 467 # $HOME is needed by distcc so it can find its lock file. | |
| 468 for envvar in ('HOME', 'DISTCC_DIR', 'DISTCC_HOSTS', 'CCACHE_DIR', | |
| 469 'INTERCEPTOR_SOCKET', 'ENFORGE_DIGEST_CACHE', | |
| 470 'CHROME_BUILD_TYPE', 'CHROMIUM_BUILD', | |
| 471 'ENFORGE_CACHE_HOST', 'ENFORGE_CACHE_PORT'): | |
| 472 if envvar in os.environ: | |
| 473 linux_env['ENV'][envvar] = os.environ[envvar] | |
| 474 | |
| 475 excluded_warnings = [ | |
| 476 # TODO: Clean up uses of ext/hash_map and remove this. | |
| 477 # (see unordered_map and base/hash_tables.h) | |
| 478 '-Wno-deprecated', # Needed for using ext/hash_map on GCC 4.3 | |
| 479 ] | |
| 480 if not root_env.get('_GYP'): | |
| 481 linux_env.Append( | |
| 482 BUILD_SCONSCRIPTS = [ | |
| 483 '$LIBEVENT_DIR/libevent${_GYP}.scons', | |
| 484 ], | |
| 485 ) | |
| 486 linux_env.Append( | |
| 487 ASFLAGS = ['-32'], | |
| 488 CCFLAGS = ['-m32', '-pthread', '-march=pentium4', '-fno-exceptions', | |
| 489 # All floating-point computations on x87 happens in 80-bit precision. | |
| 490 # Because the C and C++ language standards allow the compiler to keep the | |
| 491 # floating-point values in higher precision than what's specified in the | |
| 492 # source and doing so is more efficient than constantly rounding up to | |
| 493 # 64-bit or 32-bit precision as specified in the source, the compiler, | |
| 494 # especially in the optimized mode, tries very hard to keep values in x87 | |
| 495 # floating-point stack (in 80-bit precision) as long as possible. This has | |
| 496 # important side effects, that the real value used in computation may | |
| 497 # change depending on how the compiler did the optimization - that is, the | |
| 498 # value kept in 80-bit is different than the value rounded down to 64-bit | |
| 499 # or 32-bit. There are possible compiler options to make this behavior | |
| 500 # consistent (e.g. -ffloat-store would keep all floating-values in the | |
| 501 # memory, thus force them to be rounded to its original precision) but they | |
| 502 # have significant runtime performance penalty. | |
| 503 # | |
| 504 # -mfpmath=sse -msse2 makes the compiler use SSE instructions which keep | |
| 505 # floating-point values in SSE registers in its native precision (32-bit | |
| 506 # for single precision, and 64-bit for double precision values). This means | |
| 507 # the floating-point value used during computation does not change | |
| 508 # depending on how the compiler optimized the code, since the value is | |
| 509 # always kept in its specified precision. | |
| 510 '-msse2', '-mfpmath=sse'], | |
| 511 # GCC will generate ident directives with the GCC version. Accumulate | |
| 512 # these all up and you end up with ~80K repeated in a .comment section. | |
| 513 CCFLAGS_OPTIMIZED = ['-fno-ident'], | |
| 514 CXXFLAGS = ['-Wall', '-Werror', '-march=i686'] + excluded_warnings, | |
| 515 LINKFLAGS = ['-m32', '-pthread'], | |
| 516 ) | |
| 517 | |
| 518 linux_env.Replace( | |
| 519 # Linking of large files uses lots of RAM, so serialize links | |
| 520 # using the handy flock command from util-linux. | |
| 521 LINK = 'flock $TARGET_ROOT/linker.lock ' + linux_env['LINK'], | |
| 522 | |
| 523 # We have several cases where archives depend on each other in a cyclic | |
| 524 # fashion. (V8Bindings, libport and WebCore being the most significant | |
| 525 # example.) Since the GNU linker does only a single pass over the archives | |
| 526 # we need some extra trickery to deal with these unavoidable cycles. That | |
| 527 # trickery is --start-group and --end-group (aka -( and -) ). That causes ld | |
| 528 # to loop over the group until no more undefined symbols are found. In an | |
| 529 # ideal world we would only make groups from those libraries which we knew | |
| 530 # to be in cycles. However, that's tough with SCons, so we bodge it by | |
| 531 # making all the archives a group by redefining the linking command here. | |
| 532 SHLINKCOM = ('$SHLINK -o $TARGET $SHLINKFLAGS $SOURCES ' | |
| 533 '$_LIBDIRFLAGS ' | |
| 534 '-Wl,--start-group $_LIBFLAGS -Wl,--end-group'), | |
| 535 LINKCOM = ('$LINK -o $TARGET $LINKFLAGS $SOURCES ' | |
| 536 '$_LIBDIRFLAGS ' | |
| 537 '-Wl,--start-group $_LIBFLAGS -Wl,--end-group'), | |
| 538 ) | |
| 539 | |
| 540 linux_env.Replace( | |
| 541 PERL = '/usr/bin/perl', | |
| 542 PERL_INCLUDE_FLAG = '-I ', | |
| 543 PERL_INCLUDE_SUFFIX = '', | |
| 544 _PERL_INCLUDE_FLAGS = ('${_concat(PERL_INCLUDE_FLAG, ' | |
| 545 'PERL_INCLUDE_PATH, ' | |
| 546 'PERL_INCLUDE_SUFFIX,' | |
| 547 '__env__, RDirs, TARGET, SOURCE)}'), | |
| 548 ) | |
| 549 | |
| 550 linux_env.FilterOut( | |
| 551 BUILD_SCONSCRIPTS = [ | |
| 552 '$BSPATCH_DIR/bspatch.scons', | |
| 553 '$BSDIFF_DIR/bsdiff.scons', | |
| 554 '$GOOGLE_UPDATE_DIR/SConscript', | |
| 555 '$RLZ_DIR/SConscript', | |
| 556 '$SANDBOX_DIR/sandbox.scons', | |
| 557 ], | |
| 558 ) | |
| 559 | |
| 560 linux_env.Append( | |
| 561 # We need rt for clock_gettime. | |
| 562 LIBS = ['rt'], | |
| 563 | |
| 564 ICU_LIBS = ['icu'], | |
| 565 ) | |
| 566 | |
| 567 # Build an "official" build (DCHECKs completely compiled out, etc). | |
| 568 if ARGUMENTS.get('OFFICIAL') == '1': | |
| 569 linux_env.Append(CPPDEFINES=['OFFICIAL_BUILD']) | |
| 570 # Make sure units of code and data go in their own section, and then GC them | |
| 571 # in the linker to remove unreferenced data and code. Currently gold doesn't | |
| 572 # support --gc-sections, so you'll have to build with the original GNU ld. | |
| 573 linux_env.Append(CCFLAGS_OPTIMIZED=['-ffunction-sections', '-fdata-sections']) | |
| 574 linux_env.Append(LINKFLAGS_OPTIMIZED=['-Wl,--gc-sections']) | |
| 575 | |
| 576 # Build with support for gcov when COVERAGE=1. | |
| 577 if ARGUMENTS.get('COVERAGE') == '1': | |
| 578 linux_env.Append(CCFLAGS=['-fprofile-arcs', '-ftest-coverage']) | |
| 579 linux_env.Append(LINKFLAGS=['-fprofile-arcs']) | |
| 580 | |
| 581 # Build with support for gprof when PROFILE=1. | |
| 582 if ARGUMENTS.get('PROFILE') == '1': | |
| 583 linux_env.Append(CCFLAGS=['-pg', '-g']) | |
| 584 linux_env.Append(LINKFLAGS=['-pg']) | |
| 585 | |
| 586 # Build with symbols (useful for opt builds, for example) when SYMBOLS=1. | |
| 587 if ARGUMENTS.get('SYMBOLS') == '1': | |
| 588 linux_env.Append(CCFLAGS=['-g']) | |
| 589 | |
| 590 # Build shared libraries (useful for fast links) when SHARED=1. | |
| 591 if ARGUMENTS.get('SHARED') == '1': | |
| 592 linux_env.Replace(COMPONENT_STATIC=False) | |
| 593 | |
| 594 # Build with system-provided NSS and GTK. | |
| 595 if root_env['PLATFORM'] in ['linux', 'linux2', 'posix']: | |
| 596 try: | |
| 597 linux_env.ParseConfig('pkg-config --cflags --libs nss') | |
| 598 linux_env.ParseConfig('pkg-config --cflags --libs gtk+-2.0') | |
| 599 linux_env.ParseConfig('pkg-config --cflags --libs pangoft2') | |
| 600 except OSError, e: | |
| 601 print ('\n' | |
| 602 'Failed to find a package dependency. Please install all the\n' | |
| 603 'packages listed at\n' | |
| 604 'http://code.google.com/p/chromium/wiki/LinuxBuildInstructions' | |
| 605 '#Software_Requirements') | |
| 606 | |
| 607 sys.exit(1) | |
| 608 | |
| 609 # TODO: Factor the code here into aits own function. | |
| 610 if root_env.WantSystemLib('libxml'): | |
| 611 try: | |
| 612 linux_env.ParseConfig('pkg-config --cflags --libs libxml-2.0') | |
| 613 except OSError, e: | |
| 614 print ('\n' | |
| 615 'libxml requested in SYSTEM_LIBS but not found\n') | |
| 616 sys.exit(1) | |
| 617 if root_env.WantSystemLib('libxslt'): | |
| 618 try: | |
| 619 linux_env.ParseConfig('pkg-config --cflags --libs libxslt') | |
| 620 except OSError, e: | |
| 621 print ('\n' | |
| 622 'libxslt requested in SYSTEM_LIBS but not found\n') | |
| 623 sys.exit(1) | |
| 624 if root_env.WantSystemLib('sqlite'): | |
| 625 try: | |
| 626 linux_env.ParseConfig('pkg-config --cflags --libs sqlite') | |
| 627 except OSError, e: | |
| 628 print ('\n' | |
| 629 'sqlite requested in SYSTEM_LIBS but not found\n') | |
| 630 sys.exit(1) | |
| 631 | |
| 632 linux_dbg = linux_env.Clone() | |
| 633 environment_list.append(linux_dbg) | |
| 634 linux_dbg.Replace( | |
| 635 BUILD_TYPE = 'dbg', | |
| 636 BUILD_TYPE_DESCRIPTION = 'Linux debug build', | |
| 637 ) | |
| 638 linux_dbg.Tool('target_debug') | |
| 639 linux_dbg.ApplySConscript(['$CHROME_SRC_DIR/build/debug.scons']) | |
| 640 linux_dbg.Append(BUILD_GROUPS = ['default']) | |
| 641 | |
| 642 linux_opt = linux_env.Clone() | |
| 643 environment_list.append(linux_opt) | |
| 644 # Disable rpath for faster startup. | |
| 645 linux_opt.Append(RPATH = []) | |
| 646 linux_opt.Replace( | |
| 647 BUILD_TYPE = 'opt', | |
| 648 BUILD_TYPE_DESCRIPTION = 'Linux optimized build', | |
| 649 ) | |
| 650 linux_opt.Tool('target_optimized') | |
| 651 linux_opt.ApplySConscript(['$CHROME_SRC_DIR/build/release.scons']) | |
| 652 | |
| 653 # -------------------------------------------------------------------------- | |
| 654 # Mac specific | |
| 655 | |
| 656 mac_env = root_env.Clone() | |
| 657 environment_list.append(mac_env) | |
| 658 mac_env.Tool('target_platform_mac') | |
| 659 mac_env.Tool('target_debug') | |
| 660 mac_env.ApplySConscript(['$CHROME_SRC_DIR/build/debug.scons']) | |
| 661 mac_env.Replace( | |
| 662 BUILD_TYPE = 'debug-mac', | |
| 663 BUILD_TYPE_DESCRIPTION = 'Mac debug build', | |
| 664 ) | |
| 665 mac_env.Append(BUILD_GROUPS = ['default']) | |
| 666 | |
| 667 mac_env.Replace( | |
| 668 # Reproduce XCode's behavior of using gcc even to link C++, | |
| 669 # and distinguishing it the -x c++ option. | |
| 670 CC = 'gcc-4.2', | |
| 671 CXX = 'g++-4.2', | |
| 672 LINK = '$CXX', | |
| 673 ) | |
| 674 mac_env.FilterOut(SHCCFLAGS = ['-fPIC']) | |
| 675 mac_env.FilterOut(SHLINKFLAGS = ['-fPIC']) | |
| 676 | |
| 677 mac_env.FilterOut( | |
| 678 BUILD_SCONSCRIPTS = [ | |
| 679 '$BREAKPAD_DIR/SConscript', | |
| 680 '$BSDIFF_DIR/bsdiff.scons', | |
| 681 '$BSPATCH_DIR/bspatch.scons', | |
| 682 '$CHROME_DIR/chrome_main${_GYP}.scons', | |
| 683 '$GOOGLE_UPDATE_DIR/SConscript', | |
| 684 '$LIBJPEG_DIR/libjpeg.scons', | |
| 685 '$LIBXML_DIR/libxml.scons', | |
| 686 '$LIBXSLT_DIR/libxslt.scons', | |
| 687 '$RLZ_DIR/SConscript', | |
| 688 '$SANDBOX_DIR/sandbox.scons', | |
| 689 '$WEBKIT_DIR/SConscript', | |
| 690 'build/SConscript.v8', | |
| 691 ], | |
| 692 ) | |
| 693 # TODO(bradnelson): this is needed for now because target_platform_mac has | |
| 694 # OS_MACOSX defined in a weird way. | |
| 695 mac_env.FilterOut(CPPDEFINES = ['OS_MACOSX=OS_MACOSX']) | |
| 696 | |
| 697 if not root_env.WantSystemLib('libevent') and not root_env.get('_GYP'): | |
| 698 mac_env.Append( | |
| 699 BUILD_SCONSCRIPTS = [ | |
| 700 '$LIBEVENT_DIR/libevent${_GYP}.scons', | |
| 701 ], | |
| 702 ) | |
| 703 mac_env.Append( | |
| 704 CFLAGS = [ | |
| 705 '-std=c99', | |
| 706 ], | |
| 707 CXXFLAGS = [ | |
| 708 '-fvisibility-inlines-hidden', | |
| 709 '${str(SOURCE).endswith(".mm") and "-fobjc-gc" or ""}', | |
| 710 ], | |
| 711 CCFLAGS = [ | |
| 712 '-fmessage-length=0', | |
| 713 '-pipe', | |
| 714 '-O0', | |
| 715 '-mdynamic-no-pic', | |
| 716 '-Werror', | |
| 717 '-Wnewline-eof', | |
| 718 '-fvisibility=hidden', | |
| 719 '-gdwarf-2', | |
| 720 '-Wall', | |
| 721 '-Wendif-labels', | |
| 722 '-fstack-protector', | |
| 723 '-fstack-protector-all', | |
| 724 ], | |
| 725 CPPDEFINES = [ | |
| 726 'DEBUG', | |
| 727 ], | |
| 728 | |
| 729 FRAMEWORKPATH = [ | |
| 730 mac_env.Dir('${TARGET_ROOT}'), | |
| 731 '/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Fra
meworks', | |
| 732 ], | |
| 733 FRAMEWORKS = [ | |
| 734 'AppKit', | |
| 735 'ApplicationServices', | |
| 736 'Foundation', | |
| 737 ], | |
| 738 | |
| 739 ICU_LIBS = ['icui18n', 'icuuc', 'icudata'], | |
| 740 ) | |
| 741 | |
| 742 | |
| 743 # -------------------------------------------------------------------------- | |
| 744 # Platform-independent "xcode" mode for generating XCode files | |
| 745 # from any platform. | |
| 746 | |
| 747 DeclareBit('xcode', 'Generate XCode files') | |
| 748 | |
| 749 # TODO(sgk): remove this after we update Hammer modules. | |
| 750 DeclareBit('mac', 'Target platform is mac.') | |
| 751 | |
| 752 xcode_env = mac_env.Clone() | |
| 753 # TODO(sgk): uncomment when xcode generation becomes real. | |
| 754 #environment_list.append(xcode_env) | |
| 755 xcode_env.Replace( | |
| 756 BUILD_TYPE = 'xcode', | |
| 757 BUILD_TYPE_DESCRIPTION = 'Generate XCode files', | |
| 758 HOST_PLATFORMS = ['*'], | |
| 759 ICU_LIBS = [], | |
| 760 ) | |
| 761 xcode_env.SetBits('mac', 'xcode') | |
| 762 # TODO(sgk): turn into separate debug + release env adding | |
| 763 # to a common .sln file | |
| 764 xcode_env.Tool('target_debug') | |
| 765 | |
| 766 | |
| 767 # ------------------------------------------------------------------------- | |
| 768 | |
| 769 | |
| 770 # Overlay things from a layer below. | |
| 771 for env in environment_list: | |
| 772 env.Dir('$OBJ_ROOT').addRepository(env.Dir('$CHROME_SRC_DIR')) | |
| 773 env.Dir('$OBJ_ROOT/googleurl').addRepository(env.Dir('$CHROME_SRC_DIR/build')) | |
| 774 | |
| 775 # We pre-resolve some common targets. We end up spending lots of time | |
| 776 # resolving these over and over again. | |
| 777 env.Replace( | |
| 778 CHROME_SRC_DIR = str(env.Dir('$CHROME_SRC_DIR')), | |
| 779 SRC_DIR = str(env.Dir('$SRC_DIR')), | |
| 780 DESTINATION_ROOT = str(env.Dir('$DESTINATION_ROOT')), | |
| 781 TARGET_ROOT = str(env.Dir('$TARGET_ROOT')), | |
| 782 OBJ_ROOT = str(env.Dir('$OBJ_ROOT')), | |
| 783 WEBKIT_DIR = str(env.Dir('$WEBKIT_DIR')), | |
| 784 ) | |
| 785 | |
| 786 | |
| 787 help_fmt = """ | |
| 788 Usage: hammer [SCONS_OPTIONS] [VARIABLES] [TARGET] ... | |
| 789 | |
| 790 Supported build variables: | |
| 791 LOAD=[module,...] Comma-separated list of components to load in the | |
| 792 dependency graph ('-' prefix excludes): | |
| 793 %s | |
| 794 SYSTEM_LIBS=[lib,...] Comma-separated list of system libraries to link | |
| 795 dynamically (by default they are built in from | |
| 796 included sources): | |
| 797 %s | |
| 798 PROGRESS=type Display a progress indicator: | |
| 799 name: print each evaluated target name | |
| 800 spinner: print a spinner every 5 targets | |
| 801 GYP=1 Any non-null value uses GYP-generated files | |
| 802 (*_gyp.scons). | |
| 803 """ | |
| 804 | |
| 805 if GetOption('help'): | |
| 806 import textwrap | |
| 807 tw = textwrap.TextWrapper( | |
| 808 width = 78, | |
| 809 initial_indent = ' '*32, | |
| 810 subsequent_indent = ' '*32, | |
| 811 ) | |
| 812 components = tw.fill(', '.join(components)) | |
| 813 all_system_libs = tw.fill(', '.join(env['all_system_libs'])) | |
| 814 | |
| 815 Help(help_fmt % (components, all_system_libs)) | |
| 816 | |
| 817 # ------------------------------------------------------------------------- | |
| 818 | |
| 819 # Invoke all the SConscripts in each of the environments that make sense on | |
| 820 # this host-platform. | |
| 821 BuildComponents(environment_list) | |
| 822 | |
| 823 # ------------------------------------------------------------------------- | |
| 824 | |
| 825 if not root_env.get('_GYP'): | |
| 826 modes = GetTargetModes().keys() | |
| 827 | |
| 828 if set(modes) - set(['msvs', 'xcode']): | |
| 829 # There's at least one mode being built besides the platform- | |
| 830 # independent 'msvs' or 'xcode' modes. Build the current | |
| 831 # build_component's Alias as default--that is, "base" when we're | |
| 832 # in the base/ subdirectory, "chrome" under chrome/, etc. | |
| 833 Import('build_component') | |
| 834 Default(Alias(build_component)) # Set default target based on where built. | |
| 835 | |
| 836 if 'msvs' in modes: | |
| 837 # We're in --mode=msvs, so add its Alias(es) to the default targets. | |
| 838 Default(Alias('msvs')) | |
| 839 | |
| 840 # ------------------------------------------------------------------------- | |
| 841 | |
| 842 # This must occur after BuildComponents so that the dependency graph | |
| 843 # will be populated. | |
| 844 vs_env = windows_env.Clone() | |
| 845 vs_env.Append(COMPONENT_VS_SOURCE_SUFFIXES = [ | |
| 846 '.def', | |
| 847 '.ini', | |
| 848 '.txt', | |
| 849 '.ui', | |
| 850 '.xml', | |
| 851 ]) | |
| 852 # Source project | |
| 853 p = vs_env.ComponentVSDirProject( | |
| 854 'chrome_src', | |
| 855 [ | |
| 856 # TODO(bradnelson): need to make sure we can use $CHROME_SRC_DIR here | |
| 857 '$CHROME_SRC_DIR/base', | |
| 858 '$CHROME_SRC_DIR/breakpad', | |
| 859 '$CHROME_SRC_DIR/build', | |
| 860 # '$CHROME_SRC_DIR/chrome', | |
| 861 '.', | |
| 862 '$CHROME_SRC_DIR/data', | |
| 863 '$CHROME_SRC_DIR/gears', | |
| 864 '$CHROME_SRC_DIR/google_update', | |
| 865 '$CHROME_SRC_DIR/googleurl', | |
| 866 '$CHROME_SRC_DIR/net', | |
| 867 '$CHROME_SRC_DIR/rlz', | |
| 868 '$CHROME_SRC_DIR/sandbox', | |
| 869 '$CHROME_SRC_DIR/sdhc', | |
| 870 '$CHROME_SRC_DIR/site_scons', | |
| 871 '$CHROME_SRC_DIR/skia', | |
| 872 '$CHROME_SRC_DIR/testing', | |
| 873 '$CHROME_SRC_DIR/third_party', | |
| 874 '$CHROME_SRC_DIR/tools', | |
| 875 '$CHROME_SRC_DIR/v8', | |
| 876 '$CHROME_SRC_DIR/webkit', | |
| 877 ], | |
| 878 COMPONENT_VS_SOURCE_FOLDERS = [ | |
| 879 (None, '$DESTINATION_ROOT'), | |
| 880 ('src', '$CHROME_SRC_DIR'), | |
| 881 ], | |
| 882 COMPONENT_VS_PROJECT_DIR = '$MAIN_DIR', | |
| 883 ) | |
| 884 | |
| 885 # Always try to (re)build the project files when requested. | |
| 886 vs_env.AlwaysBuild(p) | |
| 887 | |
| 888 vs_env.ComponentVSSolution( | |
| 889 'chrome_solution', | |
| 890 [ | |
| 891 'all_libraries', | |
| 892 'all_languages', | |
| 893 'all_programs', | |
| 894 'all_test_programs', | |
| 895 ], projects = [p], | |
| 896 COMPONENT_VS_PROJECT_SCRIPT_PATH=( | |
| 897 'cd $$(ProjectDir)/$VS_PROJECT_TO_MAIN_DIR && hammer.bat'), | |
| 898 ) | |
| 899 | |
| 900 # ------------------------------------------------------------------------- | |
| OLD | NEW |