| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 'arch:arm': { | 184 'arch:arm': { |
| 185 'CPPDEFINES': ['ARM'] | 185 'CPPDEFINES': ['ARM'] |
| 186 }, | 186 }, |
| 187 'arch:android': { | 187 'arch:android': { |
| 188 'CPPDEFINES': ['ARM'] | 188 'CPPDEFINES': ['ARM'] |
| 189 }, | 189 }, |
| 190 'os:win32': { | 190 'os:win32': { |
| 191 'WARNINGFLAGS': ['-pedantic', '-Wno-long-long'] | 191 'WARNINGFLAGS': ['-pedantic', '-Wno-long-long'] |
| 192 }, | 192 }, |
| 193 'os:linux': { | 193 'os:linux': { |
| 194 'WARNINGFLAGS': ['-pedantic'], | 194 'WARNINGFLAGS': ['-pedantic'] |
| 195 'library:shared': { | |
| 196 'soname:on': { | |
| 197 'LINKFLAGS': ['-Wl,-soname,${SONAME}'] | |
| 198 } | |
| 199 } | |
| 200 }, | 195 }, |
| 201 'os:macos': { | 196 'os:macos': { |
| 202 'WARNINGFLAGS': ['-pedantic'] | 197 'WARNINGFLAGS': ['-pedantic'] |
| 203 }, | 198 }, |
| 204 'disassembler:on': { | 199 'disassembler:on': { |
| 205 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] | 200 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] |
| 206 } | 201 } |
| 207 }, | 202 }, |
| 208 'msvc': { | 203 'msvc': { |
| 209 'all': { | 204 'all': { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 'prof': { | 463 'prof': { |
| 469 'values': ['on', 'off', 'oprofile'], | 464 'values': ['on', 'off', 'oprofile'], |
| 470 'default': 'off', | 465 'default': 'off', |
| 471 'help': 'enable profiling of build target' | 466 'help': 'enable profiling of build target' |
| 472 }, | 467 }, |
| 473 'library': { | 468 'library': { |
| 474 'values': ['static', 'shared'], | 469 'values': ['static', 'shared'], |
| 475 'default': 'static', | 470 'default': 'static', |
| 476 'help': 'the type of library to produce' | 471 'help': 'the type of library to produce' |
| 477 }, | 472 }, |
| 478 'soname': { | |
| 479 'values': ['on', 'off'], | |
| 480 'default': 'off', | |
| 481 'help': 'turn on setting soname for Linux shared library' | |
| 482 }, | |
| 483 'msvcrt': { | 473 'msvcrt': { |
| 484 'values': ['static', 'shared'], | 474 'values': ['static', 'shared'], |
| 485 'default': 'static', | 475 'default': 'static', |
| 486 'help': 'the type of MSVCRT library to use' | 476 'help': 'the type of MSVCRT library to use' |
| 487 }, | 477 }, |
| 488 'wordsize': { | 478 'wordsize': { |
| 489 'values': ['64', '32'], | 479 'values': ['64', '32'], |
| 490 'default': WORDSIZE_GUESS, | 480 'default': WORDSIZE_GUESS, |
| 491 'help': 'the word size' | 481 'help': 'the word size' |
| 492 }, | 482 }, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 518 result.Add('mode', 'compilation mode (debug, release)', 'release') | 508 result.Add('mode', 'compilation mode (debug, release)', 'release') |
| 519 result.Add('sample', 'build sample (shell, process)', '') | 509 result.Add('sample', 'build sample (shell, process)', '') |
| 520 result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,..
.)', '') | 510 result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,..
.)', '') |
| 521 result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '') | 511 result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '') |
| 522 for (name, option) in SIMPLE_OPTIONS.iteritems(): | 512 for (name, option) in SIMPLE_OPTIONS.iteritems(): |
| 523 help = '%s (%s)' % (name, ", ".join(option['values'])) | 513 help = '%s (%s)' % (name, ", ".join(option['values'])) |
| 524 result.Add(name, help, option.get('default')) | 514 result.Add(name, help, option.get('default')) |
| 525 return result | 515 return result |
| 526 | 516 |
| 527 | 517 |
| 528 def GetVersionComponents(): | |
| 529 MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)") | |
| 530 MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)") | |
| 531 BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)") | |
| 532 PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)") | |
| 533 | |
| 534 patterns = [MAJOR_VERSION_PATTERN, | |
| 535 MINOR_VERSION_PATTERN, | |
| 536 BUILD_NUMBER_PATTERN, | |
| 537 PATCH_LEVEL_PATTERN] | |
| 538 | |
| 539 source = open(join(root_dir, 'src', 'version.cc')).read() | |
| 540 version_components = [] | |
| 541 for pattern in patterns: | |
| 542 match = pattern.search(source) | |
| 543 if match: | |
| 544 version_components.append(match.group(1).strip()) | |
| 545 else: | |
| 546 version_components.append('0') | |
| 547 | |
| 548 return version_components | |
| 549 | |
| 550 | |
| 551 def GetVersion(): | |
| 552 version_components = GetVersionComponents() | |
| 553 | |
| 554 if version_components[len(version_components) - 1] == '0': | |
| 555 version_components.pop() | |
| 556 return '.'.join(version_components) | |
| 557 | |
| 558 | |
| 559 def GetSpecificSONAME(): | |
| 560 SONAME_PATTERN = re.compile(r"#define\s+SONAME\s+\"(.*)\"") | |
| 561 | |
| 562 source = open(join(root_dir, 'src', 'version.cc')).read() | |
| 563 match = SONAME_PATTERN.search(source) | |
| 564 | |
| 565 if match: | |
| 566 return match.group(1).strip() | |
| 567 else: | |
| 568 return '' | |
| 569 | |
| 570 | |
| 571 def SplitList(str): | 518 def SplitList(str): |
| 572 return [ s for s in str.split(",") if len(s) > 0 ] | 519 return [ s for s in str.split(",") if len(s) > 0 ] |
| 573 | 520 |
| 574 | 521 |
| 575 def IsLegal(env, option, values): | 522 def IsLegal(env, option, values): |
| 576 str = env[option] | 523 str = env[option] |
| 577 for s in SplitList(str): | 524 for s in SplitList(str): |
| 578 if not s in values: | 525 if not s in values: |
| 579 Abort("Illegal value for option %s '%s'." % (option, s)) | 526 Abort("Illegal value for option %s '%s'." % (option, s)) |
| 580 return False | 527 return False |
| 581 return True | 528 return True |
| 582 | 529 |
| 583 | 530 |
| 584 def VerifyOptions(env): | 531 def VerifyOptions(env): |
| 585 if not IsLegal(env, 'mode', ['debug', 'release']): | 532 if not IsLegal(env, 'mode', ['debug', 'release']): |
| 586 return False | 533 return False |
| 587 if not IsLegal(env, 'sample', ["shell", "process"]): | 534 if not IsLegal(env, 'sample', ["shell", "process"]): |
| 588 return False | 535 return False |
| 589 if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on'
: | 536 if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on'
: |
| 590 Abort("Profiling on windows only supported for static library.") | 537 Abort("Profiling on windows only supported for static library.") |
| 591 if env['prof'] == 'oprofile' and env['os'] != 'linux': | 538 if env['prof'] == 'oprofile' and env['os'] != 'linux': |
| 592 Abort("OProfile is only supported on Linux.") | 539 Abort("OProfile is only supported on Linux.") |
| 593 if env['os'] == 'win32' and env['soname'] == 'on': | |
| 594 Abort("Shared Object soname not applicable for Windows.") | |
| 595 if env['soname'] == 'on' and env['library'] == 'static': | |
| 596 Abort("Shared Object soname not applicable for static library.") | |
| 597 for (name, option) in SIMPLE_OPTIONS.iteritems(): | 540 for (name, option) in SIMPLE_OPTIONS.iteritems(): |
| 598 if (not option.get('default')) and (name not in ARGUMENTS): | 541 if (not option.get('default')) and (name not in ARGUMENTS): |
| 599 message = ("A value for option %s must be specified (%s)." % | 542 message = ("A value for option %s must be specified (%s)." % |
| 600 (name, ", ".join(option['values']))) | 543 (name, ", ".join(option['values']))) |
| 601 Abort(message) | 544 Abort(message) |
| 602 if not env[name] in option['values']: | 545 if not env[name] in option['values']: |
| 603 message = ("Unknown %s value '%s'. Possible values are (%s)." % | 546 message = ("Unknown %s value '%s'. Possible values are (%s)." % |
| 604 (name, env[name], ", ".join(option['values']))) | 547 (name, env[name], ", ".join(option['values']))) |
| 605 Abort(message) | 548 Abort(message) |
| 606 | 549 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 | 660 |
| 718 context.flags = { | 661 context.flags = { |
| 719 'v8': v8_flags, | 662 'v8': v8_flags, |
| 720 'mksnapshot': mksnapshot_flags, | 663 'mksnapshot': mksnapshot_flags, |
| 721 'dtoa': dtoa_flags, | 664 'dtoa': dtoa_flags, |
| 722 'cctest': cctest_flags, | 665 'cctest': cctest_flags, |
| 723 'sample': sample_flags, | 666 'sample': sample_flags, |
| 724 'd8': d8_flags | 667 'd8': d8_flags |
| 725 } | 668 } |
| 726 | 669 |
| 727 # Generate library base name. | |
| 728 target_id = mode | 670 target_id = mode |
| 729 suffix = SUFFIXES[target_id] | 671 suffix = SUFFIXES[target_id] |
| 730 library_name = 'v8' + suffix | 672 library_name = 'v8' + suffix |
| 731 version = GetVersion() | |
| 732 if context.options['soname'] == 'on': | |
| 733 # When building shared object with SONAME version the library name. | |
| 734 library_name += '-' + version | |
| 735 env['LIBRARY'] = library_name | 673 env['LIBRARY'] = library_name |
| 736 | 674 |
| 737 # Generate library SONAME if required by the build. | |
| 738 if context.options['soname'] == 'on': | |
| 739 soname = GetSpecificSONAME() | |
| 740 if soname == '': | |
| 741 soname = 'lib' + library_name + '.so' | |
| 742 env['SONAME'] = soname | |
| 743 | |
| 744 # Build the object files by invoking SCons recursively. | 675 # Build the object files by invoking SCons recursively. |
| 745 (object_files, shell_files, mksnapshot) = env.SConscript( | 676 (object_files, shell_files, mksnapshot) = env.SConscript( |
| 746 join('src', 'SConscript'), | 677 join('src', 'SConscript'), |
| 747 build_dir=join('obj', target_id), | 678 build_dir=join('obj', target_id), |
| 748 exports='context', | 679 exports='context', |
| 749 duplicate=False | 680 duplicate=False |
| 750 ) | 681 ) |
| 751 | 682 |
| 752 context.mksnapshot_targets.append(mksnapshot) | 683 context.mksnapshot_targets.append(mksnapshot) |
| 753 | 684 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 # version of scons. Also, there's a bug in some revisions that | 766 # version of scons. Also, there's a bug in some revisions that |
| 836 # doesn't allow this flag to be set, so we swallow any exceptions. | 767 # doesn't allow this flag to be set, so we swallow any exceptions. |
| 837 # Lovely. | 768 # Lovely. |
| 838 try: | 769 try: |
| 839 SetOption('warn', 'no-deprecated') | 770 SetOption('warn', 'no-deprecated') |
| 840 except: | 771 except: |
| 841 pass | 772 pass |
| 842 | 773 |
| 843 | 774 |
| 844 Build() | 775 Build() |
| OLD | NEW |