| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 ) | 216 ) |
| 217 | 217 |
| 218 def _SetEnvForPnacl(env, root): | 218 def _SetEnvForPnacl(env, root): |
| 219 # All the PNaCl tools require Python to be in the PATH. | 219 # All the PNaCl tools require Python to be in the PATH. |
| 220 # On the Windows bots, however, Python is not installed system-wide. | 220 # On the Windows bots, however, Python is not installed system-wide. |
| 221 # It must be pulled from ../third_party/python_26. | 221 # It must be pulled from ../third_party/python_26. |
| 222 python_dir = os.path.join('..', 'third_party', 'python_26') | 222 python_dir = os.path.join('..', 'third_party', 'python_26') |
| 223 env.AppendENVPath('PATH', python_dir) | 223 env.AppendENVPath('PATH', python_dir) |
| 224 | 224 |
| 225 arch = env['TARGET_FULLARCH'] | 225 arch = env['TARGET_FULLARCH'] |
| 226 assert arch in ['arm', 'arm-thumb2', 'x86-32', 'x86-64'] | 226 assert arch in ['arm', 'arm-thumb2', 'mips32', 'x86-32', 'x86-64'] |
| 227 | 227 |
| 228 arch_flag = ' -arch %s' % arch | 228 arch_flag = ' -arch %s' % arch |
| 229 if env.Bit('pnacl_generate_pexe'): | 229 if env.Bit('pnacl_generate_pexe'): |
| 230 ld_arch_flag = '' | 230 ld_arch_flag = '' |
| 231 else: | 231 else: |
| 232 ld_arch_flag = arch_flag | 232 ld_arch_flag = arch_flag |
| 233 | 233 |
| 234 if env.Bit('nacl_glibc'): | 234 if env.Bit('nacl_glibc'): |
| 235 subroot = root + '/glibc' | 235 subroot = root + '/glibc' |
| 236 else: | 236 else: |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 LINK=cc_flags) # Already has -arch | 400 LINK=cc_flags) # Already has -arch |
| 401 env['LD'] = '${NATIVELD}' + arch_flag | 401 env['LD'] = '${NATIVELD}' + arch_flag |
| 402 env['SHLINK'] = '${LINK}' | 402 env['SHLINK'] = '${LINK}' |
| 403 if env.Bit('built_elsewhere'): | 403 if env.Bit('built_elsewhere'): |
| 404 env.Replace(CC='true', CXX='true', ASPP='true', LINK='true', LD='true') | 404 env.Replace(CC='true', CXX='true', ASPP='true', LINK='true', LD='true') |
| 405 | 405 |
| 406 # Get an environment for nacl-gcc when in PNaCl mode. | 406 # Get an environment for nacl-gcc when in PNaCl mode. |
| 407 def PNaClGetNNaClEnv(env): | 407 def PNaClGetNNaClEnv(env): |
| 408 assert(env.Bit('bitcode')) | 408 assert(env.Bit('bitcode')) |
| 409 assert(not env.Bit('target_arm')) | 409 assert(not env.Bit('target_arm')) |
| 410 assert(not env.Bit('target_mips32')) |
| 410 | 411 |
| 411 # This is kind of a hack. We clone the environment, | 412 # This is kind of a hack. We clone the environment, |
| 412 # clear the bitcode bit, and then reload naclsdk.py | 413 # clear the bitcode bit, and then reload naclsdk.py |
| 413 native_env = env.Clone() | 414 native_env = env.Clone() |
| 414 native_env.ClearBits('bitcode') | 415 native_env.ClearBits('bitcode') |
| 415 native_env.SetBits('native_code') | 416 native_env.SetBits('native_code') |
| 416 native_env = native_env.Clone(tools=['naclsdk']) | 417 native_env = native_env.Clone(tools=['naclsdk']) |
| 417 if native_env.Bit('pnacl_generate_pexe'): | 418 if native_env.Bit('pnacl_generate_pexe'): |
| 418 native_env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED', | 419 native_env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED', |
| 419 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED') | 420 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED') |
| 420 else: | 421 else: |
| 421 # These are unfortunately clobbered by running Tool. | 422 # These are unfortunately clobbered by running Tool. |
| 422 native_env.Replace(EXTRA_CFLAGS=env['EXTRA_CFLAGS'], | 423 native_env.Replace(EXTRA_CFLAGS=env['EXTRA_CFLAGS'], |
| 423 EXTRA_CXXFLAGS=env['EXTRA_CXXFLAGS'], | 424 EXTRA_CXXFLAGS=env['EXTRA_CXXFLAGS'], |
| 424 CCFLAGS=env['CCFLAGS'], | 425 CCFLAGS=env['CCFLAGS'], |
| 425 CFLAGS=env['CFLAGS'], | 426 CFLAGS=env['CFLAGS'], |
| 426 CXXFLAGS=env['CXXFLAGS']) | 427 CXXFLAGS=env['CXXFLAGS']) |
| 427 if env.Bit('built_elsewhere'): | 428 if env.Bit('built_elsewhere'): |
| 428 native_env.Replace(CC='true', CXX='true', LINK='true', LD='true', | 429 native_env.Replace(CC='true', CXX='true', LINK='true', LD='true', |
| 429 AR='true', RANLIB='true') | 430 AR='true', RANLIB='true') |
| 430 return native_env | 431 return native_env |
| 431 | 432 |
| 432 | 433 |
| 433 # This adds architecture specific defines for the target architecture. | 434 # This adds architecture specific defines for the target architecture. |
| 434 # These are normally omitted by PNaCl. | 435 # These are normally omitted by PNaCl. |
| 435 # For example: __i686__, __arm__, __x86_64__ | 436 # For example: __i686__, __arm__, __mips__, __x86_64__ |
| 436 def AddBiasForPNaCl(env, temporarily_allow=True): | 437 def AddBiasForPNaCl(env, temporarily_allow=True): |
| 437 assert(env.Bit('bitcode')) | 438 assert(env.Bit('bitcode')) |
| 438 # re: the temporarily_allow flag -- that is for: | 439 # re: the temporarily_allow flag -- that is for: |
| 439 # BUG= http://code.google.com/p/nativeclient/issues/detail?id=1248 | 440 # BUG= http://code.google.com/p/nativeclient/issues/detail?id=1248 |
| 440 if env.Bit('pnacl_generate_pexe') and not temporarily_allow: | 441 if env.Bit('pnacl_generate_pexe') and not temporarily_allow: |
| 441 env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED', | 442 env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED', |
| 442 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED') | 443 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED') |
| 443 return | 444 return |
| 444 | 445 |
| 445 if env.Bit('target_arm'): | 446 if env.Bit('target_arm'): |
| 446 env.AppendUnique(CCFLAGS=['--pnacl-arm-bias'], | 447 env.AppendUnique(CCFLAGS=['--pnacl-arm-bias'], |
| 447 ASPPFLAGS=['--pnacl-arm-bias']) | 448 ASPPFLAGS=['--pnacl-arm-bias']) |
| 448 elif env.Bit('target_x86_32'): | 449 elif env.Bit('target_x86_32'): |
| 449 env.AppendUnique(CCFLAGS=['--pnacl-i686-bias'], | 450 env.AppendUnique(CCFLAGS=['--pnacl-i686-bias'], |
| 450 ASPPFLAGS=['--pnacl-i686-bias']) | 451 ASPPFLAGS=['--pnacl-i686-bias']) |
| 451 elif env.Bit('target_x86_64'): | 452 elif env.Bit('target_x86_64'): |
| 452 env.AppendUnique(CCFLAGS=['--pnacl-x86_64-bias'], | 453 env.AppendUnique(CCFLAGS=['--pnacl-x86_64-bias'], |
| 453 ASPPFLAGS=['--pnacl-x86_64-bias']) | 454 ASPPFLAGS=['--pnacl-x86_64-bias']) |
| 455 elif env.Bit('target_mips32'): |
| 456 env.AppendUnique(CCFLAGS=['--pnacl-mips-bias'], |
| 457 ASPPFLAGS=['--pnacl-mips-bias']) |
| 454 else: | 458 else: |
| 455 raise Exception("Unknown architecture!") | 459 raise Exception("Unknown architecture!") |
| 456 | 460 |
| 457 | 461 |
| 458 def ValidateSdk(env): | 462 def ValidateSdk(env): |
| 459 checkables = ['${NACL_SDK_INCLUDE}/stdio.h'] | 463 checkables = ['${NACL_SDK_INCLUDE}/stdio.h'] |
| 460 for c in checkables: | 464 for c in checkables: |
| 461 if os.path.exists(env.subst(c)): | 465 if os.path.exists(env.subst(c)): |
| 462 continue | 466 continue |
| 463 # Windows build does not use cygwin and so can not see nacl subdirectory | 467 # Windows build does not use cygwin and so can not see nacl subdirectory |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 # Dependency files it produces are to be found in ${LIBPATH}. | 644 # Dependency files it produces are to be found in ${LIBPATH}. |
| 641 # It is applied recursively to those dependencies in case | 645 # It is applied recursively to those dependencies in case |
| 642 # some of them are linker scripts too. | 646 # some of them are linker scripts too. |
| 643 ldscript_scanner = SCons.Scanner.Base( | 647 ldscript_scanner = SCons.Scanner.Base( |
| 644 function=ScanLinkerScript, | 648 function=ScanLinkerScript, |
| 645 skeys=['.a', '.so', '.pso'], | 649 skeys=['.a', '.so', '.pso'], |
| 646 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), | 650 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), |
| 647 recursive=True | 651 recursive=True |
| 648 ) | 652 ) |
| 649 env.Append(SCANNERS=ldscript_scanner) | 653 env.Append(SCANNERS=ldscript_scanner) |
| OLD | NEW |