Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: site_scons/site_tools/naclsdk.py

Issue 9979025: [MIPS] Adding validator for MIPS architecture. (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Changes after second code review. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 ) 210 )
211 211
212 def _SetEnvForPnacl(env, root): 212 def _SetEnvForPnacl(env, root):
213 # All the PNaCl tools require Python to be in the PATH. 213 # All the PNaCl tools require Python to be in the PATH.
214 # On the Windows bots, however, Python is not installed system-wide. 214 # On the Windows bots, however, Python is not installed system-wide.
215 # It must be pulled from ../third_party/python_26. 215 # It must be pulled from ../third_party/python_26.
216 python_dir = os.path.join('..', 'third_party', 'python_26') 216 python_dir = os.path.join('..', 'third_party', 'python_26')
217 env.AppendENVPath('PATH', python_dir) 217 env.AppendENVPath('PATH', python_dir)
218 218
219 arch = env['TARGET_FULLARCH'] 219 arch = env['TARGET_FULLARCH']
220 assert arch in ['arm', 'arm-thumb2', 'x86-32', 'x86-64'] 220 assert arch in ['arm', 'arm-thumb2', 'mips32', 'x86-32', 'x86-64']
221 221
222 arch_flag = ' -arch %s' % arch 222 arch_flag = ' -arch %s' % arch
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:
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 LINK=cc_flags) # Already has -arch 372 LINK=cc_flags) # Already has -arch
373 env['LD'] = '${NATIVELD}' + arch_flag 373 env['LD'] = '${NATIVELD}' + arch_flag
374 env['SHLINK'] = '${LINK}' 374 env['SHLINK'] = '${LINK}'
375 if env.Bit('built_elsewhere'): 375 if env.Bit('built_elsewhere'):
376 env.Replace(CC='true', CXX='true', ASPP='true', LINK='true', LD='true') 376 env.Replace(CC='true', CXX='true', ASPP='true', LINK='true', LD='true')
377 377
378 # Get an environment for nacl-gcc when in PNaCl mode. 378 # Get an environment for nacl-gcc when in PNaCl mode.
379 def PNaClGetNNaClEnv(env): 379 def PNaClGetNNaClEnv(env):
380 assert(env.Bit('bitcode')) 380 assert(env.Bit('bitcode'))
381 assert(not env.Bit('target_arm')) 381 assert(not env.Bit('target_arm'))
382 assert(not env.Bit('target_mips32'))
382 383
383 # This is kind of a hack. We clone the environment, 384 # This is kind of a hack. We clone the environment,
384 # clear the bitcode bit, and then reload naclsdk.py 385 # clear the bitcode bit, and then reload naclsdk.py
385 native_env = env.Clone() 386 native_env = env.Clone()
386 native_env.ClearBits('bitcode') 387 native_env.ClearBits('bitcode')
387 native_env = native_env.Clone(tools=['naclsdk']) 388 native_env = native_env.Clone(tools=['naclsdk'])
388 if native_env.Bit('pnacl_generate_pexe'): 389 if native_env.Bit('pnacl_generate_pexe'):
389 native_env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED', 390 native_env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED',
390 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED') 391 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED')
391 else: 392 else:
392 # These are unfortunately clobbered by running Tool. 393 # These are unfortunately clobbered by running Tool.
393 native_env.Replace(EXTRA_CFLAGS=env['EXTRA_CFLAGS'], 394 native_env.Replace(EXTRA_CFLAGS=env['EXTRA_CFLAGS'],
394 EXTRA_CXXFLAGS=env['EXTRA_CXXFLAGS'], 395 EXTRA_CXXFLAGS=env['EXTRA_CXXFLAGS'],
395 CCFLAGS=env['CCFLAGS'], 396 CCFLAGS=env['CCFLAGS'],
396 CFLAGS=env['CFLAGS'], 397 CFLAGS=env['CFLAGS'],
397 CXXFLAGS=env['CXXFLAGS']) 398 CXXFLAGS=env['CXXFLAGS'])
398 if env.Bit('built_elsewhere'): 399 if env.Bit('built_elsewhere'):
399 native_env.Replace(CC='true', CXX='true', LINK='true', LD='true', 400 native_env.Replace(CC='true', CXX='true', LINK='true', LD='true',
400 AR='true', RANLIB='true') 401 AR='true', RANLIB='true')
401 return native_env 402 return native_env
402 403
403 404
404 # This adds architecture specific defines for the target architecture. 405 # This adds architecture specific defines for the target architecture.
405 # These are normally omitted by PNaCl. 406 # These are normally omitted by PNaCl.
406 # For example: __i686__, __arm__, __x86_64__ 407 # For example: __i686__, __arm__, __mips__, __x86_64__
407 def AddBiasForPNaCl(env, temporarily_allow=True): 408 def AddBiasForPNaCl(env, temporarily_allow=True):
408 assert(env.Bit('bitcode')) 409 assert(env.Bit('bitcode'))
409 # re: the temporarily_allow flag -- that is for: 410 # re: the temporarily_allow flag -- that is for:
410 # BUG= http://code.google.com/p/nativeclient/issues/detail?id=1248 411 # BUG= http://code.google.com/p/nativeclient/issues/detail?id=1248
411 if env.Bit('pnacl_generate_pexe') and not temporarily_allow: 412 if env.Bit('pnacl_generate_pexe') and not temporarily_allow:
412 env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED', 413 env.Replace(CC='NO-NATIVE-CC-INVOCATION-ALLOWED',
413 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED') 414 CXX='NO-NATIVE-CXX-INVOCATION-ALLOWED')
414 return 415 return
415 416
416 if env.Bit('target_arm'): 417 if env.Bit('target_arm'):
417 env.AppendUnique(CCFLAGS=['--pnacl-arm-bias'], 418 env.AppendUnique(CCFLAGS=['--pnacl-arm-bias'],
418 ASPPFLAGS=['--pnacl-arm-bias']) 419 ASPPFLAGS=['--pnacl-arm-bias'])
419 elif env.Bit('target_x86_32'): 420 elif env.Bit('target_x86_32'):
420 env.AppendUnique(CCFLAGS=['--pnacl-i686-bias'], 421 env.AppendUnique(CCFLAGS=['--pnacl-i686-bias'],
421 ASPPFLAGS=['--pnacl-i686-bias']) 422 ASPPFLAGS=['--pnacl-i686-bias'])
422 elif env.Bit('target_x86_64'): 423 elif env.Bit('target_x86_64'):
423 env.AppendUnique(CCFLAGS=['--pnacl-x86_64-bias'], 424 env.AppendUnique(CCFLAGS=['--pnacl-x86_64-bias'],
424 ASPPFLAGS=['--pnacl-x86_64-bias']) 425 ASPPFLAGS=['--pnacl-x86_64-bias'])
426 elif env.Bit('target_mips32'):
427 env.AppendUnique(CCFLAGS=['--pnacl-mips-bias'],
428 ASPPFLAGS=['--pnacl-mips-bias'])
425 else: 429 else:
426 raise Exception("Unknown architecture!") 430 raise Exception("Unknown architecture!")
427 431
428 432
429 def ValidateSdk(env): 433 def ValidateSdk(env):
430 checkables = ['${NACL_SDK_INCLUDE}/stdio.h'] 434 checkables = ['${NACL_SDK_INCLUDE}/stdio.h']
431 for c in checkables: 435 for c in checkables:
432 if os.path.exists(env.subst(c)): 436 if os.path.exists(env.subst(c)):
433 continue 437 continue
434 # Windows build does not use cygwin and so can not see nacl subdirectory 438 # Windows build does not use cygwin and so can not see nacl subdirectory
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 # Dependency files it produces are to be found in ${LIBPATH}. 618 # Dependency files it produces are to be found in ${LIBPATH}.
615 # It is applied recursively to those dependencies in case 619 # It is applied recursively to those dependencies in case
616 # some of them are linker scripts too. 620 # some of them are linker scripts too.
617 ldscript_scanner = SCons.Scanner.Base( 621 ldscript_scanner = SCons.Scanner.Base(
618 function=ScanLinkerScript, 622 function=ScanLinkerScript,
619 skeys=['.a', '.so', '.pso'], 623 skeys=['.a', '.so', '.pso'],
620 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), 624 path_function=SCons.Scanner.FindPathDirs('LIBPATH'),
621 recursive=True 625 recursive=True
622 ) 626 )
623 env.Append(SCANNERS=ldscript_scanner) 627 env.Append(SCANNERS=ldscript_scanner)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698