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

Side by Side Diff: tools/llvm/driver/pnacl-dis.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-dgcc.py ('k') | tools/llvm/driver/pnacl-driver.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 'FLAGS' : '',
18 }
19 env.update(EXTRA_ENV)
20
21 DISPatterns = [
22 ( ('-o','(.*)'), "env.set('OUTPUT', pathtools.normalize($0))"),
23 ( '(-.*)', "env.append('FLAGS', $0)"),
24 ( '(.*)', "env.append('INPUTS', pathtools.normalize($0))"),
25 ]
26
27 def main(argv):
28 ParseArgs(argv, DISPatterns)
29
30 inputs = env.get('INPUTS')
31 output = env.getone('OUTPUT')
32
33 if len(inputs) == 0:
34 Log.Fatal("No input files given")
35
36 if len(inputs) > 1 and output != '':
37 Log.Fatal("Cannot have -o with multiple inputs")
38
39 for infile in inputs:
40 env.push()
41 env.set('input', infile)
42 env.set('output', output)
43
44 # When we output to stdout, set redirect_stdout and set log_stdout
45 # to False to bypass the driver's line-by-line handling of stdout
46 # which is extremely slow when you have a lot of output
47
48 if IsBitcode(infile):
49 if output == '':
50 # LLVM by default outputs to a file if -o is missing
51 # Let's instead output to stdout
52 env.set('output', '-')
53 env.append('FLAGS', '-f')
54 RunWithLog('${LLVM_DIS} ${FLAGS} ${input} -o ${output}',
55 log_stdout = False)
56 elif IsELF(infile):
57 flags = env.get('FLAGS')
58 if len(flags) == 0:
59 env.append('FLAGS', '-d')
60 if output == '':
61 # objdump to stdout
62 RunWithLog('${OBJDUMP} ${FLAGS} ${input}',
63 log_stdout = False, log_stderr = False)
64 else:
65 # objdump always outputs to stdout, and doesn't recognize -o
66 # Let's add this feature to be consistent.
67 fp = DriverOpen(output, 'w')
68 RunWithLog('${OBJDUMP} ${FLAGS} ${input}',
69 echo_stdout = False, log_stdout = False,
70 redirect_stdout = fp)
71 DriverClose(fp)
72 else:
73 Log.Fatal('Unknown file type')
74 env.pop()
75
76 return 0
77
78 if __name__ == "__main__":
79 DriverMain(main)
OLDNEW
« no previous file with comments | « tools/llvm/driver/pnacl-dgcc.py ('k') | tools/llvm/driver/pnacl-driver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698