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 os | 7 import os |
8 import platform | 8 import platform |
9 import re | 9 import re |
10 import subprocess | 10 import subprocess |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 # (arch, subarch) pair | 1100 # (arch, subarch) pair |
1101 AVAILABLE_PLATFORMS = { | 1101 AVAILABLE_PLATFORMS = { |
1102 'x86-32' : { 'arch' : 'x86' , 'subarch' : '32' }, | 1102 'x86-32' : { 'arch' : 'x86' , 'subarch' : '32' }, |
1103 'x86-64' : { 'arch' : 'x86' , 'subarch' : '64' }, | 1103 'x86-64' : { 'arch' : 'x86' , 'subarch' : '64' }, |
1104 'mips32' : { 'arch' : 'mips', 'subarch' : '32' }, | 1104 'mips32' : { 'arch' : 'mips', 'subarch' : '32' }, |
1105 'arm' : { 'arch' : 'arm' , 'subarch' : '32' }, | 1105 'arm' : { 'arch' : 'arm' , 'subarch' : '32' }, |
1106 'arm-thumb2' : { 'arch' : 'arm' , 'subarch' : '32' } | 1106 'arm-thumb2' : { 'arch' : 'arm' , 'subarch' : '32' } |
1107 } | 1107 } |
1108 | 1108 |
1109 # Look up the platform name from the command line arguments. | 1109 # Look up the platform name from the command line arguments. |
1110 def GetPlatform(): | 1110 def GetPlatform(self): |
1111 return ARGUMENTS.get('platform', 'x86-32') | 1111 return ARGUMENTS.get('platform', 'x86-32') |
1112 | 1112 |
| 1113 pre_base_env.AddMethod(GetPlatform) |
1113 | 1114 |
1114 # Decode platform into list [ ARCHITECTURE , EXEC_MODE ]. | 1115 # Decode platform into list [ ARCHITECTURE , EXEC_MODE ]. |
1115 def DecodePlatform(platform): | 1116 def DecodePlatform(platform): |
1116 if platform in AVAILABLE_PLATFORMS: | 1117 if platform in AVAILABLE_PLATFORMS: |
1117 return AVAILABLE_PLATFORMS[platform] | 1118 return AVAILABLE_PLATFORMS[platform] |
1118 raise Exception('Unrecognized platform: %s' % platform) | 1119 raise Exception('Unrecognized platform: %s' % platform) |
1119 | 1120 |
1120 | 1121 |
1121 DeclareBit('build_x86_32', 'Building binaries for the x86-32 architecture', | 1122 DeclareBit('build_x86_32', 'Building binaries for the x86-32 architecture', |
1122 exclusive_groups='build_arch') | 1123 exclusive_groups='build_arch') |
(...skipping 22 matching lines...) Expand all Loading... |
1145 DeclareBit('build_x86', 'Building binaries for the x86 architecture') | 1146 DeclareBit('build_x86', 'Building binaries for the x86 architecture') |
1146 DeclareBit('target_x86', 'Tools being built will process x86 binaries') | 1147 DeclareBit('target_x86', 'Tools being built will process x86 binaries') |
1147 | 1148 |
1148 # Shorthand for either arm or thumb2 versions of ARM | 1149 # Shorthand for either arm or thumb2 versions of ARM |
1149 DeclareBit('build_arm', 'Building binaries for the arm architecture') | 1150 DeclareBit('build_arm', 'Building binaries for the arm architecture') |
1150 DeclareBit('target_arm', 'Tools being built will process arm binaries') | 1151 DeclareBit('target_arm', 'Tools being built will process arm binaries') |
1151 | 1152 |
1152 | 1153 |
1153 def MakeArchSpecificEnv(): | 1154 def MakeArchSpecificEnv(): |
1154 env = pre_base_env.Clone() | 1155 env = pre_base_env.Clone() |
1155 platform = GetPlatform() | 1156 platform = env.GetPlatform() |
1156 info = DecodePlatform(platform) | 1157 info = DecodePlatform(platform) |
1157 | 1158 |
1158 env.Replace(BUILD_FULLARCH=platform) | 1159 env.Replace(BUILD_FULLARCH=platform) |
1159 env.Replace(BUILD_ARCHITECTURE=info['arch']) | 1160 env.Replace(BUILD_ARCHITECTURE=info['arch']) |
1160 env.Replace(BUILD_SUBARCH=info['subarch']) | 1161 env.Replace(BUILD_SUBARCH=info['subarch']) |
1161 env.Replace(TARGET_FULLARCH=platform) | 1162 env.Replace(TARGET_FULLARCH=platform) |
1162 env.Replace(TARGET_ARCHITECTURE=info['arch']) | 1163 env.Replace(TARGET_ARCHITECTURE=info['arch']) |
1163 env.Replace(TARGET_SUBARCH=info['subarch']) | 1164 env.Replace(TARGET_SUBARCH=info['subarch']) |
1164 | 1165 |
1165 # Example: PlatformBit('build', 'x86-32') -> build_x86_32 | 1166 # Example: PlatformBit('build', 'x86-32') -> build_x86_32 |
1166 def PlatformBit(prefix, platform): | 1167 def PlatformBit(prefix, platform): |
1167 return "%s_%s" % (prefix, platform.replace('-', '_')) | 1168 return "%s_%s" % (prefix, platform.replace('-', '_')) |
1168 | 1169 |
1169 env.SetBits(PlatformBit('build', platform)) | 1170 env.SetBits(PlatformBit('build', platform)) |
1170 env.SetBits(PlatformBit('target', platform)) | 1171 env.SetBits(PlatformBit('target', platform)) |
1171 | 1172 |
1172 if env.Bit('build_x86_32') or env.Bit('build_x86_64'): | 1173 if env.Bit('build_x86_32') or env.Bit('build_x86_64'): |
1173 env.SetBits('build_x86') | 1174 env.SetBits('build_x86') |
1174 if env.Bit('build_arm_arm') or env.Bit('build_arm_thumb2'): | 1175 if env.Bit('build_arm_arm') or env.Bit('build_arm_thumb2'): |
1175 env.SetBits('build_arm') | 1176 env.SetBits('build_arm') |
1176 | 1177 |
1177 if env.Bit('target_x86_32') or env.Bit('target_x86_64'): | 1178 if env.Bit('target_x86_32') or env.Bit('target_x86_64'): |
1178 env.SetBits('target_x86') | 1179 env.SetBits('target_x86') |
1179 if env.Bit('target_arm_arm') or env.Bit('target_arm_thumb2'): | 1180 if env.Bit('target_arm_arm') or env.Bit('target_arm_thumb2'): |
1180 env.SetBits('target_arm') | 1181 env.SetBits('target_arm') |
1181 | 1182 |
1182 env.Replace(BUILD_ISA_NAME=GetPlatform()) | 1183 env.Replace(BUILD_ISA_NAME=env.GetPlatform()) |
1183 | 1184 |
1184 if env.Bit('target_arm') or env.Bit('target_mips32'): | 1185 if env.Bit('target_arm') or env.Bit('target_mips32'): |
1185 if not env.Bit('native_code'): | 1186 if not env.Bit('native_code'): |
1186 # This is a silent default on ARM and MIPS. | 1187 # This is a silent default on ARM and MIPS. |
1187 env.SetBits('bitcode') | 1188 env.SetBits('bitcode') |
1188 | 1189 |
1189 # If it's not bitcode, it's native code. | 1190 # If it's not bitcode, it's native code. |
1190 if not env.Bit('bitcode'): | 1191 if not env.Bit('bitcode'): |
1191 env.SetBits('native_code') | 1192 env.SetBits('native_code') |
1192 | 1193 |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2726 elif linux_env.Bit('build_x86_64'): | 2727 elif linux_env.Bit('build_x86_64'): |
2727 linux_env.Prepend( | 2728 linux_env.Prepend( |
2728 CCFLAGS = ['-m64'], | 2729 CCFLAGS = ['-m64'], |
2729 LINKFLAGS = ['-m64'], | 2730 LINKFLAGS = ['-m64'], |
2730 ) | 2731 ) |
2731 elif linux_env.Bit('build_arm'): | 2732 elif linux_env.Bit('build_arm'): |
2732 SetupLinuxEnvArm(linux_env) | 2733 SetupLinuxEnvArm(linux_env) |
2733 elif linux_env.Bit('build_mips32'): | 2734 elif linux_env.Bit('build_mips32'): |
2734 SetupLinuxEnvMips(linux_env) | 2735 SetupLinuxEnvMips(linux_env) |
2735 else: | 2736 else: |
2736 Banner('Strange platform: %s' % GetPlatform()) | 2737 Banner('Strange platform: %s' % env.GetPlatform()) |
2737 | 2738 |
2738 # These are desireable options for every Linux platform: | 2739 # These are desireable options for every Linux platform: |
2739 # _FORTIFY_SOURCE: general paranoia "hardening" option for library functions | 2740 # _FORTIFY_SOURCE: general paranoia "hardening" option for library functions |
2740 # -fPIE/-pie: create a position-independent executable | 2741 # -fPIE/-pie: create a position-independent executable |
2741 # relro/now: "hardening" options for linking | 2742 # relro/now: "hardening" options for linking |
2742 # noexecstack: ensure that the executable does not get a PT_GNU_STACK | 2743 # noexecstack: ensure that the executable does not get a PT_GNU_STACK |
2743 # header that causes the kernel to set the READ_IMPLIES_EXEC | 2744 # header that causes the kernel to set the READ_IMPLIES_EXEC |
2744 # personality flag, which disables NX page protection. | 2745 # personality flag, which disables NX page protection. |
2745 linux_env.Prepend( | 2746 linux_env.Prepend( |
2746 CPPDEFINES=[['-D_FORTIFY_SOURCE', '2']], | 2747 CPPDEFINES=[['-D_FORTIFY_SOURCE', '2']], |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3484 # The ComponentProgram method (site_scons/site_tools/component_builders.py) | 3485 # The ComponentProgram method (site_scons/site_tools/component_builders.py) |
3485 # adds dependencies on env['IMPLICIT_LIBS'] if that's set. | 3486 # adds dependencies on env['IMPLICIT_LIBS'] if that's set. |
3486 if env.Bit('bitcode'): | 3487 if env.Bit('bitcode'): |
3487 implicit_libs += ['libnacl.a'] | 3488 implicit_libs += ['libnacl.a'] |
3488 else: | 3489 else: |
3489 implicit_libs += ['crt1.o', | 3490 implicit_libs += ['crt1.o', |
3490 'libnacl.a', | 3491 'libnacl.a', |
3491 'crti.o', | 3492 'crti.o', |
3492 'crtn.o'] | 3493 'crtn.o'] |
3493 # TODO(mcgrathr): multilib nonsense defeats -B! figure out a better way. | 3494 # TODO(mcgrathr): multilib nonsense defeats -B! figure out a better way. |
3494 if GetPlatform() == 'x86-32': | 3495 if env.GetPlatform() == 'x86-32': |
3495 implicit_libs.append(os.path.join('32', 'crt1.o')) | 3496 implicit_libs.append(os.path.join('32', 'crt1.o')) |
3496 | 3497 |
3497 if implicit_libs != []: | 3498 if implicit_libs != []: |
3498 env['IMPLICIT_LIBS'] = [env.File(os.path.join('${LIB_DIR}', file)) | 3499 env['IMPLICIT_LIBS'] = [env.File(os.path.join('${LIB_DIR}', file)) |
3499 for file in implicit_libs] | 3500 for file in implicit_libs] |
3500 # The -B<dir>/ flag is necessary to tell gcc to look for crt[1in].o there. | 3501 # The -B<dir>/ flag is necessary to tell gcc to look for crt[1in].o there. |
3501 env.Prepend(LINKFLAGS=['-B${LIB_DIR}/']) | 3502 env.Prepend(LINKFLAGS=['-B${LIB_DIR}/']) |
3502 | 3503 |
3503 AddImplicitLibs(nacl_env) | 3504 AddImplicitLibs(nacl_env) |
3504 AddImplicitLibs(nacl_irt_env) | 3505 AddImplicitLibs(nacl_irt_env) |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3771 nacl_env.ValidateSdk() | 3772 nacl_env.ValidateSdk() |
3772 | 3773 |
3773 if BROKEN_TEST_COUNT > 0: | 3774 if BROKEN_TEST_COUNT > 0: |
3774 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 3775 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
3775 if GetOption('brief_comstr'): | 3776 if GetOption('brief_comstr'): |
3776 msg += " Add --verbose to the command line for more information." | 3777 msg += " Add --verbose to the command line for more information." |
3777 print msg | 3778 print msg |
3778 | 3779 |
3779 # separate warnings from actual build output | 3780 # separate warnings from actual build output |
3780 Banner('B U I L D - O U T P U T:') | 3781 Banner('B U I L D - O U T P U T:') |
OLD | NEW |