OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # |
| 3 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 """Creates a simple wrapper script that passes the correct --output-directory. |
| 8 """ |
| 9 |
| 10 import argparse |
| 11 import os |
| 12 |
| 13 _TEMPLATE = """\ |
| 14 #!/usr/bin/env python |
| 15 # |
| 16 # This file was generated by //build/android/gyp/create_tool_script.py |
| 17 |
| 18 import os |
| 19 import sys |
| 20 |
| 21 cmd = '{cmd}' |
| 22 args = [os.path.basename(cmd), '{flag_name}={output_directory}'] + sys.argv[1:] |
| 23 os.execv(cmd, args) |
| 24 """ |
| 25 |
| 26 def main(): |
| 27 parser = argparse.ArgumentParser() |
| 28 parser.add_argument('--output', help='Output path for executable script.') |
| 29 parser.add_argument('--target', help='Path to script being wrapped.') |
| 30 parser.add_argument('--output-directory', help='Value for --output-directory') |
| 31 parser.add_argument('--flag-name', |
| 32 help='Flag name to use instead of --output-directory', |
| 33 default='--output-directory') |
| 34 args = parser.parse_args() |
| 35 |
| 36 with open(args.output, 'w') as script: |
| 37 script.write(_TEMPLATE.format( |
| 38 cmd=os.path.abspath(args.target), |
| 39 flag_name=args.flag_name, |
| 40 output_directory=os.path.abspath(args.output_directory))) |
| 41 |
| 42 os.chmod(args.output, 0750) |
| 43 |
| 44 |
| 45 if __name__ == '__main__': |
| 46 main() |
OLD | NEW |