| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/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 """NaCl SDK tool SCons.""" | 6 """NaCl SDK tool SCons.""" |
| 7 | 7 |
| 8 import __builtin__ | 8 import __builtin__ |
| 9 import re | 9 import re |
| 10 import os | 10 import os |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 if env.Bit('use_sandboxed_translator'): | 191 if env.Bit('use_sandboxed_translator'): |
| 192 pnacl_translate = os.path.join(translator_root, 'bin', | 192 pnacl_translate = os.path.join(translator_root, 'bin', |
| 193 'pnacl-translate' + binext) | 193 'pnacl-translate' + binext) |
| 194 else: | 194 else: |
| 195 pnacl_translate = binprefix + 'translate' + binext | 195 pnacl_translate = binprefix + 'translate' + binext |
| 196 | 196 |
| 197 pnacl_cc = binprefix + 'clang' + binext | 197 pnacl_cc = binprefix + 'clang' + binext |
| 198 pnacl_cxx = binprefix + 'clang++' + binext | 198 pnacl_cxx = binprefix + 'clang++' + binext |
| 199 | 199 |
| 200 pnacl_ld = binprefix + 'ld' + binext | 200 pnacl_ld = binprefix + 'ld' + binext |
| 201 pnacl_nativeld = binprefix + 'nativeld' + binext | |
| 202 pnacl_disass = binprefix + 'dis' + binext | 201 pnacl_disass = binprefix + 'dis' + binext |
| 203 pnacl_finalize = binprefix + 'finalize' + binext | 202 pnacl_finalize = binprefix + 'finalize' + binext |
| 204 pnacl_strip = binprefix + 'strip' + binext | 203 pnacl_strip = binprefix + 'strip' + binext |
| 205 | 204 |
| 206 # NOTE: XXX_flags start with space for easy concatenation | 205 # NOTE: XXX_flags start with space for easy concatenation |
| 207 # The flags generated here get baked into the commands (CC, CXX, LINK) | 206 # The flags generated here get baked into the commands (CC, CXX, LINK) |
| 208 # instead of CFLAGS etc to keep them from getting blown away by some | 207 # instead of CFLAGS etc to keep them from getting blown away by some |
| 209 # tests. Don't add flags here unless they always need to be preserved. | 208 # tests. Don't add flags here unless they always need to be preserved. |
| 210 pnacl_cxx_flags = '' | 209 pnacl_cxx_flags = '' |
| 211 pnacl_cc_flags = ' -std=gnu99' | 210 pnacl_cc_flags = ' -std=gnu99' |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 SHLIBPREFIX="lib", | 244 SHLIBPREFIX="lib", |
| 246 SHLIBSUFFIX=".so", | 245 SHLIBSUFFIX=".so", |
| 247 OBJSUFFIX=".bc", | 246 OBJSUFFIX=".bc", |
| 248 LINK=pnacl_cxx + ld_arch_flag + pnacl_ld_flags, | 247 LINK=pnacl_cxx + ld_arch_flag + pnacl_ld_flags, |
| 249 # Although we are currently forced to produce native output | 248 # Although we are currently forced to produce native output |
| 250 # for LINK, we are free to produce bitcode for SHLINK | 249 # for LINK, we are free to produce bitcode for SHLINK |
| 251 # (SharedLibrary linking) because scons doesn't do anything | 250 # (SharedLibrary linking) because scons doesn't do anything |
| 252 # with shared libraries except use them with the toolchain. | 251 # with shared libraries except use them with the toolchain. |
| 253 SHLINK=pnacl_cxx + ld_arch_flag + pnacl_ld_flags, | 252 SHLINK=pnacl_cxx + ld_arch_flag + pnacl_ld_flags, |
| 254 LD=pnacl_ld, | 253 LD=pnacl_ld, |
| 255 NATIVELD=pnacl_nativeld, | |
| 256 AR=pnacl_ar, | 254 AR=pnacl_ar, |
| 257 AS=pnacl_as + ld_arch_flag, | 255 AS=pnacl_as + ld_arch_flag, |
| 258 RANLIB=pnacl_ranlib, | 256 RANLIB=pnacl_ranlib, |
| 259 DISASS=pnacl_disass, | 257 DISASS=pnacl_disass, |
| 260 OBJDUMP=pnacl_disass, | 258 OBJDUMP=pnacl_disass, |
| 261 STRIP=pnacl_strip, | 259 STRIP=pnacl_strip, |
| 262 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags, | 260 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags, |
| 263 PNACLFINALIZE=pnacl_finalize, | 261 PNACLFINALIZE=pnacl_finalize, |
| 264 ) | 262 ) |
| 265 | 263 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 281 return | 279 return |
| 282 | 280 |
| 283 env.Replace(OBJSUFFIX='.o', | 281 env.Replace(OBJSUFFIX='.o', |
| 284 SHLIBSUFFIX='.so') | 282 SHLIBSUFFIX='.so') |
| 285 arch_flag = ' -arch ${TARGET_FULLARCH}' | 283 arch_flag = ' -arch ${TARGET_FULLARCH}' |
| 286 cc_flags = ' --pnacl-allow-native --pnacl-allow-translate' | 284 cc_flags = ' --pnacl-allow-native --pnacl-allow-translate' |
| 287 env.Append(CC=arch_flag + cc_flags, | 285 env.Append(CC=arch_flag + cc_flags, |
| 288 CXX=arch_flag + cc_flags, | 286 CXX=arch_flag + cc_flags, |
| 289 ASPP=arch_flag + cc_flags, | 287 ASPP=arch_flag + cc_flags, |
| 290 LINK=cc_flags) # Already has -arch | 288 LINK=cc_flags) # Already has -arch |
| 291 env['LD'] = '${NATIVELD}' + arch_flag | 289 env['LD'] = 'NO-NATIVE-LD-INVOCATION-ALLOWED' |
| 292 env['SHLINK'] = '${LINK}' | 290 env['SHLINK'] = '${LINK}' |
| 293 if env.Bit('built_elsewhere'): | 291 if env.Bit('built_elsewhere'): |
| 294 _StubOutEnvToolsForBuiltElsewhere(env) | 292 _StubOutEnvToolsForBuiltElsewhere(env) |
| 295 | 293 |
| 296 # Get an environment for nacl-gcc when in PNaCl mode. | 294 # Get an environment for nacl-gcc when in PNaCl mode. |
| 297 def PNaClGetNNaClEnv(env): | 295 def PNaClGetNNaClEnv(env): |
| 298 assert(env.Bit('bitcode')) | 296 assert(env.Bit('bitcode')) |
| 299 assert(not env.Bit('target_mips32')) | 297 assert(not env.Bit('target_mips32')) |
| 300 | 298 |
| 301 # This is kind of a hack. We clone the environment, | 299 # This is kind of a hack. We clone the environment, |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 if 'toolchain_feature_version' in SCons.Script.ARGUMENTS: | 677 if 'toolchain_feature_version' in SCons.Script.ARGUMENTS: |
| 680 version = int(SCons.Script.ARGUMENTS['toolchain_feature_version']) | 678 version = int(SCons.Script.ARGUMENTS['toolchain_feature_version']) |
| 681 else: | 679 else: |
| 682 version_file = os.path.join(root, 'FEATURE_VERSION') | 680 version_file = os.path.join(root, 'FEATURE_VERSION') |
| 683 if os.path.exists(version_file): | 681 if os.path.exists(version_file): |
| 684 with open(version_file, 'r') as fh: | 682 with open(version_file, 'r') as fh: |
| 685 version = int(fh.read()) | 683 version = int(fh.read()) |
| 686 else: | 684 else: |
| 687 version = 0 | 685 version = 0 |
| 688 env.Replace(TOOLCHAIN_FEATURE_VERSION=version) | 686 env.Replace(TOOLCHAIN_FEATURE_VERSION=version) |
| OLD | NEW |