Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: SConstruct

Issue 3185: Work around issue 80 by splitting strings from the environment... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2008 the V8 project authors. All rights reserved. 1 # Copyright 2008 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 12 matching lines...) Expand all
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 import platform 28 import platform
29 import re 29 import re
30 import sys 30 import sys
31 import os 31 import os
32 from os.path import join, dirname, abspath 32 from os.path import join, dirname, abspath
33 from types import DictType 33 from types import DictType, StringTypes
34 root_dir = dirname(File('SConstruct').rfile().abspath) 34 root_dir = dirname(File('SConstruct').rfile().abspath)
35 sys.path.append(join(root_dir, 'tools')) 35 sys.path.append(join(root_dir, 'tools'))
36 import js2c, utils 36 import js2c, utils
37 37
38 38
39 LIBRARY_FLAGS = { 39 LIBRARY_FLAGS = {
40 'all': { 40 'all': {
41 'CPPDEFINES': ['ENABLE_LOGGING_AND_PROFILING'] 41 'CPPDEFINES': ['ENABLE_LOGGING_AND_PROFILING']
42 }, 42 },
43 'gcc': { 43 'gcc': {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 'CPPDEFINES': ['BUILDING_V8_SHARED'] 131 'CPPDEFINES': ['BUILDING_V8_SHARED']
132 } 132 }
133 } 133 }
134 } 134 }
135 135
136 136
137 DTOA_EXTRA_FLAGS = { 137 DTOA_EXTRA_FLAGS = {
138 'gcc': { 138 'gcc': {
139 'all': { 139 'all': {
140 'WARNINGFLAGS': ['-Werror'] 140 'WARNINGFLAGS': ['-Werror']
141 } 141 }
142 }, 142 },
143 'msvc': { 143 'msvc': {
144 'all': { 144 'all': {
145 'WARNINGFLAGS': ['/WX', '/wd4018', '/wd4244'] 145 'WARNINGFLAGS': ['/WX', '/wd4018', '/wd4244']
146 } 146 }
147 } 147 }
148 } 148 }
149 149
150 150
151 CCTEST_EXTRA_FLAGS = { 151 CCTEST_EXTRA_FLAGS = {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 'help': 'set how the build system detects file changes' 306 'help': 'set how the build system detects file changes'
307 } 307 }
308 } 308 }
309 309
310 310
311 def GetOptions(): 311 def GetOptions():
312 result = Options() 312 result = Options()
313 result.Add('mode', 'compilation mode (debug, release)', 'release') 313 result.Add('mode', 'compilation mode (debug, release)', 'release')
314 result.Add('sample', 'build sample (shell, process)', '') 314 result.Add('sample', 'build sample (shell, process)', '')
315 result.Add('env', 'override environment settings (NAME1:value1,NAME2:value2)', '') 315 result.Add('env', 'override environment settings (NAME1:value1,NAME2:value2)', '')
316 for (name, option) in SIMPLE_OPTIONS.items(): 316 for (name, option) in SIMPLE_OPTIONS.iteritems():
317 help = '%s (%s)' % (name, ", ".join(option['values'])) 317 help = '%s (%s)' % (name, ", ".join(option['values']))
318 result.Add(name, help, option.get('default')) 318 result.Add(name, help, option.get('default'))
319 return result 319 return result
320 320
321 321
322 def SplitList(str): 322 def SplitList(str):
323 return [ s for s in str.split(",") if len(s) > 0 ] 323 return [ s for s in str.split(",") if len(s) > 0 ]
324 324
325 325
326 def IsLegal(env, option, values): 326 def IsLegal(env, option, values):
327 str = env[option] 327 str = env[option]
328 for s in SplitList(str): 328 for s in SplitList(str):
329 if not s in values: 329 if not s in values:
330 Abort("Illegal value for option %s '%s'." % (option, s)) 330 Abort("Illegal value for option %s '%s'." % (option, s))
331 return False 331 return False
332 return True 332 return True
333 333
334 334
335 def VerifyOptions(env): 335 def VerifyOptions(env):
336 if not IsLegal(env, 'mode', ['debug', 'release']): 336 if not IsLegal(env, 'mode', ['debug', 'release']):
337 return False 337 return False
338 if not IsLegal(env, 'sample', ["shell", "process"]): 338 if not IsLegal(env, 'sample', ["shell", "process"]):
339 return False 339 return False
340 for (name, option) in SIMPLE_OPTIONS.items(): 340 for (name, option) in SIMPLE_OPTIONS.iteritems():
341 if (not option.get('default')) and (name not in ARGUMENTS): 341 if (not option.get('default')) and (name not in ARGUMENTS):
342 message = ("A value for option %s must be specified (%s)." % 342 message = ("A value for option %s must be specified (%s)." %
343 (name, ", ".join(option['values']))) 343 (name, ", ".join(option['values'])))
344 Abort(message) 344 Abort(message)
345 if not env[name] in option['values']: 345 if not env[name] in option['values']:
346 message = ("Unknown %s value '%s'. Possible values are (%s)." % 346 message = ("Unknown %s value '%s'. Possible values are (%s)." %
347 (name, env[name], ", ".join(option['values']))) 347 (name, env[name], ", ".join(option['values'])))
348 Abort(message) 348 Abort(message)
349 349
350 350
351 class BuildContext(object): 351 class BuildContext(object):
352 352
353 def __init__(self, options, env_overrides, samples): 353 def __init__(self, options, env_overrides, samples):
354 self.library_targets = [] 354 self.library_targets = []
355 self.cctest_targets = [] 355 self.cctest_targets = []
356 self.sample_targets = [] 356 self.sample_targets = []
357 self.options = options 357 self.options = options
358 self.env_overrides = env_overrides 358 self.env_overrides = env_overrides
359 self.samples = samples 359 self.samples = samples
360 self.use_snapshot = (options['snapshot'] == 'on') 360 self.use_snapshot = (options['snapshot'] == 'on')
361 self.flags = None 361 self.flags = None
362 362
363 def AddRelevantFlags(self, initial, flags): 363 def AddRelevantFlags(self, initial, flags):
364 result = initial.copy() 364 result = initial.copy()
365 self.AppendFlags(result, flags.get('all')) 365 self.AppendFlags(result, flags.get('all'))
366 toolchain = self.options['toolchain'] 366 toolchain = self.options['toolchain']
367 self.AppendFlags(result, flags[toolchain].get('all')) 367 self.AppendFlags(result, flags[toolchain].get('all'))
368 for option in sorted(self.options.keys()): 368 for option in sorted(self.options.keys()):
369 value = self.options[option] 369 value = self.options[option]
370 self.AppendFlags(result, flags[toolchain].get(option + ':' + value)) 370 self.AppendFlags(result, flags[toolchain].get(option + ':' + value))
371 return result 371 return result
372 372
373 def GetRelevantSources(self, source): 373 def GetRelevantSources(self, source):
374 result = [] 374 result = []
375 result += source.get('all', []) 375 result += source.get('all', [])
376 for (name, value) in self.options.items(): 376 for (name, value) in self.options.iteritems():
377 result += source.get(name + ':' + value, []) 377 result += source.get(name + ':' + value, [])
378 return sorted(result) 378 return sorted(result)
379 379
380 def AppendFlags(self, options, added): 380 def AppendFlags(self, options, added):
381 if not added: 381 if not added:
382 return 382 return
383 for (key, value) in added.items(): 383 for (key, value) in added.iteritems():
384 if not key in options: 384 if not key in options:
385 options[key] = value 385 options[key] = value
386 else: 386 else:
387 options[key] = options[key] + value 387 prefix = options[key]
388 if isinstance(prefix, StringTypes): prefix = prefix.split()
389 options[key] = prefix + value
388 390
389 def ConfigureObject(self, env, input, **kw): 391 def ConfigureObject(self, env, input, **kw):
390 if self.options['library'] == 'static': 392 if self.options['library'] == 'static':
391 return env.StaticObject(input, **kw) 393 return env.StaticObject(input, **kw)
392 else: 394 else:
393 return env.SharedObject(input, **kw) 395 return env.SharedObject(input, **kw)
394 396
395 def ApplyEnvOverrides(self, env): 397 def ApplyEnvOverrides(self, env):
396 if not self.env_overrides: 398 if not self.env_overrides:
397 return 399 return
(...skipping 28 matching lines...) Expand all
426 for option in SIMPLE_OPTIONS: 428 for option in SIMPLE_OPTIONS:
427 options[option] = env[option] 429 options[option] = env[option]
428 PostprocessOptions(options) 430 PostprocessOptions(options)
429 431
430 context = BuildContext(options, env_overrides, samples=SplitList(env['sample'] )) 432 context = BuildContext(options, env_overrides, samples=SplitList(env['sample'] ))
431 433
432 library_flags = context.AddRelevantFlags(os.environ, LIBRARY_FLAGS) 434 library_flags = context.AddRelevantFlags(os.environ, LIBRARY_FLAGS)
433 v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS) 435 v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS)
434 jscre_flags = context.AddRelevantFlags(library_flags, JSCRE_EXTRA_FLAGS) 436 jscre_flags = context.AddRelevantFlags(library_flags, JSCRE_EXTRA_FLAGS)
435 dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS) 437 dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS)
436 cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS) 438 cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS)
437 sample_flags = context.AddRelevantFlags(os.environ, SAMPLE_FLAGS) 439 sample_flags = context.AddRelevantFlags(os.environ, SAMPLE_FLAGS)
438 440
439 context.flags = { 441 context.flags = {
440 'v8': v8_flags, 442 'v8': v8_flags,
441 'jscre': jscre_flags, 443 'jscre': jscre_flags,
442 'dtoa': dtoa_flags, 444 'dtoa': dtoa_flags,
443 'cctest': cctest_flags, 445 'cctest': cctest_flags,
444 'sample': sample_flags 446 'sample': sample_flags
445 } 447 }
446 448
447 target_id = mode 449 target_id = mode
448 suffix = SUFFIXES[target_id] 450 suffix = SUFFIXES[target_id]
449 library_name = 'v8' + suffix 451 library_name = 'v8' + suffix
450 env['LIBRARY'] = library_name 452 env['LIBRARY'] = library_name
451 453
452 # Build the object files by invoking SCons recursively. 454 # Build the object files by invoking SCons recursively.
453 object_files = env.SConscript( 455 object_files = env.SConscript(
454 join('src', 'SConscript'), 456 join('src', 'SConscript'),
455 build_dir=join('obj', target_id), 457 build_dir=join('obj', target_id),
456 exports='context', 458 exports='context',
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 # version of scons. Also, there's a bug in some revisions that 532 # version of scons. Also, there's a bug in some revisions that
531 # doesn't allow this flag to be set, so we swallow any exceptions. 533 # doesn't allow this flag to be set, so we swallow any exceptions.
532 # Lovely. 534 # Lovely.
533 try: 535 try:
534 SetOption('warn', 'no-deprecated') 536 SetOption('warn', 'no-deprecated')
535 except: 537 except:
536 pass 538 pass
537 539
538 540
539 Build() 541 Build()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698