| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 def PNaClForceNative(env): | 328 def PNaClForceNative(env): |
| 329 assert(env.Bit('bitcode')) | 329 assert(env.Bit('bitcode')) |
| 330 env.Replace(OBJSUFFIX='.o', | 330 env.Replace(OBJSUFFIX='.o', |
| 331 SHLIBSUFFIX='.so') | 331 SHLIBSUFFIX='.so') |
| 332 env.Append(ASFLAGS=['-arch', '${TARGET_FULLARCH}'], | 332 env.Append(ASFLAGS=['-arch', '${TARGET_FULLARCH}'], |
| 333 CCFLAGS=['-arch', '${TARGET_FULLARCH}', '--pnacl-allow-translate'], | 333 CCFLAGS=['-arch', '${TARGET_FULLARCH}', '--pnacl-allow-translate'], |
| 334 LINKFLAGS=['--pnacl-allow-native']) | 334 LINKFLAGS=['--pnacl-allow-native']) |
| 335 env['SHLINK'] = '${LINK}' | 335 env['SHLINK'] = '${LINK}' |
| 336 | 336 |
| 337 # Get an environment for a different frontend when in |
| 338 # PNaCl mode. |
| 339 def PNaClChangeFrontend(env, frontend): |
| 340 assert(env.Bit('bitcode')) |
| 341 assert(frontend in ('clang','dragonegg','llvmgcc')) |
| 342 |
| 343 # This is kind of a hack. |
| 344 alt_env = env.Clone() |
| 345 alt_env['PNACL_FRONTEND'] = frontend |
| 346 alt_env = alt_env.Clone(tools = ['naclsdk']) |
| 347 return alt_env |
| 348 |
| 349 |
| 337 # Get an environment for nacl-gcc when in PNaCl mode. | 350 # Get an environment for nacl-gcc when in PNaCl mode. |
| 338 def PNaClGetNNaClEnv(env): | 351 def PNaClGetNNaClEnv(env): |
| 339 assert(env.Bit('bitcode')) | 352 assert(env.Bit('bitcode')) |
| 340 assert(not env.Bit('target_arm')) | 353 assert(not env.Bit('target_arm')) |
| 341 | 354 |
| 342 # This is kind of a hack. We clone the environment, | 355 # This is kind of a hack. We clone the environment, |
| 343 # clear the bitcode bit, and then reload naclsdk.py | 356 # clear the bitcode bit, and then reload naclsdk.py |
| 344 native_env = env.Clone() | 357 native_env = env.Clone() |
| 345 native_env.ClearBits('bitcode') | 358 native_env.ClearBits('bitcode') |
| 346 native_env = native_env.Clone(tools = ['naclsdk']) | 359 native_env = native_env.Clone(tools = ['naclsdk']) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 env: The SCons environment in question. | 469 env: The SCons environment in question. |
| 457 | 470 |
| 458 NOTE: SCons requires the use of this name, which fails lint. | 471 NOTE: SCons requires the use of this name, which fails lint. |
| 459 """ | 472 """ |
| 460 | 473 |
| 461 # make these methods to the top level scons file | 474 # make these methods to the top level scons file |
| 462 env.AddMethod(ValidateSdk) | 475 env.AddMethod(ValidateSdk) |
| 463 env.AddMethod(AddBiasForPNaCl) | 476 env.AddMethod(AddBiasForPNaCl) |
| 464 env.AddMethod(PNaClForceNative) | 477 env.AddMethod(PNaClForceNative) |
| 465 env.AddMethod(PNaClGetNNaClEnv) | 478 env.AddMethod(PNaClGetNNaClEnv) |
| 479 env.AddMethod(PNaClChangeFrontend) |
| 466 | 480 |
| 467 sdk_mode = SCons.Script.ARGUMENTS.get('naclsdk_mode', 'download') | 481 sdk_mode = SCons.Script.ARGUMENTS.get('naclsdk_mode', 'download') |
| 468 | 482 |
| 469 # Invoke the various unix tools that the NativeClient SDK resembles. | 483 # Invoke the various unix tools that the NativeClient SDK resembles. |
| 470 env.Tool('g++') | 484 env.Tool('g++') |
| 471 env.Tool('gcc') | 485 env.Tool('gcc') |
| 472 env.Tool('gnulink') | 486 env.Tool('gnulink') |
| 473 env.Tool('ar') | 487 env.Tool('ar') |
| 474 env.Tool('as') | 488 env.Tool('as') |
| 475 | 489 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 504 # Dependency files it produces are to be found in ${LIBPATH}. | 518 # Dependency files it produces are to be found in ${LIBPATH}. |
| 505 # It is applied recursively to those dependencies in case | 519 # It is applied recursively to those dependencies in case |
| 506 # some of them are linker scripts too. | 520 # some of them are linker scripts too. |
| 507 ldscript_scanner = SCons.Scanner.Base( | 521 ldscript_scanner = SCons.Scanner.Base( |
| 508 function=ScanLinkerScript, | 522 function=ScanLinkerScript, |
| 509 skeys=['.a', '.so', '.pso'], | 523 skeys=['.a', '.so', '.pso'], |
| 510 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), | 524 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), |
| 511 recursive=True | 525 recursive=True |
| 512 ) | 526 ) |
| 513 env.Append(SCANNERS=ldscript_scanner) | 527 env.Append(SCANNERS=ldscript_scanner) |
| OLD | NEW |