| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 help='Output path for jar containing all the test apk\'s ' | 62 help='Output path for jar containing all the test apk\'s ' |
| 63 'code.') | 63 'code.') |
| 64 | 64 |
| 65 parser.add_option('--stamp', help='File to touch on success') | 65 parser.add_option('--stamp', help='File to touch on success') |
| 66 | 66 |
| 67 parser.add_option('--main-dex-list-path', | 67 parser.add_option('--main-dex-list-path', |
| 68 help='The list of classes to retain in the main dex. ' | 68 help='The list of classes to retain in the main dex. ' |
| 69 'These will not be obfuscated.') | 69 'These will not be obfuscated.') |
| 70 parser.add_option('--multidex-configuration-path', | 70 parser.add_option('--multidex-configuration-path', |
| 71 help='A JSON file containing multidex build configuration.') | 71 help='A JSON file containing multidex build configuration.') |
| 72 parser.add_option('--verbose', '-v', action='store_true', |
| 73 help='Print all proguard output') |
| 72 | 74 |
| 73 (options, args) = parser.parse_args(argv) | 75 (options, args) = parser.parse_args(argv) |
| 74 | 76 |
| 75 if args: | 77 if args: |
| 76 parser.error('No positional arguments should be given. ' + str(args)) | 78 parser.error('No positional arguments should be given. ' + str(args)) |
| 77 | 79 |
| 78 # Check that required options have been provided. | 80 # Check that required options have been provided. |
| 79 required_options = ( | 81 required_options = ( |
| 80 'android_sdk', | 82 'android_sdk', |
| 81 'android_sdk_tools', | 83 'android_sdk_tools', |
| (...skipping 29 matching lines...) Expand all Loading... |
| 111 | 113 |
| 112 proguard.libraryjars([options.android_sdk_jar]) | 114 proguard.libraryjars([options.android_sdk_jar]) |
| 113 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] |
| 114 proguard.injars(proguard_injars) | 116 proguard.injars(proguard_injars) |
| 115 | 117 |
| 116 multidex_config = _PossibleMultidexConfig(options) | 118 multidex_config = _PossibleMultidexConfig(options) |
| 117 if multidex_config: | 119 if multidex_config: |
| 118 configs.append(multidex_config) | 120 configs.append(multidex_config) |
| 119 | 121 |
| 120 proguard.configs(configs) | 122 proguard.configs(configs) |
| 121 proguard.CheckOutput() | 123 proguard.CheckOutput(options.verbose) |
| 122 | 124 |
| 123 | 125 |
| 124 def _PossibleMultidexConfig(options): | 126 def _PossibleMultidexConfig(options): |
| 125 if not options.multidex_configuration_path: | 127 if not options.multidex_configuration_path: |
| 126 return None | 128 return None |
| 127 | 129 |
| 128 with open(options.multidex_configuration_path) as multidex_config_file: | 130 with open(options.multidex_configuration_path) as multidex_config_file: |
| 129 multidex_config = json.loads(multidex_config_file.read()) | 131 multidex_config = json.loads(multidex_config_file.read()) |
| 130 | 132 |
| 131 if not (multidex_config.get('enabled') and options.main_dex_list_path): | 133 if not (multidex_config.get('enabled') and options.main_dex_list_path): |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 for f in output_files: | 175 for f in output_files: |
| 174 if os.path.exists(f): | 176 if os.path.exists(f): |
| 175 os.remove(f) | 177 os.remove(f) |
| 176 build_utils.Touch(f) | 178 build_utils.Touch(f) |
| 177 | 179 |
| 178 if options.stamp: | 180 if options.stamp: |
| 179 build_utils.Touch(options.stamp) | 181 build_utils.Touch(options.stamp) |
| 180 | 182 |
| 181 if __name__ == '__main__': | 183 if __name__ == '__main__': |
| 182 sys.exit(main(sys.argv[1:])) | 184 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |