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

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

Issue 12594036: Add a scons pnacl finalize step for pnacl_generate_pexe tests. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Use StripSuffix Created 7 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 | Annotate | Revision Log
« no previous file with comments | « site_scons/site_tools/component_setup.py ('k') | tests/barebones/nacl.scons » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 'pnacl-translate' + binext) 284 'pnacl-translate' + binext)
285 else: 285 else:
286 pnacl_translate = binprefix + 'translate' + binext 286 pnacl_translate = binprefix + 'translate' + binext
287 287
288 pnacl_cc = binprefix + 'clang' + binext 288 pnacl_cc = binprefix + 'clang' + binext
289 pnacl_cxx = binprefix + 'clang++' + binext 289 pnacl_cxx = binprefix + 'clang++' + binext
290 290
291 pnacl_ld = binprefix + 'ld' + binext 291 pnacl_ld = binprefix + 'ld' + binext
292 pnacl_nativeld = binprefix + 'nativeld' + binext 292 pnacl_nativeld = binprefix + 'nativeld' + binext
293 pnacl_disass = binprefix + 'dis' + binext 293 pnacl_disass = binprefix + 'dis' + binext
294 pnacl_finalize = binprefix + 'finalize' + binext
294 pnacl_strip = binprefix + 'strip' + binext 295 pnacl_strip = binprefix + 'strip' + binext
295 pnacl_nmf = binprefix + 'nmf' + binext 296 pnacl_nmf = binprefix + 'nmf' + binext
296 pnacl_link_and_translate = os.path.join(subroot, 297 pnacl_link_and_translate = os.path.join(subroot,
297 'bin', 298 'bin',
298 'wrapper-link-and-translate') + binext 299 'wrapper-link-and-translate') + binext
299 300
300 # NOTE: XXX_flags start with space for easy concatenation 301 # NOTE: XXX_flags start with space for easy concatenation
301 # The flags generated here get baked into the commands (CC, CXX, LINK) 302 # The flags generated here get baked into the commands (CC, CXX, LINK)
302 # instead of CFLAGS etc to keep them from getting blown away by some 303 # instead of CFLAGS etc to keep them from getting blown away by some
303 # tests. Don't add flags here unless they always need to be preserved. 304 # tests. Don't add flags here unless they always need to be preserved.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 LD=pnacl_ld, 346 LD=pnacl_ld,
346 NATIVELD=pnacl_nativeld, 347 NATIVELD=pnacl_nativeld,
347 AR=pnacl_ar, 348 AR=pnacl_ar,
348 AS=pnacl_as + ld_arch_flag, 349 AS=pnacl_as + ld_arch_flag,
349 RANLIB=pnacl_ranlib, 350 RANLIB=pnacl_ranlib,
350 DISASS=pnacl_disass, 351 DISASS=pnacl_disass,
351 OBJDUMP=pnacl_disass, 352 OBJDUMP=pnacl_disass,
352 STRIP=pnacl_strip, 353 STRIP=pnacl_strip,
353 GENNMF=pnacl_nmf, 354 GENNMF=pnacl_nmf,
354 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags, 355 TRANSLATE=pnacl_translate + arch_flag + pnacl_translate_flags,
356 PNACLFINALIZE=pnacl_finalize,
355 ) 357 )
356 358
357 if env.Bit('pnacl_shared_newlib'): 359 if env.Bit('pnacl_shared_newlib'):
358 def shlibemitter(target, source, env): 360 def shlibemitter(target, source, env):
359 """when building a .so also notify scons that we care about 361 """when building a .so also notify scons that we care about
360 the .pso which gets generated as a side-effect and which should 362 the .pso which gets generated as a side-effect and which should
361 also be installed. 363 also be installed.
362 This is a not very well documented scons API. 364 This is a not very well documented scons API.
363 """ 365 """
364 if env.Bit('pnacl_generate_pexe'): 366 if env.Bit('pnacl_generate_pexe'):
365 return (target, source) 367 return (target, source)
366 assert len(target) == 1 368 assert len(target) == 1
367 lib = env.GetBuildPath(target[0]) 369 lib = env.GetBuildPath(target[0])
368 assert lib.endswith(".so") 370 assert lib.endswith(".so")
369 return (target + [lib[:-2] + 'pso'], source) 371 return (target + [lib[:-2] + 'pso'], source)
370 372
371 env.Replace(LINK=pnacl_link_and_translate + arch_flag + ' -dynamic', 373 env.Replace(LINK=pnacl_link_and_translate + arch_flag + ' -dynamic',
372 SHLINK=pnacl_link_and_translate + arch_flag, 374 SHLINK=pnacl_link_and_translate + arch_flag,
373 SHLIBEMITTER=shlibemitter) 375 SHLIBEMITTER=shlibemitter)
374 376
375 377
376 if env.Bit('built_elsewhere'): 378 if env.Bit('built_elsewhere'):
377 def FakeInstall(dest, source, env): 379 def FakeInstall(dest, source, env):
378 print 'Not installing', dest 380 print 'Not installing', dest
379 _StubOutEnvToolsForBuiltElsewhere(env) 381 _StubOutEnvToolsForBuiltElsewhere(env)
380 env.Replace(INSTALL=FakeInstall) 382 env.Replace(INSTALL=FakeInstall)
381 if env.Bit('translate_in_build_step'): 383 if env.Bit('translate_in_build_step'):
382 env.Replace(TRANSLATE='true') 384 env.Replace(TRANSLATE='true')
385 env.Replace(PNACLFINALIZE='true')
383 386
384 387
385 def _SetEnvForSdkManually(env): 388 def _SetEnvForSdkManually(env):
386 def GetEnvOrDummy(v): 389 def GetEnvOrDummy(v):
387 return os.getenv('NACL_SDK_' + v, 'MISSING_SDK_' + v) 390 return os.getenv('NACL_SDK_' + v, 'MISSING_SDK_' + v)
388 391
389 env.Replace(# Replace header and lib paths. 392 env.Replace(# Replace header and lib paths.
390 NACL_SDK_INCLUDE=GetEnvOrDummy('INCLUDE'), 393 NACL_SDK_INCLUDE=GetEnvOrDummy('INCLUDE'),
391 NACL_SDK_LIB=GetEnvOrDummy('LIB'), 394 NACL_SDK_LIB=GetEnvOrDummy('LIB'),
392 # Replace the normal unix tools with the NaCl ones. 395 # Replace the normal unix tools with the NaCl ones.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 psdk_mode) 709 psdk_mode)
707 710
708 # Invoke the various unix tools that the NativeClient SDK resembles. 711 # Invoke the various unix tools that the NativeClient SDK resembles.
709 env.Tool('g++') 712 env.Tool('g++')
710 env.Tool('gcc') 713 env.Tool('gcc')
711 env.Tool('gnulink') 714 env.Tool('gnulink')
712 env.Tool('ar') 715 env.Tool('ar')
713 env.Tool('as') 716 env.Tool('as')
714 717
715 if env.Bit('pnacl_generate_pexe'): 718 if env.Bit('pnacl_generate_pexe'):
716 suffix = '.pexe' 719 suffix = '.nonfinal.pexe'
717 else: 720 else:
718 suffix = '.nexe' 721 suffix = '.nexe'
719 722
720 env.Replace( 723 env.Replace(
721 COMPONENT_LINKFLAGS=[''], 724 COMPONENT_LINKFLAGS=[''],
722 COMPONENT_LIBRARY_LINK_SUFFIXES=['.pso', '.so', '.a'], 725 COMPONENT_LIBRARY_LINK_SUFFIXES=['.pso', '.so', '.a'],
723 _RPATH='', 726 _RPATH='',
724 COMPONENT_LIBRARY_DEBUG_SUFFIXES=[], 727 COMPONENT_LIBRARY_DEBUG_SUFFIXES=[],
725 PROGSUFFIX=suffix, 728 PROGSUFFIX=suffix,
726 # adding BASE_ AND EXTRA_ flags to common command lines 729 # adding BASE_ AND EXTRA_ flags to common command lines
(...skipping 18 matching lines...) Expand all
745 748
746 LINKCOM='$LINK $BASE_LINKFLAGS $LINKFLAGS $EXTRA_LINKFLAGS ' + 749 LINKCOM='$LINK $BASE_LINKFLAGS $LINKFLAGS $EXTRA_LINKFLAGS ' +
747 '$SOURCES $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET', 750 '$SOURCES $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET',
748 SHLINKCOM='$SHLINK $BASE_LINKFLAGS $SHLINKFLAGS $EXTRA_LINKFLAGS ' + 751 SHLINKCOM='$SHLINK $BASE_LINKFLAGS $SHLINKFLAGS $EXTRA_LINKFLAGS ' +
749 '$SOURCES $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET', 752 '$SOURCES $_LIBDIRFLAGS $_LIBFLAGS -o $TARGET',
750 753
751 ASCOM='$AS $BASE_ASFLAGS $ASFLAGS $EXTRA_ASFLAGS -o $TARGET $SOURCES', 754 ASCOM='$AS $BASE_ASFLAGS $ASFLAGS $EXTRA_ASFLAGS -o $TARGET $SOURCES',
752 ASPPCOM='$ASPP $BASE_ASPPFLAGS $ASPPFLAGS $EXTRA_ASPPFLAGS ' + 755 ASPPCOM='$ASPP $BASE_ASPPFLAGS $ASPPFLAGS $EXTRA_ASPPFLAGS ' +
753 '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES', 756 '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -c -o $TARGET $SOURCES',
754 757
755 # Strip doesn't seem to be a first-class citizen in SCons country, 758 # Strip doesn't seem to be a first-class citizen in SCons country,
756 # so we have to add these *COM, *COMSTR manually. 759 # so we have to add these *COM, *COMSTR manually.
757 # Note: it appears we cannot add this in component_setup.py 760 # Note: it appears we cannot add this in component_setup.py
758 STRIPFLAGS=['--strip-all'], 761 STRIPFLAGS=['--strip-all'],
759 STRIPCOM='${STRIP} ${STRIPFLAGS}', 762 STRIPCOM='${STRIP} ${STRIPFLAGS}',
760 TRANSLATEFLAGS=['-Wl,-L${LIB_DIR}'], 763 TRANSLATEFLAGS=['-Wl,-L${LIB_DIR}'],
761 TRANSLATECOM='${TRANSLATE} ${TRANSLATEFLAGS} ${SOURCES} -o ${TARGET}', 764 TRANSLATECOM='${TRANSLATE} ${TRANSLATEFLAGS} ${SOURCES} -o ${TARGET}',
765 PNACLFINALIZEFLAGS=[],
766 PNACLFINALIZECOM='${PNACLFINALIZE} ${PNACLFINALIZEFLAGS} ' +
767 '${SOURCES} -o ${TARGET}',
762 ) 768 )
763 769
764 # Windows has a small limit on the command line size. The linking and AR 770 # Windows has a small limit on the command line size. The linking and AR
765 # commands can get quite large. So bring in the SCons machinery to put 771 # commands can get quite large. So bring in the SCons machinery to put
766 # most of a command line into a temporary file and pass it with 772 # most of a command line into a temporary file and pass it with
767 # @filename, which works with gcc. 773 # @filename, which works with gcc.
768 if env['PLATFORM'] in ['win32', 'cygwin']: 774 if env['PLATFORM'] in ['win32', 'cygwin']:
769 env['TEMPFILE'] = NaClTempFileMunge 775 env['TEMPFILE'] = NaClTempFileMunge
770 for com in ['LINKCOM', 'SHLINKCOM', 'ARCOM']: 776 for com in ['LINKCOM', 'SHLINKCOM', 'ARCOM']:
771 env[com] = "${TEMPFILE('%s')}" % env[com] 777 env[com] = "${TEMPFILE('%s')}" % env[com]
(...skipping 30 matching lines...) Expand all
802 # Dependency files it produces are to be found in ${LIBPATH}. 808 # Dependency files it produces are to be found in ${LIBPATH}.
803 # It is applied recursively to those dependencies in case 809 # It is applied recursively to those dependencies in case
804 # some of them are linker scripts too. 810 # some of them are linker scripts too.
805 ldscript_scanner = SCons.Scanner.Base( 811 ldscript_scanner = SCons.Scanner.Base(
806 function=ScanLinkerScript, 812 function=ScanLinkerScript,
807 skeys=['.a', '.so', '.pso'], 813 skeys=['.a', '.so', '.pso'],
808 path_function=SCons.Scanner.FindPathDirs('LIBPATH'), 814 path_function=SCons.Scanner.FindPathDirs('LIBPATH'),
809 recursive=True 815 recursive=True
810 ) 816 )
811 env.Append(SCANNERS=ldscript_scanner) 817 env.Append(SCANNERS=ldscript_scanner)
OLDNEW
« no previous file with comments | « site_scons/site_tools/component_setup.py ('k') | tests/barebones/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698