Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2698)

Unified Diff: build/android/gn/create_incremental_install_script.py

Issue 1291793007: GN(android): Add scripts & runtime logic for installing _managed apks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-managed-install
Patch Set: fix compile Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/base.gyp ('k') | build/android/gyp/util/build_utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gn/create_incremental_install_script.py
diff --git a/build/android/gn/create_incremental_install_script.py b/build/android/gn/create_incremental_install_script.py
new file mode 100755
index 0000000000000000000000000000000000000000..d3aa16b949cf2c2ddbb84749887dca2bf183f858
--- /dev/null
+++ b/build/android/gn/create_incremental_install_script.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+
+# Copyright 2015 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 script to run a "_incremental" .apk."""
+
+import argparse
+import os
+import sys
+
+sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir))
+from gyp.util import build_utils
+from pylib import constants
+
+
+SCRIPT_TEMPLATE = """\
+#!/usr/bin/env python
+#
+# This file was generated by:
+# //build/android/gyp/create_incremental_install_script.py
+
+import os
+import subprocess
+import sys
+
+def main():
+ script_directory = os.path.dirname(__file__)
+
+ def resolve_path(path):
+ return os.path.abspath(os.path.join(script_directory, path))
+
+ cmd_path = resolve_path({cmd_path})
+ cmd_args = [cmd_path] + {cmd_args}
+ cmd_path_args = {cmd_path_args}
+ for arg, path in cmd_path_args:
+ if arg:
+ cmd_args.append(arg)
+ cmd_args.append(resolve_path(path))
+
+ return subprocess.call(cmd_args + sys.argv[1:])
+
+if __name__ == '__main__':
+ sys.exit(main())
+"""
+
+
+def main(args):
+ args = build_utils.ExpandFileArgs(args)
+ parser = argparse.ArgumentParser()
+ build_utils.AddDepfileOption(parser)
+ parser.add_argument('--script-output-path',
+ help='Output path for executable script.',
+ required=True)
+ parser.add_argument('--apk-path',
+ help='Path to the .apk to install.',
+ required=True)
+ parser.add_argument('--split',
+ action='append',
+ dest='splits',
+ default=[],
+ help='A glob matching the apk splits. '
+ 'Can be specified multiple times.')
+ parser.add_argument('--lib-dir',
+ help='Path to native libraries directory.')
+
+ options = parser.parse_args(args)
+
+ def relativize(path):
+ return os.path.relpath(path, os.path.dirname(options.script_output_path))
+
+ incremental_install_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build',
+ 'android', 'incremental_install.py')
+ incremental_install_path = relativize(incremental_install_path)
+
+ incremental_install_path_args = [
+ (None, relativize(options.apk_path)),
+ ]
+ if options.lib_dir:
+ incremental_install_path_args.append(
+ ('--lib-dir', relativize(options.lib_dir)))
+ for split_arg in options.splits:
+ incremental_install_path_args.append(('--split', relativize(split_arg)))
+
+ with open(options.script_output_path, 'w') as script:
+ script.write(SCRIPT_TEMPLATE.format(
+ cmd_path=repr(incremental_install_path),
+ cmd_args='[]',
+ cmd_path_args=repr(incremental_install_path_args)))
+
+ os.chmod(options.script_output_path, 0750)
+
+ if options.depfile:
+ build_utils.WriteDepfile(
+ options.depfile,
+ build_utils.GetPythonDependencies())
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
« no previous file with comments | « base/base.gyp ('k') | build/android/gyp/util/build_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698