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 import argparse | 7 import argparse |
8 import json | 8 import json |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 22 matching lines...) Expand all Loading... |
33 help='The build configurations for which a main dex list' | 33 help='The build configurations for which a main dex list' |
34 ' should be generated.') | 34 ' should be generated.') |
35 parser.add_argument('--configuration-name', | 35 parser.add_argument('--configuration-name', |
36 help='The current build configuration.') | 36 help='The current build configuration.') |
37 parser.add_argument('--multidex-configuration-path', | 37 parser.add_argument('--multidex-configuration-path', |
38 help='A JSON file containing multidex build ' | 38 help='A JSON file containing multidex build ' |
39 'configuration.') | 39 'configuration.') |
40 parser.add_argument('--inputs', | 40 parser.add_argument('--inputs', |
41 help='JARs for which a main dex list should be ' | 41 help='JARs for which a main dex list should be ' |
42 'generated.') | 42 'generated.') |
| 43 parser.add_argument('--proguard-path', required=True, |
| 44 help='Path to the proguard executable.') |
| 45 |
43 parser.add_argument('paths', nargs='*', default=[], | 46 parser.add_argument('paths', nargs='*', default=[], |
44 help='JARs for which a main dex list should be ' | 47 help='JARs for which a main dex list should be ' |
45 'generated.') | 48 'generated.') |
46 | 49 |
47 args = parser.parse_args(build_utils.ExpandFileArgs(args)) | 50 args = parser.parse_args(build_utils.ExpandFileArgs(args)) |
48 | 51 |
49 if args.multidex_configuration_path: | 52 if args.multidex_configuration_path: |
50 with open(args.multidex_configuration_path) as multidex_config_file: | 53 with open(args.multidex_configuration_path) as multidex_config_file: |
51 multidex_config = json.loads(multidex_config_file.read()) | 54 multidex_config = json.loads(multidex_config_file.read()) |
52 | 55 |
53 if not multidex_config.get('enabled', False): | 56 if not multidex_config.get('enabled', False): |
54 return 0 | 57 return 0 |
55 | 58 |
56 if args.inputs: | 59 if args.inputs: |
57 args.paths.extend(build_utils.ParseGnList(args.inputs)) | 60 args.paths.extend(build_utils.ParseGnList(args.inputs)) |
58 | 61 |
59 shrinked_android_jar = os.path.abspath( | 62 shrinked_android_jar = os.path.abspath( |
60 os.path.join(args.android_sdk_tools, 'lib', 'shrinkedAndroid.jar')) | 63 os.path.join(args.android_sdk_tools, 'lib', 'shrinkedAndroid.jar')) |
61 dx_jar = os.path.abspath( | 64 dx_jar = os.path.abspath( |
62 os.path.join(args.android_sdk_tools, 'lib', 'dx.jar')) | 65 os.path.join(args.android_sdk_tools, 'lib', 'dx.jar')) |
63 rules_file = os.path.abspath( | 66 rules_file = os.path.abspath( |
64 os.path.join(args.android_sdk_tools, 'mainDexClasses.rules')) | 67 os.path.join(args.android_sdk_tools, 'mainDexClasses.rules')) |
65 | 68 |
66 proguard_cmd = [ | 69 proguard_cmd = [ |
67 constants.PROGUARD_SCRIPT_PATH, | 70 'java', '-jar', args.proguard_path, |
68 '-forceprocessing', | 71 '-forceprocessing', |
69 '-dontwarn', '-dontoptimize', '-dontobfuscate', '-dontpreverify', | 72 '-dontwarn', '-dontoptimize', '-dontobfuscate', '-dontpreverify', |
70 '-libraryjars', shrinked_android_jar, | 73 '-libraryjars', shrinked_android_jar, |
71 '-include', rules_file, | 74 '-include', rules_file, |
72 ] | 75 ] |
73 for m in args.main_dex_rules_paths: | 76 for m in args.main_dex_rules_paths: |
74 proguard_cmd.extend(['-include', m]) | 77 proguard_cmd.extend(['-include', m]) |
75 | 78 |
76 main_dex_list_cmd = [ | 79 main_dex_list_cmd = [ |
77 'java', '-cp', dx_jar, | 80 'java', '-cp', dx_jar, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 else: | 132 else: |
130 raise | 133 raise |
131 | 134 |
132 with open(main_dex_list_path, 'w') as main_dex_list_file: | 135 with open(main_dex_list_path, 'w') as main_dex_list_file: |
133 main_dex_list_file.write(main_dex_list) | 136 main_dex_list_file.write(main_dex_list) |
134 | 137 |
135 | 138 |
136 if __name__ == '__main__': | 139 if __name__ == '__main__': |
137 sys.exit(main(sys.argv[1:])) | 140 sys.exit(main(sys.argv[1:])) |
138 | 141 |
OLD | NEW |