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

Side by Side Diff: build/toolchain/gcc_link_wrapper.py

Issue 1432603003: GN: Avoid nontrivial shell commands in gcc_toolchain tool("link") (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | build/toolchain/gcc_toolchain.gni » ('j') | build/toolchain/nacl/BUILD.gn » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
Dirk Pranke 2015/11/03 23:49:13 nit: probably should remove the shebang line.
Roland McGrath 2015/11/04 00:06:44 I'm following the example of all the .py files I'v
2 # Copyright 2015 The Chromium 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 """Runs a linking command and optionally a strip command.
7
8 This script exists to avoid using complex shell commands in
9 gcc_toolchain.gni's tool("link"), in case the host running the compiler
10 does not have a POSIX-like shell (e.g. Windows).
11 """
12
13 import argparse
14 import subprocess
15 import sys
16
17
18 def main():
19 parser = argparse.ArgumentParser(description=__doc__)
20 parser.add_argument('--strip',
21 help='The strip binary to run',
22 metavar='PATH')
23 parser.add_argument('--unstripped-file',
24 required=True,
25 help='Executable file produced by linking command',
26 metavar='FILE')
27 parser.add_argument('--output',
28 required=True,
29 help='Final output executable file',
30 metavar='FILE')
31 parser.add_argument('command', nargs='+',
32 help='Linking command')
33 args = parser.parse_args()
34
35 # First, run the actual link.
36 result = subprocess.call(args.command)
37 if result != 0:
38 return result
39
40 # Finally, strip the linked executable (if desired).
41 if args.strip:
42 command = [args.strip, '-o', args.output, args.unstripped_file]
43 # TODO(mcgrathr): Make the switch unconditional after pnacl-finalize
44 # is taught to accept it.
45 if not args.strip.endswith('pnacl-finalize'):
46 command.insert(1, '--strip-unneeded')
47 result = subprocess.call(command)
48
49 return result
50
51
52 if __name__ == "__main__":
53 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/toolchain/gcc_toolchain.gni » ('j') | build/toolchain/nacl/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698