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

Side by Side Diff: build/android/gn/create_incremental_install_script.py

Issue 1338813003: GN: Side-load dex files as well as native code in incremental installs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self review style nits Created 5 years, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2
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
5 # found in the LICENSE file.
6
7 """Creates a script to run a "_incremental" .apk."""
8
9 import argparse
10 import os
11 import sys
12
13 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir))
14 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'gyp'))
15 from util import build_utils
16 from pylib import constants
17
18
19 SCRIPT_TEMPLATE = """\
20 #!/usr/bin/env python
21 #
22 # This file was generated by:
23 # //build/android/gyp/create_incremental_install_script.py
24
25 import os
26 import subprocess
27 import sys
28
29 def main():
30 script_directory = os.path.dirname(__file__)
31
32 def resolve_path(path):
33 return os.path.abspath(os.path.join(script_directory, path))
34
35 cmd_path = resolve_path({cmd_path})
36 cmd_args = [cmd_path] + {cmd_args}
37 cmd_path_args = {cmd_path_args}
38 for arg, path in cmd_path_args:
39 if arg:
40 cmd_args.append(arg)
41 cmd_args.append(resolve_path(path))
42
43 return subprocess.call(cmd_args + sys.argv[1:])
44
45 if __name__ == '__main__':
46 sys.exit(main())
47 """
48
49
50 def main(args):
51 args = build_utils.ExpandFileArgs(args)
52 parser = argparse.ArgumentParser()
53 build_utils.AddDepfileOption(parser)
54 parser.add_argument('--script-output-path',
55 help='Output path for executable script.',
56 required=True)
57 parser.add_argument('--apk-path',
58 help='Path to the .apk to install.',
59 required=True)
60 parser.add_argument('--split',
61 action='append',
62 dest='splits',
63 default=[],
64 help='A glob matching the apk splits. '
65 'Can be specified multiple times.')
66 parser.add_argument('--lib-dir',
67 help='Path to native libraries directory.')
68
69 options = parser.parse_args(args)
70
71 def relativize(path):
72 return os.path.relpath(path, os.path.dirname(options.script_output_path))
73
74 incremental_install_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build',
75 'android', 'incremental_install.py')
76 incremental_install_path = relativize(incremental_install_path)
77
78 incremental_install_path_args = [
79 (None, relativize(options.apk_path)),
80 ]
81 if options.lib_dir:
82 incremental_install_path_args.append(
83 ('--lib-dir', relativize(options.lib_dir)))
84 for split_arg in options.splits:
85 incremental_install_path_args.append(('--split', relativize(split_arg)))
86
87 with open(options.script_output_path, 'w') as script:
88 script.write(SCRIPT_TEMPLATE.format(
89 cmd_path=repr(incremental_install_path),
90 cmd_args='[]',
91 cmd_path_args=repr(incremental_install_path_args)))
92
93 os.chmod(options.script_output_path, 0750)
94
95 if options.depfile:
96 build_utils.WriteDepfile(
97 options.depfile,
98 build_utils.GetPythonDependencies())
99
100
101 if __name__ == '__main__':
102 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698