Chromium Code Reviews| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 AR=pnacl_ar, | 318 AR=pnacl_ar, |
| 319 AS=pnacl_as + ld_arch_flag, | 319 AS=pnacl_as + ld_arch_flag, |
| 320 RANLIB=pnacl_ranlib, | 320 RANLIB=pnacl_ranlib, |
| 321 DISASS=pnacl_disass, | 321 DISASS=pnacl_disass, |
| 322 OBJDUMP=pnacl_disass, | 322 OBJDUMP=pnacl_disass, |
| 323 STRIP=pnacl_strip, | 323 STRIP=pnacl_strip, |
| 324 GENNMF=pnacl_nmf, | 324 GENNMF=pnacl_nmf, |
| 325 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags, | 325 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags, |
| 326 ) | 326 ) |
| 327 | 327 |
| 328 if env.Bit('built_elsewhere'): | |
| 329 def FakeInstall(dest, source, env): | |
| 330 print 'Not installing', dest | |
| 331 env.Replace(CC='true', CXX='true', LINK='true', AR='true', | |
|
robertm
2012/03/22 14:09:37
if it is not too much work it be nice to make the
(google.com) Derek Schuff
2012/03/22 16:10:25
How would that work? Will it work if I just pass a
robertm
2012/03/22 16:18:43
not sure.
another option could be CC='echo CC #'
| |
| 332 RANLIB='true', AS='true', LD='true', | |
| 333 STRIP='true', INSTALL=FakeInstall, | |
| 334 #TODO(dschuff) remove this when we can translate on arm hw | |
| 335 TRANSLATE='true') | |
| 336 | |
| 328 | 337 |
| 329 def _SetEnvForSdkManually(env): | 338 def _SetEnvForSdkManually(env): |
| 330 def GetEnvOrDummy(v): | 339 def GetEnvOrDummy(v): |
| 331 return os.getenv('NACL_SDK_' + v, 'MISSING_SDK_' + v) | 340 return os.getenv('NACL_SDK_' + v, 'MISSING_SDK_' + v) |
| 332 | 341 |
| 333 env.Replace(# Replace header and lib paths. | 342 env.Replace(# Replace header and lib paths. |
| 334 NACL_SDK_INCLUDE=GetEnvOrDummy('INCLUDE'), | 343 NACL_SDK_INCLUDE=GetEnvOrDummy('INCLUDE'), |
| 335 NACL_SDK_LIB=GetEnvOrDummy('LIB'), | 344 NACL_SDK_LIB=GetEnvOrDummy('LIB'), |
| 336 # Replace the normal unix tools with the NaCl ones. | 345 # Replace the normal unix tools with the NaCl ones. |
| 337 CC=GetEnvOrDummy('CC'), | 346 CC=GetEnvOrDummy('CC'), |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 352 env.Replace(OBJSUFFIX='.o', | 361 env.Replace(OBJSUFFIX='.o', |
| 353 SHLIBSUFFIX='.so') | 362 SHLIBSUFFIX='.so') |
| 354 arch_flag = ' -arch ${TARGET_FULLARCH}' | 363 arch_flag = ' -arch ${TARGET_FULLARCH}' |
| 355 cc_flags = ' --pnacl-allow-native --pnacl-allow-translate' | 364 cc_flags = ' --pnacl-allow-native --pnacl-allow-translate' |
| 356 env.Append(CC=arch_flag + cc_flags, | 365 env.Append(CC=arch_flag + cc_flags, |
| 357 CXX=arch_flag + cc_flags, | 366 CXX=arch_flag + cc_flags, |
| 358 ASPP=arch_flag + cc_flags, | 367 ASPP=arch_flag + cc_flags, |
| 359 LINK=cc_flags) # Already has -arch | 368 LINK=cc_flags) # Already has -arch |
| 360 env['LD'] = '${NATIVELD}' + arch_flag | 369 env['LD'] = '${NATIVELD}' + arch_flag |
| 361 env['SHLINK'] = '${LINK}' | 370 env['SHLINK'] = '${LINK}' |
| 371 if env.Bit('built_elsewhere'): | |
| 372 env.Replace(CC='true', CXX='true', ASPP='true', LINK='true', LD='true') | |
|
jvoung - send to chromium...
2012/03/22 00:17:45
Should this be done earlier? Mainly concerned wit
robertm
2012/03/22 14:09:37
if this ends up staying around you could unify thi
(google.com) Derek Schuff
2012/03/22 16:10:25
The change above is for the nacl environment and a
| |
| 362 | 373 |
| 363 # Get an environment for a different frontend when in | 374 # Get an environment for a different frontend when in |
| 364 # PNaCl mode. | 375 # PNaCl mode. |
| 365 def PNaClChangeFrontend(env, frontend): | 376 def PNaClChangeFrontend(env, frontend): |
| 366 assert(env.Bit('bitcode')) | 377 assert(env.Bit('bitcode')) |
| 367 assert(frontend in ('clang','dragonegg')) | 378 assert(frontend in ('clang','dragonegg')) |
| 368 | 379 |
| 369 # This is kind of a hack. | 380 # This is kind of a hack. |
| 370 alt_env = env.Clone() | 381 alt_env = env.Clone() |
| 371 alt_env['PNACL_FRONTEND'] = frontend | 382 alt_env['PNACL_FRONTEND'] = frontend |
| 372 alt_env = alt_env.Clone(tools = ['naclsdk']) | 383 alt_env = alt_env.Clone(tools = ['naclsdk']) |
| 373 return alt_env | 384 return alt_env |
| 374 | 385 |
| 375 | 386 |
| 376 # Get an environment for nacl-gcc when in PNaCl mode. | 387 # Get an environment for nacl-gcc when in PNaCl mode. |
| 377 def PNaClGetNNaClEnv(env): | 388 def PNaClGetNNaClEnv(env): |
| 378 assert(env.Bit('bitcode')) | 389 assert(env.Bit('bitcode')) |
| 379 assert(not env.Bit('target_arm')) | 390 assert(not env.Bit('target_arm')) |
| 380 | 391 |
| 381 # This is kind of a hack. We clone the environment, | 392 # This is kind of a hack. We clone the environment, |
| 382 # clear the bitcode bit, and then reload naclsdk.py | 393 # clear the bitcode bit, and then reload naclsdk.py |
| 383 native_env = env.Clone() | 394 native_env = env.Clone() |
| 384 native_env.ClearBits('bitcode') | 395 native_env.ClearBits('bitcode') |
| 385 native_env = native_env.Clone(tools=['naclsdk']) | 396 native_env = native_env.Clone(tools=['naclsdk']) |
| 386 if native_env.Bit('pnacl_generate_pexe'): | 397 if native_env.Bit('pnacl_generate_pexe'): |
| 387 native_env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED', | 398 native_env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED', |
| 388 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED') | 399 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED') |
|
jvoung - send to chromium...
2012/03/22 00:17:45
I assume this worked too since I think toolchain t
(google.com) Derek Schuff
2012/03/22 16:10:25
It did work when I tested, but I added a case here
| |
| 389 else: | 400 else: |
| 390 # These are unfortunately clobbered by running Tool. | 401 # These are unfortunately clobbered by running Tool. |
| 391 native_env.Replace(EXTRA_CFLAGS=env['EXTRA_CFLAGS'], | 402 native_env.Replace(EXTRA_CFLAGS=env['EXTRA_CFLAGS'], |
| 392 EXTRA_CXXFLAGS=env['EXTRA_CXXFLAGS'], | 403 EXTRA_CXXFLAGS=env['EXTRA_CXXFLAGS'], |
| 393 CCFLAGS=env['CCFLAGS'], | 404 CCFLAGS=env['CCFLAGS'], |
| 394 CFLAGS=env['CFLAGS'], | 405 CFLAGS=env['CFLAGS'], |
| 395 CXXFLAGS=env['CXXFLAGS']) | 406 CXXFLAGS=env['CXXFLAGS']) |
| 396 return native_env | 407 return native_env |
| 397 | 408 |
| 398 | 409 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 # Dependency files it produces are to be found in ${LIBPATH}. | 621 # Dependency files it produces are to be found in ${LIBPATH}. |
| 611 # It is applied recursively to those dependencies in case | 622 # It is applied recursively to those dependencies in case |
| 612 # some of them are linker scripts too. | 623 # some of them are linker scripts too. |
| 613 ldscript_scanner = SCons.Scanner.Base( | 624 ldscript_scanner = SCons.Scanner.Base( |
| 614 function=ScanLinkerScript, | 625 function=ScanLinkerScript, |
| 615 skeys=['.a', '.so', '.pso'], | 626 skeys=['.a', '.so', '.pso'], |
| 616 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), | 627 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), |
| 617 recursive=True | 628 recursive=True |
| 618 ) | 629 ) |
| 619 env.Append(SCANNERS=ldscript_scanner) | 630 env.Append(SCANNERS=ldscript_scanner) |
| OLD | NEW |