| 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 } |
| 195 }, | 200 }, |
| 196 'os:macos': { | 201 'os:macos': { |
| 197 'WARNINGFLAGS': ['-pedantic'] | 202 'WARNINGFLAGS': ['-pedantic'] |
| 198 }, | 203 }, |
| 199 'disassembler:on': { | 204 'disassembler:on': { |
| 200 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] | 205 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] |
| 201 } | 206 } |
| 202 }, | 207 }, |
| 203 'msvc': { | 208 'msvc': { |
| 204 'all': { | 209 'all': { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 'prof': { | 468 'prof': { |
| 464 'values': ['on', 'off', 'oprofile'], | 469 'values': ['on', 'off', 'oprofile'], |
| 465 'default': 'off', | 470 'default': 'off', |
| 466 'help': 'enable profiling of build target' | 471 'help': 'enable profiling of build target' |
| 467 }, | 472 }, |
| 468 'library': { | 473 'library': { |
| 469 'values': ['static', 'shared'], | 474 'values': ['static', 'shared'], |
| 470 'default': 'static', | 475 'default': 'static', |
| 471 'help': 'the type of library to produce' | 476 'help': 'the type of library to produce' |
| 472 }, | 477 }, |
| 478 'soname': { |
| 479 'values': ['on', 'off'], |
| 480 'default': 'off', |
| 481 'help': 'turn on setting soname for Linux shared library' |
| 482 }, |
| 473 'msvcrt': { | 483 'msvcrt': { |
| 474 'values': ['static', 'shared'], | 484 'values': ['static', 'shared'], |
| 475 'default': 'static', | 485 'default': 'static', |
| 476 'help': 'the type of MSVCRT library to use' | 486 'help': 'the type of MSVCRT library to use' |
| 477 }, | 487 }, |
| 478 'wordsize': { | 488 'wordsize': { |
| 479 'values': ['64', '32'], | 489 'values': ['64', '32'], |
| 480 'default': WORDSIZE_GUESS, | 490 'default': WORDSIZE_GUESS, |
| 481 'help': 'the word size' | 491 'help': 'the word size' |
| 482 }, | 492 }, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 508 result.Add('mode', 'compilation mode (debug, release)', 'release') | 518 result.Add('mode', 'compilation mode (debug, release)', 'release') |
| 509 result.Add('sample', 'build sample (shell, process)', '') | 519 result.Add('sample', 'build sample (shell, process)', '') |
| 510 result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,..
.)', '') | 520 result.Add('env', 'override environment settings (NAME0:value0,NAME1:value1,..
.)', '') |
| 511 result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '') | 521 result.Add('importenv', 'import environment settings (NAME0,NAME1,...)', '') |
| 512 for (name, option) in SIMPLE_OPTIONS.iteritems(): | 522 for (name, option) in SIMPLE_OPTIONS.iteritems(): |
| 513 help = '%s (%s)' % (name, ", ".join(option['values'])) | 523 help = '%s (%s)' % (name, ", ".join(option['values'])) |
| 514 result.Add(name, help, option.get('default')) | 524 result.Add(name, help, option.get('default')) |
| 515 return result | 525 return result |
| 516 | 526 |
| 517 | 527 |
| 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 |
| 518 def SplitList(str): | 571 def SplitList(str): |
| 519 return [ s for s in str.split(",") if len(s) > 0 ] | 572 return [ s for s in str.split(",") if len(s) > 0 ] |
| 520 | 573 |
| 521 | 574 |
| 522 def IsLegal(env, option, values): | 575 def IsLegal(env, option, values): |
| 523 str = env[option] | 576 str = env[option] |
| 524 for s in SplitList(str): | 577 for s in SplitList(str): |
| 525 if not s in values: | 578 if not s in values: |
| 526 Abort("Illegal value for option %s '%s'." % (option, s)) | 579 Abort("Illegal value for option %s '%s'." % (option, s)) |
| 527 return False | 580 return False |
| 528 return True | 581 return True |
| 529 | 582 |
| 530 | 583 |
| 531 def VerifyOptions(env): | 584 def VerifyOptions(env): |
| 532 if not IsLegal(env, 'mode', ['debug', 'release']): | 585 if not IsLegal(env, 'mode', ['debug', 'release']): |
| 533 return False | 586 return False |
| 534 if not IsLegal(env, 'sample', ["shell", "process"]): | 587 if not IsLegal(env, 'sample', ["shell", "process"]): |
| 535 return False | 588 return False |
| 536 if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on'
: | 589 if env['os'] == 'win32' and env['library'] == 'shared' and env['prof'] == 'on'
: |
| 537 Abort("Profiling on windows only supported for static library.") | 590 Abort("Profiling on windows only supported for static library.") |
| 538 if env['prof'] == 'oprofile' and env['os'] != 'linux': | 591 if env['prof'] == 'oprofile' and env['os'] != 'linux': |
| 539 Abort("OProfile is only supported on Linux.") | 592 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.") |
| 540 for (name, option) in SIMPLE_OPTIONS.iteritems(): | 597 for (name, option) in SIMPLE_OPTIONS.iteritems(): |
| 541 if (not option.get('default')) and (name not in ARGUMENTS): | 598 if (not option.get('default')) and (name not in ARGUMENTS): |
| 542 message = ("A value for option %s must be specified (%s)." % | 599 message = ("A value for option %s must be specified (%s)." % |
| 543 (name, ", ".join(option['values']))) | 600 (name, ", ".join(option['values']))) |
| 544 Abort(message) | 601 Abort(message) |
| 545 if not env[name] in option['values']: | 602 if not env[name] in option['values']: |
| 546 message = ("Unknown %s value '%s'. Possible values are (%s)." % | 603 message = ("Unknown %s value '%s'. Possible values are (%s)." % |
| 547 (name, env[name], ", ".join(option['values']))) | 604 (name, env[name], ", ".join(option['values']))) |
| 548 Abort(message) | 605 Abort(message) |
| 549 | 606 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 717 |
| 661 context.flags = { | 718 context.flags = { |
| 662 'v8': v8_flags, | 719 'v8': v8_flags, |
| 663 'mksnapshot': mksnapshot_flags, | 720 'mksnapshot': mksnapshot_flags, |
| 664 'dtoa': dtoa_flags, | 721 'dtoa': dtoa_flags, |
| 665 'cctest': cctest_flags, | 722 'cctest': cctest_flags, |
| 666 'sample': sample_flags, | 723 'sample': sample_flags, |
| 667 'd8': d8_flags | 724 'd8': d8_flags |
| 668 } | 725 } |
| 669 | 726 |
| 727 # Generate library base name. |
| 670 target_id = mode | 728 target_id = mode |
| 671 suffix = SUFFIXES[target_id] | 729 suffix = SUFFIXES[target_id] |
| 672 library_name = 'v8' + suffix | 730 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 |
| 673 env['LIBRARY'] = library_name | 735 env['LIBRARY'] = library_name |
| 674 | 736 |
| 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 |
| 675 # Build the object files by invoking SCons recursively. | 744 # Build the object files by invoking SCons recursively. |
| 676 (object_files, shell_files, mksnapshot) = env.SConscript( | 745 (object_files, shell_files, mksnapshot) = env.SConscript( |
| 677 join('src', 'SConscript'), | 746 join('src', 'SConscript'), |
| 678 build_dir=join('obj', target_id), | 747 build_dir=join('obj', target_id), |
| 679 exports='context', | 748 exports='context', |
| 680 duplicate=False | 749 duplicate=False |
| 681 ) | 750 ) |
| 682 | 751 |
| 683 context.mksnapshot_targets.append(mksnapshot) | 752 context.mksnapshot_targets.append(mksnapshot) |
| 684 | 753 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 # version of scons. Also, there's a bug in some revisions that | 835 # version of scons. Also, there's a bug in some revisions that |
| 767 # doesn't allow this flag to be set, so we swallow any exceptions. | 836 # doesn't allow this flag to be set, so we swallow any exceptions. |
| 768 # Lovely. | 837 # Lovely. |
| 769 try: | 838 try: |
| 770 SetOption('warn', 'no-deprecated') | 839 SetOption('warn', 'no-deprecated') |
| 771 except: | 840 except: |
| 772 pass | 841 pass |
| 773 | 842 |
| 774 | 843 |
| 775 Build() | 844 Build() |
| OLD | NEW |