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

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

Issue 9696046: Add test running support for tests generated as pexes. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: suggestions Created 8 years, 9 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 | Annotate | Revision Log
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 def _SetEnvForPnacl(env, root): 207 def _SetEnvForPnacl(env, root):
208 # All the PNaCl tools require Python to be in the PATH. 208 # All the PNaCl tools require Python to be in the PATH.
209 # On the Windows bots, however, Python is not installed system-wide. 209 # On the Windows bots, however, Python is not installed system-wide.
210 # It must be pulled from ../third_party/python_26. 210 # It must be pulled from ../third_party/python_26.
211 python_dir = os.path.join('..', 'third_party', 'python_26') 211 python_dir = os.path.join('..', 'third_party', 'python_26')
212 env.AppendENVPath('PATH', python_dir) 212 env.AppendENVPath('PATH', python_dir)
213 213
214 arch = env['TARGET_FULLARCH'] 214 arch = env['TARGET_FULLARCH']
215 assert arch in ['arm', 'arm-thumb2', 'x86-32', 'x86-64'] 215 assert arch in ['arm', 'arm-thumb2', 'x86-32', 'x86-64']
216 216
217 arch_flag = ' -arch %s' % arch
217 if env.Bit('pnacl_stop_with_pexe'): 218 if env.Bit('pnacl_stop_with_pexe'):
218 arch_flag = '' 219 ld_arch_flag = ''
219 else: 220 else:
220 arch_flag = ' -arch %s' % arch 221 ld_arch_flag = arch_flag
222
Mark Seaborn 2012/03/13 22:16:55 Style nit: Shouldn't have >1 blank line inside a f
221 223
222 if env.Bit('nacl_glibc'): 224 if env.Bit('nacl_glibc'):
223 subroot = root + '/glibc' 225 subroot = root + '/glibc'
224 else: 226 else:
225 subroot = root + '/newlib' 227 subroot = root + '/newlib'
226 228
227 binprefix = os.path.join(subroot, 'bin', 'pnacl-') 229 binprefix = os.path.join(subroot, 'bin', 'pnacl-')
228 binext = '' 230 binext = ''
229 if env.Bit('host_windows'): 231 if env.Bit('host_windows'):
230 binext = '.bat' 232 binext = '.bat'
(...skipping 10 matching lines...) Expand all
241 243
242 #TODO(robertm): remove NACL_SDK_INCLUDE ASAP 244 #TODO(robertm): remove NACL_SDK_INCLUDE ASAP
243 if env.Bit('nacl_glibc'): 245 if env.Bit('nacl_glibc'):
244 pnacl_include = os.path.join(root, 'glibc', 'usr', 'include') 246 pnacl_include = os.path.join(root, 'glibc', 'usr', 'include')
245 else: 247 else:
246 pnacl_include = os.path.join(root, 'newlib', 'usr', 'include') 248 pnacl_include = os.path.join(root, 'newlib', 'usr', 'include')
247 pnacl_ar = binprefix + 'ar' + binext 249 pnacl_ar = binprefix + 'ar' + binext
248 pnacl_as = binprefix + 'as' + binext 250 pnacl_as = binprefix + 'as' + binext
249 pnacl_nm = binprefix + 'nm' + binext 251 pnacl_nm = binprefix + 'nm' + binext
250 pnacl_ranlib = binprefix + 'ranlib' + binext 252 pnacl_ranlib = binprefix + 'ranlib' + binext
253 pnacl_translate = binprefix + 'translate' + binext
251 254
252 frontend = env['PNACL_FRONTEND'] 255 frontend = env['PNACL_FRONTEND']
253 if frontend == 'clang': 256 if frontend == 'clang':
254 pnacl_cc = binprefix + 'clang' + binext 257 pnacl_cc = binprefix + 'clang' + binext
255 pnacl_cxx = binprefix + 'clang++' + binext 258 pnacl_cxx = binprefix + 'clang++' + binext
256 elif frontend == 'dragonegg': 259 elif frontend == 'dragonegg':
257 pnacl_cc = binprefix + 'dgcc' + binext 260 pnacl_cc = binprefix + 'dgcc' + binext
258 pnacl_cxx = binprefix + 'dg++' + binext 261 pnacl_cxx = binprefix + 'dg++' + binext
259 else: 262 else:
260 print "Unknown frontend" 263 print "Unknown frontend"
261 sys.exit(-1) 264 sys.exit(-1)
262 265
263 pnacl_ld = binprefix + 'ld' + binext 266 pnacl_ld = binprefix + 'ld' + binext
264 pnacl_nativeld = binprefix + 'nativeld' + binext 267 pnacl_nativeld = binprefix + 'nativeld' + binext
265 pnacl_disass = binprefix + 'dis' + binext 268 pnacl_disass = binprefix + 'dis' + binext
266 pnacl_strip = binprefix + 'strip' + binext 269 pnacl_strip = binprefix + 'strip' + binext
267 pnacl_nmf = binprefix + 'nmf' + binext 270 pnacl_nmf = binprefix + 'nmf' + binext
268 271
269 # NOTE: XXX_flags start with space for easy concatenation 272 # NOTE: XXX_flags start with space for easy concatenation
270 # The flags generated here get baked into the commands (CC, CXX, LINK) 273 # The flags generated here get baked into the commands (CC, CXX, LINK)
271 # instead of CFLAGS etc to keep them from getting blown away by some 274 # instead of CFLAGS etc to keep them from getting blown away by some
272 # tests. Don't add flags here unless they always need to be preserved. 275 # tests. Don't add flags here unless they always need to be preserved.
273 pnacl_cxx_flags = '' 276 pnacl_cxx_flags = ''
274 pnacl_cc_flags = ' -std=gnu99' 277 pnacl_cc_flags = ' -std=gnu99'
275 pnacl_ld_flags = ' ' + ' '.join(env['PNACL_BCLDFLAGS']) 278 pnacl_ld_flags = ' ' + ' '.join(env['PNACL_BCLDFLAGS'])
279 pnacl_translate_flags = ''
276 280
277 if env.Bit('nacl_pic'): 281 if env.Bit('nacl_pic'):
278 pnacl_cc_flags += ' -fPIC' 282 pnacl_cc_flags += ' -fPIC'
279 pnacl_cxx_flags += ' -fPIC' 283 pnacl_cxx_flags += ' -fPIC'
280 # NOTE: this is a special hack for the pnacl backend which 284 # NOTE: this is a special hack for the pnacl backend which
281 # does more than linking 285 # does more than linking
282 pnacl_ld_flags += ' -fPIC' 286 pnacl_ld_flags += ' -fPIC'
287 pnacl_translate_flags += ' -fPIC'
283 288
284 if env.Bit('use_sandboxed_translator'): 289 if env.Bit('use_sandboxed_translator'):
285 pnacl_ld_flags += ' --pnacl-sb --pnacl-default-command-line' 290 sb_flags = ' --pnacl-sb --pnacl-default-command-line'
286 if env.Bit('sandboxed_translator_is_dynamic'): 291 if env.Bit('sandboxed_translator_is_dynamic'):
287 pnacl_ld_flags += ' --pnacl-sb-dynamic' 292 sb_flags += ' --pnacl-sb-dynamic'
293 pnacl_ld_flags += sb_flags
294 pnacl_translate_flags += sb_flags
288 295
289 if pnacl_extra_lib: 296 if pnacl_extra_lib:
290 env.Prepend(LIBPATH=pnacl_extra_lib) 297 env.Prepend(LIBPATH=pnacl_extra_lib)
291 298
292 env.Replace(# Replace header and lib paths. 299 env.Replace(# Replace header and lib paths.
293 PNACL_ROOT=root, 300 PNACL_ROOT=root,
294 NACL_SDK_INCLUDE=pnacl_include, 301 NACL_SDK_INCLUDE=pnacl_include,
295 NACL_SDK_LIB=pnacl_lib, 302 NACL_SDK_LIB=pnacl_lib,
296 # Replace the normal unix tools with the PNaCl ones. 303 # Replace the normal unix tools with the PNaCl ones.
297 CC=pnacl_cc + pnacl_cc_flags, 304 CC=pnacl_cc + pnacl_cc_flags,
298 CXX=pnacl_cxx + pnacl_cxx_flags, 305 CXX=pnacl_cxx + pnacl_cxx_flags,
299 ASPP=pnacl_cc + pnacl_cc_flags, 306 ASPP=pnacl_cc + pnacl_cc_flags,
300 LIBPREFIX="lib", 307 LIBPREFIX="lib",
301 SHLIBPREFIX="lib", 308 SHLIBPREFIX="lib",
302 SHLIBSUFFIX=".so", 309 SHLIBSUFFIX=".so",
303 OBJSUFFIX=".bc", 310 OBJSUFFIX=".bc",
304 LINK=pnacl_cxx + arch_flag + pnacl_ld_flags, 311 LINK=pnacl_cxx + ld_arch_flag + pnacl_ld_flags,
305 # Although we are currently forced to produce native output 312 # Although we are currently forced to produce native output
306 # for LINK, we are free to produce bitcode for SHLINK 313 # for LINK, we are free to produce bitcode for SHLINK
307 # (SharedLibrary linking) because scons doesn't do anything 314 # (SharedLibrary linking) because scons doesn't do anything
308 # with shared libraries except use them with the toolchain. 315 # with shared libraries except use them with the toolchain.
309 SHLINK=pnacl_cxx + arch_flag + pnacl_ld_flags, 316 SHLINK=pnacl_cxx + ld_arch_flag + pnacl_ld_flags,
310 LD=pnacl_ld, 317 LD=pnacl_ld,
311 NATIVELD=pnacl_nativeld, 318 NATIVELD=pnacl_nativeld,
312 AR=pnacl_ar, 319 AR=pnacl_ar,
313 AS=pnacl_as + arch_flag, 320 AS=pnacl_as + ld_arch_flag,
314 RANLIB=pnacl_ranlib, 321 RANLIB=pnacl_ranlib,
315 DISASS=pnacl_disass, 322 DISASS=pnacl_disass,
316 OBJDUMP=pnacl_disass, 323 OBJDUMP=pnacl_disass,
317 STRIP=pnacl_strip, 324 STRIP=pnacl_strip,
318 GENNMF=pnacl_nmf, 325 GENNMF=pnacl_nmf,
326 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags,
319 ) 327 )
320 328
321 329
322 def _SetEnvForSdkManually(env): 330 def _SetEnvForSdkManually(env):
323 def GetEnvOrDummy(v): 331 def GetEnvOrDummy(v):
324 return os.getenv('NACL_SDK_' + v, 'MISSING_SDK_' + v) 332 return os.getenv('NACL_SDK_' + v, 'MISSING_SDK_' + v)
325 333
326 env.Replace(# Replace header and lib paths. 334 env.Replace(# Replace header and lib paths.
327 NACL_SDK_INCLUDE=GetEnvOrDummy('INCLUDE'), 335 NACL_SDK_INCLUDE=GetEnvOrDummy('INCLUDE'),
328 NACL_SDK_LIB=GetEnvOrDummy('LIB'), 336 NACL_SDK_LIB=GetEnvOrDummy('LIB'),
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 # Dependency files it produces are to be found in ${LIBPATH}. 609 # Dependency files it produces are to be found in ${LIBPATH}.
602 # It is applied recursively to those dependencies in case 610 # It is applied recursively to those dependencies in case
603 # some of them are linker scripts too. 611 # some of them are linker scripts too.
604 ldscript_scanner = SCons.Scanner.Base( 612 ldscript_scanner = SCons.Scanner.Base(
605 function=ScanLinkerScript, 613 function=ScanLinkerScript,
606 skeys=['.a', '.so', '.pso'], 614 skeys=['.a', '.so', '.pso'],
607 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), 615 path_function=SCons.Scanner.FindPathDirs('LIBPATH'),
608 recursive=True 616 recursive=True
609 ) 617 )
610 env.Append(SCANNERS=ldscript_scanner) 618 env.Append(SCANNERS=ldscript_scanner)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698