| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 if env.Bit('pnacl_generate_pexe'): | 223 if env.Bit('pnacl_generate_pexe'): |
| 224 ld_arch_flag = '' | 224 ld_arch_flag = '' |
| 225 else: | 225 else: |
| 226 ld_arch_flag = arch_flag | 226 ld_arch_flag = arch_flag |
| 227 | 227 |
| 228 if env.Bit('nacl_glibc'): | 228 if env.Bit('nacl_glibc'): |
| 229 subroot = root + '/glibc' | 229 subroot = root + '/glibc' |
| 230 else: | 230 else: |
| 231 subroot = root + '/newlib' | 231 subroot = root + '/newlib' |
| 232 | 232 |
| 233 translator_root = os.path.join(os.path.dirname(root), 'pnacl_translator') |
| 234 |
| 233 binprefix = os.path.join(subroot, 'bin', 'pnacl-') | 235 binprefix = os.path.join(subroot, 'bin', 'pnacl-') |
| 234 binext = '' | 236 binext = '' |
| 235 if env.Bit('host_windows'): | 237 if env.Bit('host_windows'): |
| 236 binext = '.bat' | 238 binext = '.bat' |
| 237 | 239 |
| 238 if env.Bit('nacl_glibc'): | 240 if env.Bit('nacl_glibc'): |
| 239 # TODO(pdox): This bias is needed because runnable-ld is | 241 # TODO(pdox): This bias is needed because runnable-ld is |
| 240 # expected to be in the same directory as the SDK. | 242 # expected to be in the same directory as the SDK. |
| 241 # This assumption should be removed. | 243 # This assumption should be removed. |
| 242 pnacl_lib = os.path.join(root, 'lib-%s' % arch) | 244 pnacl_lib = os.path.join(root, 'lib-%s' % arch) |
| 243 pnacl_extra_lib = os.path.join(subroot, 'lib') | 245 pnacl_extra_lib = os.path.join(subroot, 'lib') |
| 244 else: | 246 else: |
| 245 pnacl_lib = os.path.join(subroot, 'lib') | 247 pnacl_lib = os.path.join(subroot, 'lib') |
| 246 pnacl_extra_lib = '' | 248 pnacl_extra_lib = '' |
| 247 | 249 |
| 248 #TODO(robertm): remove NACL_SDK_INCLUDE ASAP | 250 #TODO(robertm): remove NACL_SDK_INCLUDE ASAP |
| 249 if env.Bit('nacl_glibc'): | 251 if env.Bit('nacl_glibc'): |
| 250 pnacl_include = os.path.join(root, 'glibc', 'usr', 'include') | 252 pnacl_include = os.path.join(root, 'glibc', 'usr', 'include') |
| 251 else: | 253 else: |
| 252 pnacl_include = os.path.join(root, 'newlib', 'usr', 'include') | 254 pnacl_include = os.path.join(root, 'newlib', 'usr', 'include') |
| 253 pnacl_ar = binprefix + 'ar' + binext | 255 pnacl_ar = binprefix + 'ar' + binext |
| 254 pnacl_as = binprefix + 'as' + binext | 256 pnacl_as = binprefix + 'as' + binext |
| 255 pnacl_nm = binprefix + 'nm' + binext | 257 pnacl_nm = binprefix + 'nm' + binext |
| 256 pnacl_ranlib = binprefix + 'ranlib' + binext | 258 pnacl_ranlib = binprefix + 'ranlib' + binext |
| 257 pnacl_translate = binprefix + 'translate' + binext | 259 # Use the standalone sandboxed translator in sbtc mode |
| 260 if env.Bit('use_sandboxed_translator'): |
| 261 pnacl_translate = os.path.join(translator_root, 'bin', |
| 262 'pnacl-translate' + binext) |
| 263 else: |
| 264 pnacl_translate = binprefix + 'translate' + binext |
| 258 | 265 |
| 259 frontend = env['PNACL_FRONTEND'] | 266 frontend = env['PNACL_FRONTEND'] |
| 260 if frontend == 'clang': | 267 if frontend == 'clang': |
| 261 pnacl_cc = binprefix + 'clang' + binext | 268 pnacl_cc = binprefix + 'clang' + binext |
| 262 pnacl_cxx = binprefix + 'clang++' + binext | 269 pnacl_cxx = binprefix + 'clang++' + binext |
| 263 elif frontend == 'dragonegg': | 270 elif frontend == 'dragonegg': |
| 264 pnacl_cc = binprefix + 'dgcc' + binext | 271 pnacl_cc = binprefix + 'dgcc' + binext |
| 265 pnacl_cxx = binprefix + 'dg++' + binext | 272 pnacl_cxx = binprefix + 'dg++' + binext |
| 266 else: | 273 else: |
| 267 print "Unknown frontend" | 274 print "Unknown frontend" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 STRIP=pnacl_strip, | 335 STRIP=pnacl_strip, |
| 329 GENNMF=pnacl_nmf, | 336 GENNMF=pnacl_nmf, |
| 330 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags, | 337 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags, |
| 331 ) | 338 ) |
| 332 | 339 |
| 333 if env.Bit('built_elsewhere'): | 340 if env.Bit('built_elsewhere'): |
| 334 def FakeInstall(dest, source, env): | 341 def FakeInstall(dest, source, env): |
| 335 print 'Not installing', dest | 342 print 'Not installing', dest |
| 336 env.Replace(CC='true', CXX='true', LINK='true', AR='true', | 343 env.Replace(CC='true', CXX='true', LINK='true', AR='true', |
| 337 RANLIB='true', AS='true', LD='true', | 344 RANLIB='true', AS='true', LD='true', |
| 338 STRIP='true', INSTALL=FakeInstall, | 345 STRIP='true', INSTALL=FakeInstall) |
| 339 #TODO(dschuff) remove this when we can translate on arm hw | |
| 340 TRANSLATE='true') | |
| 341 | 346 |
| 342 | 347 |
| 343 def _SetEnvForSdkManually(env): | 348 def _SetEnvForSdkManually(env): |
| 344 def GetEnvOrDummy(v): | 349 def GetEnvOrDummy(v): |
| 345 return os.getenv('NACL_SDK_' + v, 'MISSING_SDK_' + v) | 350 return os.getenv('NACL_SDK_' + v, 'MISSING_SDK_' + v) |
| 346 | 351 |
| 347 env.Replace(# Replace header and lib paths. | 352 env.Replace(# Replace header and lib paths. |
| 348 NACL_SDK_INCLUDE=GetEnvOrDummy('INCLUDE'), | 353 NACL_SDK_INCLUDE=GetEnvOrDummy('INCLUDE'), |
| 349 NACL_SDK_LIB=GetEnvOrDummy('LIB'), | 354 NACL_SDK_LIB=GetEnvOrDummy('LIB'), |
| 350 # Replace the normal unix tools with the NaCl ones. | 355 # Replace the normal unix tools with the NaCl ones. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 native_env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED', | 408 native_env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED', |
| 404 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED') | 409 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED') |
| 405 else: | 410 else: |
| 406 # These are unfortunately clobbered by running Tool. | 411 # These are unfortunately clobbered by running Tool. |
| 407 native_env.Replace(EXTRA_CFLAGS=env['EXTRA_CFLAGS'], | 412 native_env.Replace(EXTRA_CFLAGS=env['EXTRA_CFLAGS'], |
| 408 EXTRA_CXXFLAGS=env['EXTRA_CXXFLAGS'], | 413 EXTRA_CXXFLAGS=env['EXTRA_CXXFLAGS'], |
| 409 CCFLAGS=env['CCFLAGS'], | 414 CCFLAGS=env['CCFLAGS'], |
| 410 CFLAGS=env['CFLAGS'], | 415 CFLAGS=env['CFLAGS'], |
| 411 CXXFLAGS=env['CXXFLAGS']) | 416 CXXFLAGS=env['CXXFLAGS']) |
| 412 if env.Bit('built_elsewhere'): | 417 if env.Bit('built_elsewhere'): |
| 413 native_env.Replace(CC='true', CXX='true', LINK='true', LD='true') | 418 native_env.Replace(CC='true', CXX='true', LINK='true', LD='true', |
| 419 AR='true', RANLIB='true') |
| 414 return native_env | 420 return native_env |
| 415 | 421 |
| 416 | 422 |
| 417 # This adds architecture specific defines for the target architecture. | 423 # This adds architecture specific defines for the target architecture. |
| 418 # These are normally omitted by PNaCl. | 424 # These are normally omitted by PNaCl. |
| 419 # For example: __i686__, __arm__, __x86_64__ | 425 # For example: __i686__, __arm__, __x86_64__ |
| 420 def AddBiasForPNaCl(env, temporarily_allow=True): | 426 def AddBiasForPNaCl(env, temporarily_allow=True): |
| 421 assert(env.Bit('bitcode')) | 427 assert(env.Bit('bitcode')) |
| 422 # re: the temporarily_allow flag -- that is for: | 428 # re: the temporarily_allow flag -- that is for: |
| 423 # BUG= http://code.google.com/p/nativeclient/issues/detail?id=1248 | 429 # BUG= http://code.google.com/p/nativeclient/issues/detail?id=1248 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 # Dependency files it produces are to be found in ${LIBPATH}. | 634 # Dependency files it produces are to be found in ${LIBPATH}. |
| 629 # It is applied recursively to those dependencies in case | 635 # It is applied recursively to those dependencies in case |
| 630 # some of them are linker scripts too. | 636 # some of them are linker scripts too. |
| 631 ldscript_scanner = SCons.Scanner.Base( | 637 ldscript_scanner = SCons.Scanner.Base( |
| 632 function=ScanLinkerScript, | 638 function=ScanLinkerScript, |
| 633 skeys=['.a', '.so', '.pso'], | 639 skeys=['.a', '.so', '.pso'], |
| 634 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), | 640 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), |
| 635 recursive=True | 641 recursive=True |
| 636 ) | 642 ) |
| 637 env.Append(SCANNERS=ldscript_scanner) | 643 env.Append(SCANNERS=ldscript_scanner) |
| OLD | NEW |