OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 | |
7 import argparse | |
8 import json | |
9 import sys | |
10 | |
11 from util import build_utils | |
12 | |
13 | |
14 def ParseArgs(): | |
15 parser = argparse.ArgumentParser() | |
16 parser.add_argument('--configuration-name', required=True, | |
17 help='The build CONFIGURATION_NAME.') | |
18 parser.add_argument('--enabled-configurations', default=[], | |
19 help='The configuration(s) for which multidex should be ' | |
20 'enabled. If not specified and --enable-multidex is ' | |
21 'passed, multidex will be enabled for all ' | |
22 'configurations.') | |
23 parser.add_argument('--enable-multidex', action='store_true', default=False, | |
24 help='Whether or not multidex should be enabled.') | |
25 parser.add_argument('--multidex-configuration-path', required=True, | |
26 help='The path to which the multidex configuration JSON ' | |
27 'should be saved.') | |
28 parser.add_argument('--tested-apk-multidex-configuration-path', | |
29 help='The path to a preexisting ') | |
Yaron
2015/11/11 02:06:38
truncated
jbudorick
2015/11/12 20:33:40
This parameter wasn't necessary after implementing
| |
30 parser.add_argument('--multidex-disabled-libs', required=True, | |
31 help='The libraries to link if multidex is disabled.') | |
32 parser.add_argument('--multidex-enabled-libs', | |
33 help='The libraries to link if multidex is enabled.') | |
34 | |
35 args = parser.parse_args() | |
36 | |
37 if args.enabled_configurations: | |
38 args.enabled_configurations = build_utils.ParseGypList( | |
39 args.enabled_configurations) | |
40 | |
41 if args.multidex_disabled_libs: | |
42 args.multidex_disabled_libs = build_utils.ParseGypList( | |
43 args.multidex_disabled_libs) | |
44 | |
45 if args.multidex_enabled_libs: | |
46 args.multidex_enabled_libs = build_utils.ParseGypList( | |
47 args.multidex_enabled_libs) | |
48 | |
49 return args | |
50 | |
51 | |
52 def main(): | |
53 args = ParseArgs() | |
54 | |
55 multidex_enabled = ( | |
56 args.enable_multidex | |
57 and (not args.enabled_configurations | |
58 or args.configuration_name in args.enabled_configurations)) | |
59 | |
60 if args.tested_apk_multidex_configuration_path: | |
61 with open(args.tested_apk_multidex_configuration_path) as f: | |
62 tested_apk_config = json.loads(f.read()) | |
63 libs = tested_apk_config['libs'] | |
64 elif multidex_enabled: | |
65 assert args.multidex_enabled_libs | |
66 libs = args.multidex_enabled_libs | |
67 else: | |
68 libs = args.multidex_disabled_libs | |
69 | |
70 config = { | |
71 'enabled': multidex_enabled, | |
72 'libs': libs, | |
73 } | |
74 | |
75 with open(args.multidex_configuration_path, 'w') as f: | |
76 f.write(json.dumps(config)) | |
77 | |
78 return 0 | |
79 | |
80 | |
81 if __name__ == '__main__': | |
82 sys.exit(main()) | |
83 | |
OLD | NEW |