Chromium Code Reviews| Index: build/android/gyp/create_tool_script.py |
| diff --git a/build/android/gyp/create_tool_script.py b/build/android/gyp/create_tool_script.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..7e4a293f2abebf6f094fd40310cd0d64f5387cb1 |
| --- /dev/null |
| +++ b/build/android/gyp/create_tool_script.py |
| @@ -0,0 +1,47 @@ |
| +#!/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
|
| +# |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Creates a simple wrapper script that passes the correct --output-directory. |
| +""" |
| + |
| +import argparse |
| +import os |
| + |
| +from util import build_utils |
| + |
| +# 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
|
| +# be user-supplied paths in the args. The script receives the classpath relative |
| +# to the directory that the script is written in and then, when run, must |
| +# recalculate the paths relative to the current directory. |
| +_TEMPLATE = """\ |
| +#!/usr/bin/env python |
| +# |
| +# This file was generated by //build/android/gyp/create_tool_script.py |
| + |
| +import os |
| +import sys |
| + |
| +args = ['--output-directory={output_directory}'] + sys.argv[1:] |
| +os.execv('{cmd}', args) |
| +""" |
| + |
| +def main(): |
| + parser = argparse.ArgumentParser() |
| + parser.add_argument('--output', help='Output path for executable script.') |
| + parser.add_argument('--target', help='Path to script being wrapped.') |
| + parser.add_argument('--output-directory', help='Value for --output-directory') |
| + args = parser.parse_args() |
| + |
| + with open(args.output, 'w') as script: |
| + script.write(_TEMPLATE.format( |
| + cmd=os.path.abspath(args.target), |
| + output_directory=os.path.abspath(args.output_directory))) |
| + |
| + os.chmod(args.output, 0750) |
| + |
| + |
| +if __name__ == '__main__': |
| + main() |