OLD | NEW |
(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()) |
OLD | NEW |