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

Side by Side Diff: tools/llvm/driver/pnacl-strip.py

Issue 8395028: Move tools/llvm/driver to pnacl/driver. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 9 years, 2 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 | « tools/llvm/driver/pnacl-ranlib.py ('k') | tools/llvm/driver/pnacl-translate.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
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
4 # found in the LICENSE file.
5 #
6 # IMPORTANT NOTE: If you make local mods to this file, you must run:
7 # % tools/llvm/utman.sh driver
8 # in order for them to take effect in the scons build. This command
9 # updates the copy in the toolchain/ tree.
10 #
11
12 from driver_tools import *
13
14 EXTRA_ENV = {
15 'INPUTS' : '',
16 'OUTPUT' : '',
17 'MODE' : 'all',
18 'OPT_FLAGS_all' : '-disable-opt --strip',
19 'OPT_FLAGS_debug' : '-disable-opt --strip-debug',
20 'STRIP_FLAGS_all' : '-s',
21 'STRIP_FLAGS_debug' : '-S',
22
23 'OPT_FLAGS' : '${OPT_FLAGS_%MODE%}',
24 'STRIP_FLAGS' : '${STRIP_FLAGS_%MODE%}',
25
26 'RUN_OPT' : '${LLVM_OPT} ${OPT_FLAGS} ${input} -o ${output}',
27 'RUN_STRIP' : '${STRIP} ${STRIP_FLAGS} ${input} -o ${output}',
28 }
29 env.update(EXTRA_ENV)
30
31 StripPatterns = [
32 ( ('-o','(.*)'), "env.set('OUTPUT', pathtools.normalize($0))"),
33 ( ('-o','(.*)'), "env.set('OUTPUT', pathtools.normalize($0))"),
34 ( '--strip-all', "env.set('MODE', 'all')"),
35 ( '-s', "env.set('MODE', 'all')"),
36
37 ( '--strip-debug', "env.set('MODE', 'debug')"),
38 ( '-S', "env.set('MODE', 'debug')"),
39 ( '(-.*)', UnrecognizedOption),
40
41 ( '(.*)', "env.append('INPUTS', pathtools.normalize($0))"),
42 ]
43
44 def main(argv):
45 ParseArgs(argv, StripPatterns)
46 inputs = env.get('INPUTS')
47 output = env.getone('OUTPUT')
48
49 if len(inputs) > 1 and output != '':
50 Log.Fatal('Cannot have -o with multiple inputs')
51
52 for f in inputs:
53 if output != '':
54 f_output = output
55 else:
56 f_output = f
57 if IsBitcode(f):
58 RunWithEnv('${RUN_OPT}', input = f, output = f_output)
59 elif IsELF(f):
60 RunWithEnv('${RUN_STRIP}', input = f, output = f_output)
61 else:
62 Log.Fatal('%s: File is neither ELF nor bitcode', pathtools.touser(f))
63 return 0
64
65 if __name__ == "__main__":
66 DriverMain(main)
OLDNEW
« no previous file with comments | « tools/llvm/driver/pnacl-ranlib.py ('k') | tools/llvm/driver/pnacl-translate.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698