Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright 2015 The Chromium Authors. All rights reserved. | 3 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Creates a script to run a "_incremental" .apk.""" | 7 """Creates a script to run a "_incremental" .apk.""" |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import os | 10 import os |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 return os.path.abspath(os.path.join(script_directory, path)) | 33 return os.path.abspath(os.path.join(script_directory, path)) |
| 34 | 34 |
| 35 cmd_path = resolve_path({cmd_path}) | 35 cmd_path = resolve_path({cmd_path}) |
| 36 cmd_args = [cmd_path] + {cmd_args} | 36 cmd_args = [cmd_path] + {cmd_args} |
| 37 cmd_path_args = {cmd_path_args} | 37 cmd_path_args = {cmd_path_args} |
| 38 for arg, path in cmd_path_args: | 38 for arg, path in cmd_path_args: |
| 39 if arg: | 39 if arg: |
| 40 cmd_args.append(arg) | 40 cmd_args.append(arg) |
| 41 cmd_args.append(resolve_path(path)) | 41 cmd_args.append(resolve_path(path)) |
| 42 | 42 |
| 43 os.environ['CHROMIUM_OUTPUT_DIR'] = resolve_path(os.pardir) | |
|
jbudorick
2015/09/11 16:47:53
Does it work without this? If so, take this out. I
agrieve
2015/09/11 19:58:55
Whoops, yep, that should not be there.
| |
| 43 return subprocess.call(cmd_args + sys.argv[1:]) | 44 return subprocess.call(cmd_args + sys.argv[1:]) |
| 44 | 45 |
| 45 if __name__ == '__main__': | 46 if __name__ == '__main__': |
| 46 sys.exit(main()) | 47 sys.exit(main()) |
| 47 """ | 48 """ |
| 48 | 49 |
| 49 | 50 |
| 50 def main(args): | 51 def main(args): |
| 51 args = build_utils.ExpandFileArgs(args) | 52 args = build_utils.ExpandFileArgs(args) |
| 52 parser = argparse.ArgumentParser() | 53 parser = argparse.ArgumentParser() |
| 53 build_utils.AddDepfileOption(parser) | 54 build_utils.AddDepfileOption(parser) |
| 54 parser.add_argument('--script-output-path', | 55 parser.add_argument('--script-output-path', |
| 55 help='Output path for executable script.', | 56 help='Output path for executable script.', |
| 56 required=True) | 57 required=True) |
| 58 parser.add_argument('--output-directory', | |
| 59 help='Path to the root build directory.', | |
| 60 default='.') | |
| 57 parser.add_argument('--apk-path', | 61 parser.add_argument('--apk-path', |
| 58 help='Path to the .apk to install.', | 62 help='Path to the .apk to install.', |
| 59 required=True) | 63 required=True) |
| 60 parser.add_argument('--split', | 64 parser.add_argument('--split', |
| 61 action='append', | 65 action='append', |
| 62 dest='splits', | 66 dest='splits', |
| 63 default=[], | 67 default=[], |
| 64 help='A glob matching the apk splits. ' | 68 help='A glob matching the apk splits. ' |
| 65 'Can be specified multiple times.') | 69 'Can be specified multiple times.') |
| 66 parser.add_argument('--lib-dir', | 70 parser.add_argument('--lib-dir', |
| 67 help='Path to native libraries directory.') | 71 help='Path to native libraries directory.') |
| 68 | 72 |
| 69 options = parser.parse_args(args) | 73 options = parser.parse_args(args) |
| 70 | 74 |
| 71 def relativize(path): | 75 def relativize(path): |
| 72 return os.path.relpath(path, os.path.dirname(options.script_output_path)) | 76 return os.path.relpath(path, os.path.dirname(options.script_output_path)) |
| 73 | 77 |
| 74 incremental_install_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build', | 78 incremental_install_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build', |
| 75 'android', 'incremental_install.py') | 79 'android', 'incremental_install.py') |
| 76 incremental_install_path = relativize(incremental_install_path) | 80 incremental_install_path = relativize(incremental_install_path) |
| 77 | 81 |
| 78 incremental_install_path_args = [ | 82 incremental_install_path_args = [ |
| 83 ('--output-directory', relativize(options.output_directory)), | |
| 79 (None, relativize(options.apk_path)), | 84 (None, relativize(options.apk_path)), |
| 80 ] | 85 ] |
| 81 if options.lib_dir: | 86 if options.lib_dir: |
| 82 incremental_install_path_args.append( | 87 incremental_install_path_args.append( |
| 83 ('--lib-dir', relativize(options.lib_dir))) | 88 ('--lib-dir', relativize(options.lib_dir))) |
| 84 for split_arg in options.splits: | 89 for split_arg in options.splits: |
| 85 incremental_install_path_args.append(('--split', relativize(split_arg))) | 90 incremental_install_path_args.append(('--split', relativize(split_arg))) |
| 86 | 91 |
| 87 with open(options.script_output_path, 'w') as script: | 92 with open(options.script_output_path, 'w') as script: |
| 88 script.write(SCRIPT_TEMPLATE.format( | 93 script.write(SCRIPT_TEMPLATE.format( |
| 89 cmd_path=repr(incremental_install_path), | 94 cmd_path=repr(incremental_install_path), |
| 90 cmd_args='[]', | 95 cmd_args='[]', |
| 91 cmd_path_args=repr(incremental_install_path_args))) | 96 cmd_path_args=repr(incremental_install_path_args))) |
| 92 | 97 |
| 93 os.chmod(options.script_output_path, 0750) | 98 os.chmod(options.script_output_path, 0750) |
| 94 | 99 |
| 95 if options.depfile: | 100 if options.depfile: |
| 96 build_utils.WriteDepfile( | 101 build_utils.WriteDepfile( |
| 97 options.depfile, | 102 options.depfile, |
| 98 build_utils.GetPythonDependencies()) | 103 build_utils.GetPythonDependencies()) |
| 99 | 104 |
| 100 | 105 |
| 101 if __name__ == '__main__': | 106 if __name__ == '__main__': |
| 102 sys.exit(main(sys.argv[1:])) | 107 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |