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

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: gn set-but-unused nit 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') | 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/env python
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 result = subprocess.call([args.strip, '--strip-unneeded',
43 '-o', args.output, args.unstripped_file])
44
45 return result
46
47
48 if __name__ == "__main__":
49 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/toolchain/gcc_toolchain.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698