1 # This file is generated; do not edit. 2 3 __doc__ = ''' 4 Wrapper configuration for building this entire "solution," 5 including all the specific targets in various *.scons files. 6 ''' 7 8 import os 9 import sys 10 11 import SCons.Environment 12 import SCons.Util 13 14 def GetProcessorCount(): 15 ''' 16 Detects the number of CPUs on the system. Adapted form: 17 http://codeliberates.blogspot.com/2008/05/detecting-cpuscores-in-python.html 18 ''' 19 # Linux, Unix and Mac OS X: 20 if hasattr(os, 'sysconf'): 21 if os.sysconf_names.has_key('SC_NPROCESSORS_ONLN'): 22 # Linux and Unix or Mac OS X with python >= 2.5: 23 return os.sysconf('SC_NPROCESSORS_ONLN') 24 else: # Mac OS X with Python < 2.5: 25 return int(os.popen2("sysctl -n hw.ncpu")[1].read()) 26 # Windows: 27 if os.environ.has_key('NUMBER_OF_PROCESSORS'): 28 return max(int(os.environ.get('NUMBER_OF_PROCESSORS', '1')), 1) 29 return 1 # Default 30 31 # Support PROGRESS= to show progress in different ways. 32 p = ARGUMENTS.get('PROGRESS') 33 if p == 'spinner': 34 Progress(['/\r', '|\r', '\\\r', '-\r'], 35 interval=5, 36 file=open('/dev/tty', 'w')) 37 elif p == 'name': 38 Progress('$TARGET\r', overwrite=True, file=open('/dev/tty', 'w')) 39 40 # Set the default -j value based on the number of processors. 41 SetOption('num_jobs', GetProcessorCount() + 1) 42 43 # Have SCons use its cached dependency information. 44 SetOption('implicit_cache', 1) 45 46 # Only re-calculate MD5 checksums if a timestamp has changed. 47 Decider('MD5-timestamp') 48 49 # Since we set the -j value by default, suppress SCons warnings about being 50 # unable to support parallel build on versions of Python with no threading. 51 default_warnings = ['no-no-parallel-support'] 52 SetOption('warn', default_warnings + GetOption('warn')) 53 54 AddOption('--mode', nargs=1, dest='conf_list', default=[], 55 action='append', help='Configuration to build.') 56 57 AddOption('--verbose', dest='verbose', default=False, 58 action='store_true', help='Verbose command-line output.') 59 60 61 # 62 sconscript_file_map = dict( 63 base = 'base.scons', 64 base_i18n = 'base_i18n.scons', 65 base_unittests = 'base_unittests.scons', 66 gmock = '../testing/gmock.scons', 67 gtest = '../testing/gtest.scons', 68 icudata = '../third_party/icu/icudata.scons', 69 icui18n = '../third_party/icu/icui18n.scons', 70 icuuc = '../third_party/icu/icuuc.scons', 71 lastchange = '../build/util/lastchange.scons', 72 libevent = '../third_party/libevent/libevent.scons', 73 linux_versioninfo = 'linux_versioninfo.scons', 74 test_support_base = 'test_support_base.scons', 75 test_support_perf = 'test_support_perf.scons', 76 xdisplaycheck = '../tools/xdisplaycheck/xdisplaycheck.scons', 77 ) 78 79 class LoadTarget: 80 ''' 81 Class for deciding if a given target sconscript is to be included 82 based on a list of included target names, optionally prefixed with '-' 83 to exclude a target name. 84 ''' 85 def __init__(self, load): 86 ''' 87 Initialize a class with a list of names for possible loading. 88 89 Arguments: 90 load: list of elements in the LOAD= specification 91 ''' 92 self.included = set([c for c in load if not c.startswith('-')]) 93 self.excluded = set([c[1:] for c in load if c.startswith('-')]) 94 95 if not self.included: 96 self.included = set(['all']) 97 98 def __call__(self, target): 99 ''' 100 Returns True if the specified target's sconscript file should be 101 loaded, based on the initialized included and excluded lists. 102 ''' 103 return (target in self.included or 104 ('all' in self.included and not target in self.excluded)) 105 106 if 'LOAD' in ARGUMENTS: 107 load = ARGUMENTS['LOAD'].split(',') 108 else: 109 load = [] 110 load_target = LoadTarget(load) 111 112 sconscript_files = [] 113 for target, sconscript in sconscript_file_map.iteritems(): 114 if load_target(target): 115 sconscript_files.append(sconscript) 116 117 118 target_alias_list= [] 119 120 conf_list = GetOption('conf_list') 121 if conf_list: 122 # In case the same --mode= value was specified multiple times. 123 conf_list = list(set(conf_list)) 124 else: 125 conf_list = ['Debug'] 126 127 sconsbuild_dir = Dir('../sconsbuild') 128 129 130 def FilterOut(self, **kw): 131 kw = SCons.Environment.copy_non_reserved_keywords(kw) 132 for key, val in kw.items(): 133 envval = self.get(key, None) 134 if envval is None: 135 # No existing variable in the environment, so nothing to delete. 136 continue 137 138 for vremove in val: 139 # Use while not if, so we can handle duplicates. 140 while vremove in envval: 141 envval.remove(vremove) 142 143 self[key] = envval 144 145 # TODO(sgk): SCons.Environment.Append() has much more logic to deal 146 # with various types of values. We should handle all those cases in here 147 # too. (If variable is a dict, etc.) 148 149 150 non_compilable_suffixes = { 151 'LINUX' : set([ 152 '.bdic', 153 '.css', 154 '.dat', 155 '.fragment', 156 '.gperf', 157 '.h', 158 '.hh', 159 '.hpp', 160 '.html', 161 '.hxx', 162 '.idl', 163 '.in', 164 '.in0', 165 '.in1', 166 '.js', 167 '.mk', 168 '.rc', 169 '.sigs', 170 '', 171 ]), 172 'WINDOWS' : set([ 173 '.h', 174 '.hh', 175 '.hpp', 176 '.dat', 177 '.idl', 178 '.in', 179 '.in0', 180 '.in1', 181 ]), 182 } 183 184 def compilable(env, file): 185 base, ext = os.path.splitext(str(file)) 186 if ext in non_compilable_suffixes[env['TARGET_PLATFORM']]: 187 return False 188 return True 189 190 def compilable_files(env, sources): 191 return [x for x in sources if compilable(env, x)] 192 193 def GypProgram(env, target, source, *args, **kw): 194 source = compilable_files(env, source) 195 result = env.Program('$TOP_BUILDDIR/' + str(target), source, *args, **kw) 196 if env.get('INCREMENTAL'): 197 env.Precious(result) 198 return result 199 200 def GypTestProgram(env, target, source, *args, **kw): 201 source = compilable_files(env, source) 202 result = env.Program('$TOP_BUILDDIR/' + str(target), source, *args, **kw) 203 if env.get('INCREMENTAL'): 204 env.Precious(*result) 205 return result 206 207 def GypLibrary(env, target, source, *args, **kw): 208 source = compilable_files(env, source) 209 result = env.Library('$LIB_DIR/' + str(target), source, *args, **kw) 210 return result 211 212 def GypLoadableModule(env, target, source, *args, **kw): 213 source = compilable_files(env, source) 214 result = env.LoadableModule('$TOP_BUILDDIR/' + str(target), source, *args, 215 **kw) 216 return result 217 218 def GypStaticLibrary(env, target, source, *args, **kw): 219 source = compilable_files(env, source) 220 result = env.StaticLibrary('$LIB_DIR/' + str(target), source, *args, **kw) 221 return result 222 223 def GypSharedLibrary(env, target, source, *args, **kw): 224 source = compilable_files(env, source) 225 result = env.SharedLibrary('$LIB_DIR/' + str(target), source, *args, **kw) 226 if env.get('INCREMENTAL'): 227 env.Precious(result) 228 return result 229 230 def add_gyp_methods(env): 231 env.AddMethod(GypProgram) 232 env.AddMethod(GypTestProgram) 233 env.AddMethod(GypLibrary) 234 env.AddMethod(GypLoadableModule) 235 env.AddMethod(GypStaticLibrary) 236 env.AddMethod(GypSharedLibrary) 237 238 env.AddMethod(FilterOut) 239 240 env.AddMethod(compilable) 241 242 243 base_env = Environment( 244 tools = ['ar', 'as', 'gcc', 'g++', 'gnulink', 'chromium_builders'], 245 INTERMEDIATE_DIR='$OBJ_DIR/${COMPONENT_NAME}/_${TARGET_NAME}_intermediate', 246 LIB_DIR='$TOP_BUILDDIR/lib', 247 OBJ_DIR='$TOP_BUILDDIR/obj', 248 SCONSBUILD_DIR=sconsbuild_dir.abspath, 249 SHARED_INTERMEDIATE_DIR='$OBJ_DIR/_global_intermediate', 250 SRC_DIR=Dir('..'), 251 TARGET_PLATFORM='LINUX', 252 TOP_BUILDDIR='$SCONSBUILD_DIR/$CONFIG_NAME', 253 LIBPATH=['$LIB_DIR'], 254 ) 255 256 if not GetOption('verbose'): 257 base_env.SetDefault( 258 ARCOMSTR='Creating library $TARGET', 259 ASCOMSTR='Assembling $TARGET', 260 CCCOMSTR='Compiling $TARGET', 261 CONCATSOURCECOMSTR='ConcatSource $TARGET', 262 CXXCOMSTR='Compiling $TARGET', 263 LDMODULECOMSTR='Building loadable module $TARGET', 264 LINKCOMSTR='Linking $TARGET', 265 MANIFESTCOMSTR='Updating manifest for $TARGET', 266 MIDLCOMSTR='Compiling IDL $TARGET', 267 PCHCOMSTR='Precompiling $TARGET', 268 RANLIBCOMSTR='Indexing $TARGET', 269 RCCOMSTR='Compiling resource $TARGET', 270 SHCCCOMSTR='Compiling $TARGET', 271 SHCXXCOMSTR='Compiling $TARGET', 272 SHLINKCOMSTR='Linking $TARGET', 273 SHMANIFESTCOMSTR='Updating manifest for $TARGET', 274 ) 275 276 add_gyp_methods(base_env) 277 278 for conf in conf_list: 279 env = base_env.Clone(CONFIG_NAME=conf) 280 SConsignFile(env.File('$TOP_BUILDDIR/.sconsign').abspath) 281 for sconscript in sconscript_files: 282 target_alias = env.SConscript(sconscript, exports=['env']) 283 if target_alias: 284 target_alias_list.extend(target_alias) 285 286 Default(Alias('all', target_alias_list)) 287 288 help_fmt = ''' 289 Usage: hammer [SCONS_OPTIONS] [VARIABLES] [TARGET] ... 290 291 Local command-line build options: 292 --mode=CONFIG Configuration to build: 293 --mode=Debug [default] 294 --mode=Release 295 --verbose Print actual executed command lines. 296 297 Supported command-line build variables: 298 LOAD=[module,...] Comma-separated list of components to load in the 299 dependency graph ('-' prefix excludes) 300 PROGRESS=type Display a progress indicator: 301 name: print each evaluated target name 302 spinner: print a spinner every 5 targets 303 304 The following TARGET names can also be used as LOAD= module names: 305 306 %s 307 ''' 308 309 if GetOption('help'): 310 def columnar_text(items, width=78, indent=2, sep=2): 311 result = [] 312 colwidth = max(map(len, items)) + sep 313 cols = (width - indent) / colwidth 314 if cols < 1: 315 cols = 1 316 rows = (len(items) + cols - 1) / cols 317 indent = '%*s' % (indent, '') 318 sep = indent 319 for row in xrange(0, rows): 320 result.append(sep) 321 for i in xrange(row, len(items), rows): 322 result.append('%-*s' % (colwidth, items[i])) 323 sep = '\n' + indent 324 result.append('\n') 325 return ''.join(result) 326 327 load_list = set(sconscript_file_map.keys()) 328 target_aliases = set(map(str, target_alias_list)) 329 330 common = load_list and target_aliases 331 load_only = load_list - common 332 target_only = target_aliases - common 333 help_text = [help_fmt % columnar_text(sorted(list(common)))] 334 if target_only: 335 fmt = "The following are additional TARGET names:\n\n%s\n" 336 help_text.append(fmt % columnar_text(sorted(list(target_only)))) 337 if load_only: 338 fmt = "The following are additional LOAD= module names:\n\n%s\n" 339 help_text.append(fmt % columnar_text(sorted(list(load_only)))) 340 Help(''.join(help_text)) 341