Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
|
jbudorick
2016/02/03 19:46:27
It'd be nice if this could share logic with the ex
agrieve
2016/02/04 19:27:00
Just spent some time attempting this. Looked at:
-
jbudorick
2016/02/08 16:14:18
:(
ok
| |
| 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 from util import build_utils | |
| 14 | |
| 15 # The java command must be executed in the current directory because there may | |
|
jbudorick
2016/02/03 19:46:27
...? I'm not sure I follow the requirements implie
agrieve
2016/02/04 19:27:00
Whoops, left over from create_java_binary_script.p
| |
| 16 # be user-supplied paths in the args. The script receives the classpath relative | |
| 17 # to the directory that the script is written in and then, when run, must | |
| 18 # recalculate the paths relative to the current directory. | |
| 19 _TEMPLATE = """\ | |
| 20 #!/usr/bin/env python | |
| 21 # | |
| 22 # This file was generated by //build/android/gyp/create_tool_script.py | |
| 23 | |
| 24 import os | |
| 25 import sys | |
| 26 | |
| 27 args = ['--output-directory={output_directory}'] + sys.argv[1:] | |
| 28 os.execv('{cmd}', args) | |
| 29 """ | |
| 30 | |
| 31 def main(): | |
| 32 parser = argparse.ArgumentParser() | |
| 33 parser.add_argument('--output', help='Output path for executable script.') | |
| 34 parser.add_argument('--target', help='Path to script being wrapped.') | |
| 35 parser.add_argument('--output-directory', help='Value for --output-directory') | |
| 36 args = parser.parse_args() | |
| 37 | |
| 38 with open(args.output, 'w') as script: | |
| 39 script.write(_TEMPLATE.format( | |
| 40 cmd=os.path.abspath(args.target), | |
| 41 output_directory=os.path.abspath(args.output_directory))) | |
| 42 | |
| 43 os.chmod(args.output, 0750) | |
| 44 | |
| 45 | |
| 46 if __name__ == '__main__': | |
| 47 main() | |
| OLD | NEW |