| OLD | NEW |
| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF', '/LTCG'] | 209 'LINKFLAGS': ['/OPT:REF', '/OPT:ICF', '/LTCG'] |
| 210 }, | 210 }, |
| 211 'mode:debug': { | 211 'mode:debug': { |
| 212 'CCFLAGS': ['/Od', '/MTd'], | 212 'CCFLAGS': ['/Od', '/MTd'], |
| 213 'LINKFLAGS': ['/DEBUG'] | 213 'LINKFLAGS': ['/DEBUG'] |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 | 218 |
| 219 D8_FLAGS = { |
| 220 'gcc': { |
| 221 'console:readline': { |
| 222 'LIBS': ['readline'] |
| 223 } |
| 224 }, |
| 225 'msvc': { } |
| 226 } |
| 227 |
| 228 |
| 219 SUFFIXES = { | 229 SUFFIXES = { |
| 220 'release': '', | 230 'release': '', |
| 221 'debug': '_g' | 231 'debug': '_g' |
| 222 } | 232 } |
| 223 | 233 |
| 224 | 234 |
| 225 def Abort(message): | 235 def Abort(message): |
| 226 print message | 236 print message |
| 227 sys.exit(1) | 237 sys.exit(1) |
| 228 | 238 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 }, | 315 }, |
| 306 'disassembler': { | 316 'disassembler': { |
| 307 'values': ['on', 'off'], | 317 'values': ['on', 'off'], |
| 308 'default': 'off', | 318 'default': 'off', |
| 309 'help': 'enable the disassembler to inspect generated code' | 319 'help': 'enable the disassembler to inspect generated code' |
| 310 }, | 320 }, |
| 311 'sourcesignatures': { | 321 'sourcesignatures': { |
| 312 'values': ['MD5', 'timestamp'], | 322 'values': ['MD5', 'timestamp'], |
| 313 'default': 'MD5', | 323 'default': 'MD5', |
| 314 'help': 'set how the build system detects file changes' | 324 'help': 'set how the build system detects file changes' |
| 325 }, |
| 326 'console': { |
| 327 'values': ['dumb', 'readline'], |
| 328 'default': 'dumb', |
| 329 'help': 'the console to use for the d8 shell' |
| 315 } | 330 } |
| 316 } | 331 } |
| 317 | 332 |
| 318 | 333 |
| 319 def GetOptions(): | 334 def GetOptions(): |
| 320 result = Options() | 335 result = Options() |
| 321 result.Add('mode', 'compilation mode (debug, release)', 'release') | 336 result.Add('mode', 'compilation mode (debug, release)', 'release') |
| 322 result.Add('sample', 'build sample (shell, process)', '') | 337 result.Add('sample', 'build sample (shell, process)', '') |
| 323 result.Add('env', 'override environment settings (NAME1:value1,NAME2:value2)',
'') | 338 result.Add('env', 'override environment settings (NAME1:value1,NAME2:value2)',
'') |
| 324 for (name, option) in SIMPLE_OPTIONS.iteritems(): | 339 for (name, option) in SIMPLE_OPTIONS.iteritems(): |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 (name, env[name], ", ".join(option['values']))) | 372 (name, env[name], ", ".join(option['values']))) |
| 358 Abort(message) | 373 Abort(message) |
| 359 | 374 |
| 360 | 375 |
| 361 class BuildContext(object): | 376 class BuildContext(object): |
| 362 | 377 |
| 363 def __init__(self, options, env_overrides, samples): | 378 def __init__(self, options, env_overrides, samples): |
| 364 self.library_targets = [] | 379 self.library_targets = [] |
| 365 self.cctest_targets = [] | 380 self.cctest_targets = [] |
| 366 self.sample_targets = [] | 381 self.sample_targets = [] |
| 382 self.d8_targets = [] |
| 367 self.options = options | 383 self.options = options |
| 368 self.env_overrides = env_overrides | 384 self.env_overrides = env_overrides |
| 369 self.samples = samples | 385 self.samples = samples |
| 370 self.use_snapshot = (options['snapshot'] == 'on') | 386 self.use_snapshot = (options['snapshot'] == 'on') |
| 371 self.flags = None | 387 self.flags = None |
| 372 | 388 |
| 373 def AddRelevantFlags(self, initial, flags): | 389 def AddRelevantFlags(self, initial, flags): |
| 374 result = initial.copy() | 390 result = initial.copy() |
| 375 self.AppendFlags(result, flags.get('all')) | 391 self.AppendFlags(result, flags.get('all')) |
| 376 toolchain = self.options['toolchain'] | 392 toolchain = self.options['toolchain'] |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 PostprocessOptions(options) | 456 PostprocessOptions(options) |
| 441 | 457 |
| 442 context = BuildContext(options, env_overrides, samples=SplitList(env['sample']
)) | 458 context = BuildContext(options, env_overrides, samples=SplitList(env['sample']
)) |
| 443 | 459 |
| 444 library_flags = context.AddRelevantFlags(os.environ, LIBRARY_FLAGS) | 460 library_flags = context.AddRelevantFlags(os.environ, LIBRARY_FLAGS) |
| 445 v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS) | 461 v8_flags = context.AddRelevantFlags(library_flags, V8_EXTRA_FLAGS) |
| 446 jscre_flags = context.AddRelevantFlags(library_flags, JSCRE_EXTRA_FLAGS) | 462 jscre_flags = context.AddRelevantFlags(library_flags, JSCRE_EXTRA_FLAGS) |
| 447 dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS) | 463 dtoa_flags = context.AddRelevantFlags(library_flags, DTOA_EXTRA_FLAGS) |
| 448 cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS) | 464 cctest_flags = context.AddRelevantFlags(v8_flags, CCTEST_EXTRA_FLAGS) |
| 449 sample_flags = context.AddRelevantFlags(os.environ, SAMPLE_FLAGS) | 465 sample_flags = context.AddRelevantFlags(os.environ, SAMPLE_FLAGS) |
| 466 d8_flags = context.AddRelevantFlags(library_flags, D8_FLAGS) |
| 450 | 467 |
| 451 context.flags = { | 468 context.flags = { |
| 452 'v8': v8_flags, | 469 'v8': v8_flags, |
| 453 'jscre': jscre_flags, | 470 'jscre': jscre_flags, |
| 454 'dtoa': dtoa_flags, | 471 'dtoa': dtoa_flags, |
| 455 'cctest': cctest_flags, | 472 'cctest': cctest_flags, |
| 456 'sample': sample_flags | 473 'sample': sample_flags, |
| 474 'd8': d8_flags |
| 457 } | 475 } |
| 458 | 476 |
| 459 target_id = mode | 477 target_id = mode |
| 460 suffix = SUFFIXES[target_id] | 478 suffix = SUFFIXES[target_id] |
| 461 library_name = 'v8' + suffix | 479 library_name = 'v8' + suffix |
| 462 env['LIBRARY'] = library_name | 480 env['LIBRARY'] = library_name |
| 463 | 481 |
| 464 # Build the object files by invoking SCons recursively. | 482 # Build the object files by invoking SCons recursively. |
| 465 object_files = env.SConscript( | 483 (object_files, shell_files) = env.SConscript( |
| 466 join('src', 'SConscript'), | 484 join('src', 'SConscript'), |
| 467 build_dir=join('obj', target_id), | 485 build_dir=join('obj', target_id), |
| 468 exports='context', | 486 exports='context', |
| 469 duplicate=False | 487 duplicate=False |
| 470 ) | 488 ) |
| 471 | 489 |
| 472 # Link the object files into a library. | 490 # Link the object files into a library. |
| 473 env.Replace(**context.flags['v8']) | 491 env.Replace(**context.flags['v8']) |
| 474 context.ApplyEnvOverrides(env) | 492 context.ApplyEnvOverrides(env) |
| 475 if context.options['library'] == 'static': | 493 if context.options['library'] == 'static': |
| 476 library = env.StaticLibrary(library_name, object_files) | 494 library = env.StaticLibrary(library_name, object_files) |
| 477 else: | 495 else: |
| 478 # There seems to be a glitch in the way scons decides where to put | 496 # There seems to be a glitch in the way scons decides where to put |
| 479 # PDB files when compiling using MSVC so we specify it manually. | 497 # PDB files when compiling using MSVC so we specify it manually. |
| 480 # This should not affect any other platforms. | 498 # This should not affect any other platforms. |
| 481 pdb_name = library_name + '.dll.pdb' | 499 pdb_name = library_name + '.dll.pdb' |
| 482 library = env.SharedLibrary(library_name, object_files, PDB=pdb_name) | 500 library = env.SharedLibrary(library_name, object_files, PDB=pdb_name) |
| 483 context.library_targets.append(library) | 501 context.library_targets.append(library) |
| 484 | 502 |
| 503 d8_env = Environment() |
| 504 d8_env.Replace(**context.flags['d8']) |
| 505 shell = d8_env.Program('d8' + suffix, object_files + shell_files) |
| 506 context.d8_targets.append(shell) |
| 507 |
| 485 for sample in context.samples: | 508 for sample in context.samples: |
| 486 sample_env = Environment(LIBRARY=library_name) | 509 sample_env = Environment(LIBRARY=library_name) |
| 487 sample_env.Replace(**context.flags['sample']) | 510 sample_env.Replace(**context.flags['sample']) |
| 488 context.ApplyEnvOverrides(sample_env) | 511 context.ApplyEnvOverrides(sample_env) |
| 489 sample_object = sample_env.SConscript( | 512 sample_object = sample_env.SConscript( |
| 490 join('samples', 'SConscript'), | 513 join('samples', 'SConscript'), |
| 491 build_dir=join('obj', 'sample', sample, target_id), | 514 build_dir=join('obj', 'sample', sample, target_id), |
| 492 exports='sample context', | 515 exports='sample context', |
| 493 duplicate=False | 516 duplicate=False |
| 494 ) | 517 ) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 507 | 530 |
| 508 return context | 531 return context |
| 509 | 532 |
| 510 | 533 |
| 511 def Build(): | 534 def Build(): |
| 512 opts = GetOptions() | 535 opts = GetOptions() |
| 513 env = Environment(options=opts) | 536 env = Environment(options=opts) |
| 514 Help(opts.GenerateHelpText(env)) | 537 Help(opts.GenerateHelpText(env)) |
| 515 VerifyOptions(env) | 538 VerifyOptions(env) |
| 516 env_overrides = ParseEnvOverrides(env['env']) | 539 env_overrides = ParseEnvOverrides(env['env']) |
| 517 | 540 |
| 518 SourceSignatures(env['sourcesignatures']) | 541 SourceSignatures(env['sourcesignatures']) |
| 519 | 542 |
| 520 libraries = [] | 543 libraries = [] |
| 521 cctests = [] | 544 cctests = [] |
| 522 samples = [] | 545 samples = [] |
| 546 d8s = [] |
| 523 modes = SplitList(env['mode']) | 547 modes = SplitList(env['mode']) |
| 524 for mode in modes: | 548 for mode in modes: |
| 525 context = BuildSpecific(env.Copy(), mode, env_overrides) | 549 context = BuildSpecific(env.Copy(), mode, env_overrides) |
| 526 libraries += context.library_targets | 550 libraries += context.library_targets |
| 527 cctests += context.cctest_targets | 551 cctests += context.cctest_targets |
| 528 samples += context.sample_targets | 552 samples += context.sample_targets |
| 553 d8s += context.d8_targets |
| 529 | 554 |
| 530 env.Alias('library', libraries) | 555 env.Alias('library', libraries) |
| 531 env.Alias('cctests', cctests) | 556 env.Alias('cctests', cctests) |
| 532 env.Alias('sample', samples) | 557 env.Alias('sample', samples) |
| 558 env.Alias('d8', d8s) |
| 533 | 559 |
| 534 if env['sample']: | 560 if env['sample']: |
| 535 env.Default('sample') | 561 env.Default('sample') |
| 536 else: | 562 else: |
| 537 env.Default('library') | 563 env.Default('library') |
| 538 | 564 |
| 539 | 565 |
| 540 # We disable deprecation warnings because we need to be able to use | 566 # We disable deprecation warnings because we need to be able to use |
| 541 # env.Copy without getting warnings for compatibility with older | 567 # env.Copy without getting warnings for compatibility with older |
| 542 # version of scons. Also, there's a bug in some revisions that | 568 # version of scons. Also, there's a bug in some revisions that |
| 543 # doesn't allow this flag to be set, so we swallow any exceptions. | 569 # doesn't allow this flag to be set, so we swallow any exceptions. |
| 544 # Lovely. | 570 # Lovely. |
| 545 try: | 571 try: |
| 546 SetOption('warn', 'no-deprecated') | 572 SetOption('warn', 'no-deprecated') |
| 547 except: | 573 except: |
| 548 pass | 574 pass |
| 549 | 575 |
| 550 | 576 |
| 551 Build() | 577 Build() |
| OLD | NEW |