OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 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 """Generates the obfuscated jar and test jar for an apk. | 7 """Generates the obfuscated jar and test jar for an apk. |
8 | 8 |
9 If proguard is not enabled or 'Release' is not in the configuration name, | 9 If proguard is not enabled or 'Release' is not in the configuration name, |
10 obfuscation will be a no-op. | 10 obfuscation will be a no-op. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 ) | 94 ) |
95 | 95 |
96 build_utils.CheckOptions(options, parser, required=required_options) | 96 build_utils.CheckOptions(options, parser, required=required_options) |
97 return options, args | 97 return options, args |
98 | 98 |
99 | 99 |
100 def DoProguard(options): | 100 def DoProguard(options): |
101 proguard = proguard_util.ProguardCmdBuilder(options.proguard_jar_path) | 101 proguard = proguard_util.ProguardCmdBuilder(options.proguard_jar_path) |
102 proguard.outjar(options.obfuscated_jar_path) | 102 proguard.outjar(options.obfuscated_jar_path) |
103 | 103 |
104 input_jars = build_utils.ParseGypList(options.input_jars_paths) | 104 input_jars = build_utils.ParseGnList(options.input_jars_paths) |
105 | 105 |
106 exclude_paths = [] | 106 exclude_paths = [] |
107 configs = build_utils.ParseGypList(options.proguard_configs) | 107 configs = build_utils.ParseGnList(options.proguard_configs) |
108 if options.tested_apk_obfuscated_jar_path: | 108 if options.tested_apk_obfuscated_jar_path: |
109 # configs should only contain the process_resources.py generated config. | 109 # configs should only contain the process_resources.py generated config. |
110 assert len(configs) == 1, ( | 110 assert len(configs) == 1, ( |
111 'test apks should not have custom proguard configs: ' + str(configs)) | 111 'test apks should not have custom proguard configs: ' + str(configs)) |
112 proguard.tested_apk_info(options.tested_apk_obfuscated_jar_path + '.info') | 112 proguard.tested_apk_info(options.tested_apk_obfuscated_jar_path + '.info') |
113 | 113 |
114 proguard.libraryjars([options.android_sdk_jar]) | 114 proguard.libraryjars([options.android_sdk_jar]) |
115 proguard_injars = [p for p in input_jars if p not in exclude_paths] | 115 proguard_injars = [p for p in input_jars if p not in exclude_paths] |
116 proguard.injars(proguard_injars) | 116 proguard.injars(proguard_injars) |
117 | 117 |
(...skipping 28 matching lines...) Expand all Loading... |
146 dir=os.path.dirname(options.main_dex_list_path), | 146 dir=os.path.dirname(options.main_dex_list_path), |
147 prefix='main_dex_list_proguard', | 147 prefix='main_dex_list_proguard', |
148 suffix='.flags') as main_dex_config_file: | 148 suffix='.flags') as main_dex_config_file: |
149 main_dex_config_file.write(main_dex_list_config) | 149 main_dex_config_file.write(main_dex_list_config) |
150 return main_dex_config_file.name | 150 return main_dex_config_file.name |
151 | 151 |
152 | 152 |
153 def main(argv): | 153 def main(argv): |
154 options, _ = ParseArgs(argv) | 154 options, _ = ParseArgs(argv) |
155 | 155 |
156 input_jars = build_utils.ParseGypList(options.input_jars_paths) | 156 input_jars = build_utils.ParseGnList(options.input_jars_paths) |
157 | 157 |
158 if options.testapp: | 158 if options.testapp: |
159 dependency_class_filters = [ | 159 dependency_class_filters = [ |
160 '*R.class', '*R$*.class', '*Manifest.class', '*BuildConfig.class'] | 160 '*R.class', '*R$*.class', '*Manifest.class', '*BuildConfig.class'] |
161 build_utils.MergeZips( | 161 build_utils.MergeZips( |
162 options.test_jar_path, input_jars, dependency_class_filters) | 162 options.test_jar_path, input_jars, dependency_class_filters) |
163 | 163 |
164 if ((options.configuration_name == 'Release' and options.proguard_enabled) or | 164 if ((options.configuration_name == 'Release' and options.proguard_enabled) or |
165 (options.configuration_name == 'Debug' and | 165 (options.configuration_name == 'Debug' and |
166 options.debug_build_proguard_enabled)): | 166 options.debug_build_proguard_enabled)): |
167 DoProguard(options) | 167 DoProguard(options) |
168 else: | 168 else: |
169 output_files = [ | 169 output_files = [ |
170 options.obfuscated_jar_path, | 170 options.obfuscated_jar_path, |
171 options.obfuscated_jar_path + '.info', | 171 options.obfuscated_jar_path + '.info', |
172 options.obfuscated_jar_path + '.dump', | 172 options.obfuscated_jar_path + '.dump', |
173 options.obfuscated_jar_path + '.seeds', | 173 options.obfuscated_jar_path + '.seeds', |
174 options.obfuscated_jar_path + '.usage', | 174 options.obfuscated_jar_path + '.usage', |
175 options.obfuscated_jar_path + '.mapping'] | 175 options.obfuscated_jar_path + '.mapping'] |
176 for f in output_files: | 176 for f in output_files: |
177 if os.path.exists(f): | 177 if os.path.exists(f): |
178 os.remove(f) | 178 os.remove(f) |
179 build_utils.Touch(f) | 179 build_utils.Touch(f) |
180 | 180 |
181 if options.stamp: | 181 if options.stamp: |
182 build_utils.Touch(options.stamp) | 182 build_utils.Touch(options.stamp) |
183 | 183 |
184 if __name__ == '__main__': | 184 if __name__ == '__main__': |
185 sys.exit(main(sys.argv[1:])) | 185 sys.exit(main(sys.argv[1:])) |
OLD | NEW |