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 icudata = 'icudata.scons', 64 icui18n = 'icui18n.scons', 65 icuuc = 'icuuc.scons', 66 ) 67 68 class LoadTarget: 69 ''' 70 Class for deciding if a given target sconscript is to be included 71 based on a list of included target names, optionally prefixed with '-' 72 to exclude a target name. 73 ''' 74 def __init__(self, load): 75 ''' 76 Initialize a class with a list of names for possible loading. 77 78 Arguments: 79 load: list of elements in the LOAD= specification 80 ''' 81 self.included = set([c for c in load if not c.startswith('-')]) 82 self.excluded = set([c[1:] for c in load if c.startswith('-')]) 83 84 if not self.included: 85 self.included = set(['all']) 86 87 def __call__(self, target): 88 ''' 89 Returns True if the specified target's sconscript file should be 90 loaded, based on the initialized included and excluded lists. 91 ''' 92 return (target in self.included or 93 ('all' in self.included and not target in self.excluded)) 94 95 if 'LOAD' in ARGUMENTS: 96 load = ARGUMENTS['LOAD'].split(',') 97 else: 98 load = [] 99 load_target = LoadTarget(load) 100 101 sconscript_files = [] 102 for target, sconscript in sconscript_file_map.iteritems(): 103 if load_target(target): 104 sconscript_files.append(sconscript) 105 106 107 target_alias_list= [] 108 109 conf_list = GetOption('conf_list') 110 if conf_list: 111 # In case the same --mode= value was specified multiple times. 112 conf_list = list(set(conf_list)) 113 else: 114 conf_list = ['Debug'] 115 116 sconsbuild_dir = Dir('../../sconsbuild') 117 118 119 def FilterOut(self, **kw): 120 kw = SCons.Environment.copy_non_reserved_keywords(kw) 121 for key, val in kw.items(): 122 envval = self.get(key, None) 123 if envval is None: 124 # No existing variable in the environment, so nothing to delete. 125 continue 126 127 for vremove in val: 128 # Use while not if, so we can handle duplicates. 129 while vremove in envval: 130 envval.remove(vremove) 131 132 self[key] = envval 133 134 # TODO(sgk): SCons.Environment.Append() has much more logic to deal 135 # with various types of values. We should handle all those cases in here 136 # too. (If variable is a dict, etc.) 137 138 139 non_compilable_suffixes = { 140 'LINUX' : set([ 141 '.bdic', 142 '.css', 143 '.dat', 144 '.fragment', 145 '.gperf', 146 '.h', 147 '.hh', 148 '.hpp', 149 '.html', 150 '.hxx', 151 '.idl', 152 '.in', 153 '.in0', 154 '.in1', 155 '.js', 156 '.mk', 157 '.rc', 158 '.sigs', 159 '', 160 ]), 161 'WINDOWS' : set([ 162 '.h', 163 '.hh', 164 '.hpp', 165 '.dat', 166 '.idl', 167 '.in', 168 '.in0', 169 '.in1', 170 ]), 171 } 172 173 def compilable(env, file): 174 base, ext = os.path.splitext(str(file)) 175 if ext in non_compilable_suffixes[env['TARGET_PLATFORM']]: 176 return False 177 return True 178 179 def compilable_files(env, sources): 180 return [x for x in sources if compilable(env, x)] 181 182 def GypProgram(env, target, source, *args, **kw): 183 source = compilable_files(env, source) 184 result = env.Program('$TOP_BUILDDIR/' + str(target), source, *args, **kw) 185 if env.get('INCREMENTAL'): 186 env.Precious(result) 187 return result 188 189 def GypTestProgram(env, target, source, *args, **kw): 190 source = compilable_files(env, source) 191 result = env.Program('$TOP_BUILDDIR/' + str(target), source, *args, **kw) 192 if env.get('INCREMENTAL'): 193 env.Precious(*result) 194 return result 195 196 def GypLibrary(env, target, source, *args, **kw): 197 source = compilable_files(env, source) 198 result = env.Library('$LIB_DIR/' + str(target), source, *args, **kw) 199 return result 200 201 def GypLoadableModule(env, target, source, *args, **kw): 202 source = compilable_files(env, source) 203 result = env.LoadableModule('$TOP_BUILDDIR/' + str(target), source, *args, 204 **kw) 205 return result 206 207 def GypStaticLibrary(env, target, source, *args, **kw): 208 source = compilable_files(env, source) 209 result = env.StaticLibrary('$LIB_DIR/' + str(target), source, *args, **kw) 210 return result 211 212 def GypSharedLibrary(env, target, source, *args, **kw): 213 source = compilable_files(env, source) 214 result = env.SharedLibrary('$LIB_DIR/' + str(target), source, *args, **kw) 215 if env.get('INCREMENTAL'): 216 env.Precious(result) 217 return result 218 219 def add_gyp_methods(env): 220 env.AddMethod(GypProgram) 221 env.AddMethod(GypTestProgram) 222 env.AddMethod(GypLibrary) 223 env.AddMethod(GypLoadableModule) 224 env.AddMethod(GypStaticLibrary) 225 env.AddMethod(GypSharedLibrary) 226 227 env.AddMethod(FilterOut) 228 229 env.AddMethod(compilable) 230 231 232 base_env = Environment( 233 tools = ['ar', 'as', 'gcc', 'g++', 'gnulink', 'chromium_builders'], 234 INTERMEDIATE_DIR='$OBJ_DIR/${COMPONENT_NAME}/_${TARGET_NAME}_intermediate', 235 LIB_DIR='$TOP_BUILDDIR/lib', 236 OBJ_DIR='$TOP_BUILDDIR/obj', 237 SCONSBUILD_DIR=sconsbuild_dir.abspath, 238 SHARED_INTERMEDIATE_DIR='$OBJ_DIR/_global_intermediate', 239 SRC_DIR=Dir('../..'), 240 TARGET_PLATFORM='LINUX', 241 TOP_BUILDDIR='$SCONSBUILD_DIR/$CONFIG_NAME', 242 LIBPATH=['$LIB_DIR'], 243 ) 244 245 if not GetOption('verbose'): 246 base_env.SetDefault( 247 ARCOMSTR='Creating library $TARGET', 248 ASCOMSTR='Assembling $TARGET', 249 CCCOMSTR='Compiling $TARGET', 250 CONCATSOURCECOMSTR='ConcatSource $TARGET', 251 CXXCOMSTR='Compiling $TARGET', 252 LDMODULECOMSTR='Building loadable module $TARGET', 253 LINKCOMSTR='Linking $TARGET', 254 MANIFESTCOMSTR='Updating manifest for $TARGET', 255 MIDLCOMSTR='Compiling IDL $TARGET', 256 PCHCOMSTR='Precompiling $TARGET', 257 RANLIBCOMSTR='Indexing $TARGET', 258 RCCOMSTR='Compiling resource $TARGET', 259 SHCCCOMSTR='Compiling $TARGET', 260 SHCXXCOMSTR='Compiling $TARGET', 261 SHLINKCOMSTR='Linking $TARGET', 262 SHMANIFESTCOMSTR='Updating manifest for $TARGET', 263 ) 264 265 add_gyp_methods(base_env) 266 267 for conf in conf_list: 268 env = base_env.Clone(CONFIG_NAME=conf) 269 SConsignFile(env.File('$TOP_BUILDDIR/.sconsign').abspath) 270 for sconscript in sconscript_files: 271 target_alias = env.SConscript(sconscript, exports=['env']) 272 if target_alias: 273 target_alias_list.extend(target_alias) 274 275 Default(Alias('all', target_alias_list)) 276 277 help_fmt = ''' 278 Usage: hammer [SCONS_OPTIONS] [VARIABLES] [TARGET] ... 279 280 Local command-line build options: 281 --mode=CONFIG Configuration to build: 282 --mode=Debug [default] 283 --mode=Release 284 --verbose Print actual executed command lines. 285 286 Supported command-line build variables: 287 LOAD=[module,...] Comma-separated list of components to load in the 288 dependency graph ('-' prefix excludes) 289 PROGRESS=type Display a progress indicator: 290 name: print each evaluated target name 291 spinner: print a spinner every 5 targets 292 293 The following TARGET names can also be used as LOAD= module names: 294 295 %s 296 ''' 297 298 if GetOption('help'): 299 def columnar_text(items, width=78, indent=2, sep=2): 300 result = [] 301 colwidth = max(map(len, items)) + sep 302 cols = (width - indent) / colwidth 303 if cols < 1: 304 cols = 1 305 rows = (len(items) + cols - 1) / cols 306 indent = '%*s' % (indent, '') 307 sep = indent 308 for row in xrange(0, rows): 309 result.append(sep) 310 for i in xrange(row, len(items), rows): 311 result.append('%-*s' % (colwidth, items[i])) 312 sep = '\n' + indent 313 result.append('\n') 314 return ''.join(result) 315 316 load_list = set(sconscript_file_map.keys()) 317 target_aliases = set(map(str, target_alias_list)) 318 319 common = load_list and target_aliases 320 load_only = load_list - common 321 target_only = target_aliases - common 322 help_text = [help_fmt % columnar_text(sorted(list(common)))] 323 if target_only: 324 fmt = "The following are additional TARGET names:\n\n%s\n" 325 help_text.append(fmt % columnar_text(sorted(list(target_only)))) 326 if load_only: 327 fmt = "The following are additional LOAD= module names:\n\n%s\n" 328 help_text.append(fmt % columnar_text(sorted(list(load_only)))) 329 Help(''.join(help_text)) 330