| OLD | NEW | 
|---|
| 1 #! -*- python -*- | 1 #! -*- python -*- | 
| 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be | 
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. | 
| 5 | 5 | 
| 6 import atexit | 6 import atexit | 
| 7 import glob | 7 import glob | 
| 8 import os | 8 import os | 
| 9 import platform | 9 import platform | 
| 10 import shutil | 10 import shutil | 
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 871 #. | 871 #. | 
| 872 # We have "build" and "target" platforms for the non nacl environments | 872 # We have "build" and "target" platforms for the non nacl environments | 
| 873 # which govern service runtime, validator, etc. | 873 # which govern service runtime, validator, etc. | 
| 874 # | 874 # | 
| 875 # "build" means the  platform the code is running on | 875 # "build" means the  platform the code is running on | 
| 876 # "target" means the platform the validator is checking for. | 876 # "target" means the platform the validator is checking for. | 
| 877 # Typically they are the same but testing it useful to have flexibility. | 877 # Typically they are the same but testing it useful to have flexibility. | 
| 878 # | 878 # | 
| 879 # Various variables in the scons environment are related to this, e.g. | 879 # Various variables in the scons environment are related to this, e.g. | 
| 880 # | 880 # | 
| 881 # BUILD_ARCH: (arm, x86) | 881 # BUILD_ARCH: (arm, mips, x86) | 
| 882 # BUILD_SUBARCH: (32, 64) | 882 # BUILD_SUBARCH: (32, 64) | 
| 883 # | 883 # | 
| 884 # The settings can be controlled using scons command line variables: | 884 # The settings can be controlled using scons command line variables: | 
| 885 # | 885 # | 
| 886 # | 886 # | 
| 887 # buildplatform=: controls the build platform | 887 # buildplatform=: controls the build platform | 
| 888 # targetplatform=: controls the target platform | 888 # targetplatform=: controls the target platform | 
| 889 # platform=: controls both | 889 # platform=: controls both | 
| 890 # | 890 # | 
| 891 # This dictionary is used to translate from a platform name to a | 891 # This dictionary is used to translate from a platform name to a | 
| 892 # (arch, subarch) pair | 892 # (arch, subarch) pair | 
| 893 AVAILABLE_PLATFORMS = { | 893 AVAILABLE_PLATFORMS = { | 
| 894     'x86-32'      : { 'arch' : 'x86' , 'subarch' : '32' }, | 894     'x86-32'      : { 'arch' : 'x86' , 'subarch' : '32' }, | 
| 895     'x86-64'      : { 'arch' : 'x86' , 'subarch' : '64' }, | 895     'x86-64'      : { 'arch' : 'x86' , 'subarch' : '64' }, | 
|  | 896     'mips32'      : { 'arch' : 'mips', 'subarch' : '32' }, | 
| 896     'arm'         : { 'arch' : 'arm' , 'subarch' : '32' }, | 897     'arm'         : { 'arch' : 'arm' , 'subarch' : '32' }, | 
| 897     'arm-thumb2'  : { 'arch' : 'arm' , 'subarch' : '32' } | 898     'arm-thumb2'  : { 'arch' : 'arm' , 'subarch' : '32' } | 
| 898     } | 899     } | 
| 899 | 900 | 
| 900 # Look up the platform name from the command line arguments, | 901 # Look up the platform name from the command line arguments, | 
| 901 # defaulting to 'platform' if needed. | 902 # defaulting to 'platform' if needed. | 
| 902 def GetPlatform(name): | 903 def GetPlatform(name): | 
| 903   platform = ARGUMENTS.get(name) | 904   platform = ARGUMENTS.get(name) | 
| 904   if platform is None: | 905   if platform is None: | 
| 905     return ARGUMENTS.get('platform', 'x86-32') | 906     return ARGUMENTS.get('platform', 'x86-32') | 
| 906   elif ARGUMENTS.get('platform') is None: | 907   elif ARGUMENTS.get('platform') is None: | 
| 907     return platform | 908     return platform | 
| 908   else: | 909   else: | 
| 909     raise Exception('Can\'t specify both %s and %s on the command line' | 910     raise Exception('Can\'t specify both %s and %s on the command line' | 
| 910                     % ('platform', name)) | 911                     % ('platform', name)) | 
| 911 | 912 | 
| 912 | 913 | 
| 913 # Decode platform into list [ ARCHITECTURE , EXEC_MODE ]. | 914 # Decode platform into list [ ARCHITECTURE , EXEC_MODE ]. | 
| 914 def DecodePlatform(platform): | 915 def DecodePlatform(platform): | 
| 915   if platform in AVAILABLE_PLATFORMS: | 916   if platform in AVAILABLE_PLATFORMS: | 
| 916     return AVAILABLE_PLATFORMS[platform] | 917     return AVAILABLE_PLATFORMS[platform] | 
| 917   raise Exception('Unrecognized platform: %s' % platform) | 918   raise Exception('Unrecognized platform: %s' % platform) | 
| 918 | 919 | 
| 919 | 920 | 
| 920 DeclareBit('build_x86_32', 'Building binaries for the x86-32 architecture', | 921 DeclareBit('build_x86_32', 'Building binaries for the x86-32 architecture', | 
| 921            exclusive_groups='build_arch') | 922            exclusive_groups='build_arch') | 
| 922 DeclareBit('build_x86_64', 'Building binaries for the x86-64 architecture', | 923 DeclareBit('build_x86_64', 'Building binaries for the x86-64 architecture', | 
| 923            exclusive_groups='build_arch') | 924            exclusive_groups='build_arch') | 
|  | 925 DeclareBit('build_mips32', 'Building binaries for the MIPS architecture', | 
|  | 926            exclusive_groups='build_arch') | 
| 924 DeclareBit('build_arm_arm', 'Building binaries for the ARM architecture', | 927 DeclareBit('build_arm_arm', 'Building binaries for the ARM architecture', | 
| 925            exclusive_groups='build_arch') | 928            exclusive_groups='build_arch') | 
| 926 DeclareBit('build_arm_thumb2', | 929 DeclareBit('build_arm_thumb2', | 
| 927            'Building binaries for the ARM architecture (thumb2 ISA)', | 930            'Building binaries for the ARM architecture (thumb2 ISA)', | 
| 928            exclusive_groups='build_arch') | 931            exclusive_groups='build_arch') | 
| 929 DeclareBit('target_x86_32', 'Tools being built will process x86-32 binaries', | 932 DeclareBit('target_x86_32', 'Tools being built will process x86-32 binaries', | 
| 930            exclusive_groups='target_arch') | 933            exclusive_groups='target_arch') | 
| 931 DeclareBit('target_x86_64', 'Tools being built will process x86-36 binaries', | 934 DeclareBit('target_x86_64', 'Tools being built will process x86-36 binaries', | 
| 932            exclusive_groups='target_arch') | 935            exclusive_groups='target_arch') | 
|  | 936 DeclareBit('target_mips32', 'Tools being built will process MIPS binaries', | 
|  | 937            exclusive_groups='target_arch') | 
| 933 DeclareBit('target_arm_arm', 'Tools being built will process ARM binaries', | 938 DeclareBit('target_arm_arm', 'Tools being built will process ARM binaries', | 
| 934            exclusive_groups='target_arch') | 939            exclusive_groups='target_arch') | 
| 935 DeclareBit('target_arm_thumb2', | 940 DeclareBit('target_arm_thumb2', | 
| 936            'Tools being built will process ARM binaries (thumb2 ISA)', | 941            'Tools being built will process ARM binaries (thumb2 ISA)', | 
| 937            exclusive_groups='target_arch') | 942            exclusive_groups='target_arch') | 
| 938 | 943 | 
| 939 # Shorthand for either the 32 or 64 bit version of x86. | 944 # Shorthand for either the 32 or 64 bit version of x86. | 
| 940 DeclareBit('build_x86', 'Building binaries for the x86 architecture') | 945 DeclareBit('build_x86', 'Building binaries for the x86 architecture') | 
| 941 DeclareBit('target_x86', 'Tools being built will process x86 binaries') | 946 DeclareBit('target_x86', 'Tools being built will process x86 binaries') | 
| 942 | 947 | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 969   if env.Bit('build_arm_arm') or env.Bit('build_arm_thumb2'): | 974   if env.Bit('build_arm_arm') or env.Bit('build_arm_thumb2'): | 
| 970     env.SetBits('build_arm') | 975     env.SetBits('build_arm') | 
| 971 | 976 | 
| 972   if env.Bit('target_x86_32') or env.Bit('target_x86_64'): | 977   if env.Bit('target_x86_32') or env.Bit('target_x86_64'): | 
| 973     env.SetBits('target_x86') | 978     env.SetBits('target_x86') | 
| 974   if env.Bit('target_arm_arm') or env.Bit('target_arm_thumb2'): | 979   if env.Bit('target_arm_arm') or env.Bit('target_arm_thumb2'): | 
| 975     env.SetBits('target_arm') | 980     env.SetBits('target_arm') | 
| 976 | 981 | 
| 977   env.Replace(BUILD_ISA_NAME=GetPlatform('buildplatform')) | 982   env.Replace(BUILD_ISA_NAME=GetPlatform('buildplatform')) | 
| 978 | 983 | 
| 979   if env.Bit('target_arm') and not env.Bit('native_code'): | 984   if env.Bit('target_arm') or env.Bit('target_mips32'): | 
| 980     # This has always been a silent default on ARM. | 985     if not env.Bit('native_code'): | 
| 981     env.SetBits('bitcode') | 986       # This is a silent default on ARM and MIPS. | 
|  | 987       env.SetBits('bitcode') | 
| 982 | 988 | 
| 983   # If it's not bitcode, it's native code. | 989   # If it's not bitcode, it's native code. | 
| 984   if not env.Bit('bitcode'): | 990   if not env.Bit('bitcode'): | 
| 985     env.SetBits('native_code') | 991     env.SetBits('native_code') | 
| 986 | 992 | 
| 987   # Determine where the object files go | 993   # Determine where the object files go | 
| 988   if BUILD_NAME == TARGET_NAME: | 994   if BUILD_NAME == TARGET_NAME: | 
| 989     BUILD_TARGET_NAME = TARGET_NAME | 995     BUILD_TARGET_NAME = TARGET_NAME | 
| 990   else: | 996   else: | 
| 991     BUILD_TARGET_NAME = '%s-to-%s' % (BUILD_NAME, TARGET_NAME) | 997     BUILD_TARGET_NAME = '%s-to-%s' % (BUILD_NAME, TARGET_NAME) | 
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1117 | 1123 | 
| 1118 | 1124 | 
| 1119 def GetValidator(env, validator): | 1125 def GetValidator(env, validator): | 
| 1120   # NOTE: that the variable TRUSTED_ENV is set by ExportSpecialFamilyVars() | 1126   # NOTE: that the variable TRUSTED_ENV is set by ExportSpecialFamilyVars() | 
| 1121   if 'TRUSTED_ENV' not in env: | 1127   if 'TRUSTED_ENV' not in env: | 
| 1122     return None | 1128     return None | 
| 1123 | 1129 | 
| 1124   if validator is None: | 1130   if validator is None: | 
| 1125     if env.Bit('build_arm'): | 1131     if env.Bit('build_arm'): | 
| 1126       validator = 'arm-ncval-core' | 1132       validator = 'arm-ncval-core' | 
|  | 1133     elif env.Bit('build_mips32'): | 
|  | 1134       validator = 'mips-ncval-core' | 
| 1127     else: | 1135     else: | 
| 1128       validator = 'ncval' | 1136       validator = 'ncval' | 
| 1129 | 1137 | 
| 1130   trusted_env = env['TRUSTED_ENV'] | 1138   trusted_env = env['TRUSTED_ENV'] | 
| 1131   return trusted_env.File('${STAGING_DIR}/${PROGPREFIX}%s${PROGSUFFIX}' % | 1139   return trusted_env.File('${STAGING_DIR}/${PROGPREFIX}%s${PROGSUFFIX}' % | 
| 1132                     validator) | 1140                     validator) | 
| 1133 | 1141 | 
| 1134 | 1142 | 
| 1135 # Perform os.path.abspath rooted at the directory SConstruct resides in. | 1143 # Perform os.path.abspath rooted at the directory SConstruct resides in. | 
| 1136 def SConstructAbsPath(env, path): | 1144 def SConstructAbsPath(env, path): | 
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1749     env.SideEffect(side_effect, node) | 1757     env.SideEffect(side_effect, node) | 
| 1750   # We can't check output if the test is not run. | 1758   # We can't check output if the test is not run. | 
| 1751   if not env.Bit('do_not_run_tests'): | 1759   if not env.Bit('do_not_run_tests'): | 
| 1752     for action in post_actions: | 1760     for action in post_actions: | 
| 1753       env.AddPostAction(node, action) | 1761       env.AddPostAction(node, action) | 
| 1754   return node | 1762   return node | 
| 1755 | 1763 | 
| 1756 pre_base_env.AddMethod(PPAPIBrowserTester) | 1764 pre_base_env.AddMethod(PPAPIBrowserTester) | 
| 1757 | 1765 | 
| 1758 | 1766 | 
| 1759 # Disabled for ARM because Chrome binaries for ARM are not available. | 1767 # Disabled for ARM and MIPS because Chrome binaries for ARM and MIPS are not | 
|  | 1768 # available. | 
| 1760 def PPAPIBrowserTesterIsBroken(env): | 1769 def PPAPIBrowserTesterIsBroken(env): | 
| 1761   return env.Bit('target_arm') or env.Bit('target_arm_thumb2') | 1770   return (env.Bit('target_arm') or env.Bit('target_arm_thumb2') | 
|  | 1771           or env.Bit('target_mips32')) | 
| 1762 | 1772 | 
| 1763 pre_base_env.AddMethod(PPAPIBrowserTesterIsBroken) | 1773 pre_base_env.AddMethod(PPAPIBrowserTesterIsBroken) | 
| 1764 | 1774 | 
| 1765 # 3D is disabled everywhere | 1775 # 3D is disabled everywhere | 
| 1766 def PPAPIGraphics3DIsBroken(env): | 1776 def PPAPIGraphics3DIsBroken(env): | 
| 1767   return True | 1777   return True | 
| 1768 | 1778 | 
| 1769 pre_base_env.AddMethod(PPAPIGraphics3DIsBroken) | 1779 pre_base_env.AddMethod(PPAPIGraphics3DIsBroken) | 
| 1770 | 1780 | 
| 1771 | 1781 | 
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1963   # TODO(mseaborn): Fix by retrying the connection or by adding an | 1973   # TODO(mseaborn): Fix by retrying the connection or by adding an | 
| 1964   # option to ld.so to disable its argv-over-IPC feature. | 1974   # option to ld.so to disable its argv-over-IPC feature. | 
| 1965   if env.Bit('nacl_glibc') and not env.Bit('nacl_static_link'): | 1975   if env.Bit('nacl_glibc') and not env.Bit('nacl_static_link'): | 
| 1966     return [] | 1976     return [] | 
| 1967 | 1977 | 
| 1968   if sel_universal_flags is None: | 1978   if sel_universal_flags is None: | 
| 1969     sel_universal_flags = [] | 1979     sel_universal_flags = [] | 
| 1970 | 1980 | 
| 1971   # When run under qemu, sel_universal must sneak in qemu to the execv | 1981   # When run under qemu, sel_universal must sneak in qemu to the execv | 
| 1972   # call that spawns sel_ldr. | 1982   # call that spawns sel_ldr. | 
| 1973   if env.Bit('target_arm') and env.UsingEmulator(): | 1983   if env.UsingEmulator(): | 
| 1974     sel_universal_flags.append('--command_prefix') | 1984     sel_universal_flags.append('--command_prefix') | 
| 1975     sel_universal_flags.append(GetEmulator(env)) | 1985     sel_universal_flags.append(GetEmulator(env)) | 
| 1976 | 1986 | 
| 1977   if 'TRUSTED_ENV' not in env: | 1987   if 'TRUSTED_ENV' not in env: | 
| 1978     return [] | 1988     return [] | 
| 1979   sel_universal = env['TRUSTED_ENV'].File( | 1989   sel_universal = env['TRUSTED_ENV'].File( | 
| 1980       '${STAGING_DIR}/${PROGPREFIX}sel_universal${PROGSUFFIX}') | 1990       '${STAGING_DIR}/${PROGPREFIX}sel_universal${PROGSUFFIX}') | 
| 1981 | 1991 | 
| 1982   # Point to sel_ldr using an environment variable. | 1992   # Point to sel_ldr using an environment variable. | 
| 1983   sel_ldr = GetSelLdr(env) | 1993   sel_ldr = GetSelLdr(env) | 
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2607       'tests/unittests/shared/platform/build.scons', | 2617       'tests/unittests/shared/platform/build.scons', | 
| 2608       'tests/unittests/trusted/asan/build.scons', | 2618       'tests/unittests/trusted/asan/build.scons', | 
| 2609       'tests/unittests/trusted/platform_qualify/build.scons', | 2619       'tests/unittests/trusted/platform_qualify/build.scons', | 
| 2610       'tests/unittests/trusted/service_runtime/build.scons', | 2620       'tests/unittests/trusted/service_runtime/build.scons', | 
| 2611       'installer/build.scons' | 2621       'installer/build.scons' | 
| 2612       ], ppapi_scons_files['trusted_scons_files']) | 2622       ], ppapi_scons_files['trusted_scons_files']) | 
| 2613     ) | 2623     ) | 
| 2614 | 2624 | 
| 2615   base_env.AddMethod(SDKInstallBin) | 2625   base_env.AddMethod(SDKInstallBin) | 
| 2616 | 2626 | 
| 2617   # The ARM validator can be built for any target that doesn't use ELFCLASS64. | 2627   # The ARM and MIPS validators can be built for any target that doesn't use | 
|  | 2628   # ELFCLASS64. | 
| 2618   if not base_env.Bit('target_x86_64'): | 2629   if not base_env.Bit('target_x86_64'): | 
| 2619     base_env.Append( | 2630     base_env.Append( | 
| 2620         BUILD_SCONSCRIPTS = [ | 2631         BUILD_SCONSCRIPTS = [ | 
| 2621           'src/trusted/validator_arm/build.scons', | 2632           'src/trusted/validator_arm/build.scons', | 
|  | 2633           'src/trusted/validator_mips/build.scons', | 
| 2622         ]) | 2634         ]) | 
| 2623 | 2635 | 
| 2624   base_env.Replace( | 2636   base_env.Replace( | 
| 2625       NACL_BUILD_FAMILY = 'TRUSTED', | 2637       NACL_BUILD_FAMILY = 'TRUSTED', | 
| 2626   ) | 2638   ) | 
| 2627 | 2639 | 
| 2628   # Add optional scons files if present in the directory tree. | 2640   # Add optional scons files if present in the directory tree. | 
| 2629   if os.path.exists(pre_base_env.subst('${MAIN_DIR}/supplement/build.scons')): | 2641   if os.path.exists(pre_base_env.subst('${MAIN_DIR}/supplement/build.scons')): | 
| 2630     base_env.Append(BUILD_SCONSCRIPTS=['${MAIN_DIR}/supplement/build.scons']) | 2642     base_env.Append(BUILD_SCONSCRIPTS=['${MAIN_DIR}/supplement/build.scons']) | 
| 2631 | 2643 | 
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2993                                  '-isystem', | 3005                                  '-isystem', | 
| 2994                                  jail + '/usr/include', | 3006                                  jail + '/usr/include', | 
| 2995                                 ]) | 3007                                 ]) | 
| 2996       # /usr/lib makes sense for most configuration except this one | 3008       # /usr/lib makes sense for most configuration except this one | 
| 2997       # No ARM compatible libs can be found there. | 3009       # No ARM compatible libs can be found there. | 
| 2998       # So this just makes the command lines longer and sometimes results | 3010       # So this just makes the command lines longer and sometimes results | 
| 2999       # in linker warnings referring to this directory. | 3011       # in linker warnings referring to this directory. | 
| 3000       linux_env.FilterOut(LIBPATH=['/usr/lib']) | 3012       linux_env.FilterOut(LIBPATH=['/usr/lib']) | 
| 3001      # This appears to be needed for sel_universal | 3013      # This appears to be needed for sel_universal | 
| 3002     linux_env.Append(LIBS=['dl']) | 3014     linux_env.Append(LIBS=['dl']) | 
|  | 3015   elif linux_env.Bit('build_mips32'): | 
|  | 3016     # TODO(petarj): Add support for MIPS. | 
|  | 3017     pass | 
| 3003   else: | 3018   else: | 
| 3004     Banner('Strange platform: %s' % BUILD_NAME) | 3019     Banner('Strange platform: %s' % BUILD_NAME) | 
| 3005 | 3020 | 
| 3006   # These are desireable options for every Linux platform: | 3021   # These are desireable options for every Linux platform: | 
| 3007   # _FORTIFY_SOURCE: general paranoia "hardening" option for library functions | 3022   # _FORTIFY_SOURCE: general paranoia "hardening" option for library functions | 
| 3008   # -fPIE/-pie: create a position-independent executable | 3023   # -fPIE/-pie: create a position-independent executable | 
| 3009   # relro/now: "hardening" options for linking | 3024   # relro/now: "hardening" options for linking | 
| 3010   # noexecstack: ensure that the executable does not get a PT_GNU_STACK | 3025   # noexecstack: ensure that the executable does not get a PT_GNU_STACK | 
| 3011   #              header that causes the kernel to set the READ_IMPLIES_EXEC | 3026   #              header that causes the kernel to set the READ_IMPLIES_EXEC | 
| 3012   #              personality flag, which disables NX page protection. | 3027   #              personality flag, which disables NX page protection. | 
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3918   nacl_env.ValidateSdk() | 3933   nacl_env.ValidateSdk() | 
| 3919 | 3934 | 
| 3920 if BROKEN_TEST_COUNT > 0: | 3935 if BROKEN_TEST_COUNT > 0: | 
| 3921   msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 3936   msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 
| 3922   if GetOption('brief_comstr'): | 3937   if GetOption('brief_comstr'): | 
| 3923     msg += " Add --verbose to the command line for more information." | 3938     msg += " Add --verbose to the command line for more information." | 
| 3924   print msg | 3939   print msg | 
| 3925 | 3940 | 
| 3926 # separate warnings from actual build output | 3941 # separate warnings from actual build output | 
| 3927 Banner('B U I L D - O U T P U T:') | 3942 Banner('B U I L D - O U T P U T:') | 
| OLD | NEW | 
|---|