| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 ) | 73 ) |
| 74 | 74 |
| 75 build_utils.CheckOptions(options, parser, required=required_options) | 75 build_utils.CheckOptions(options, parser, required=required_options) |
| 76 return options, args | 76 return options, args |
| 77 | 77 |
| 78 | 78 |
| 79 def DoProguard(options): | 79 def DoProguard(options): |
| 80 proguard = proguard_util.ProguardCmdBuilder(options.proguard_jar_path) | 80 proguard = proguard_util.ProguardCmdBuilder(options.proguard_jar_path) |
| 81 proguard.outjar(options.obfuscated_jar_path) | 81 proguard.outjar(options.obfuscated_jar_path) |
| 82 | 82 |
| 83 library_classpath = [options.android_sdk_jar] | |
| 84 input_jars = build_utils.ParseGypList(options.input_jars_paths) | 83 input_jars = build_utils.ParseGypList(options.input_jars_paths) |
| 85 | 84 |
| 86 exclude_paths = [] | 85 exclude_paths = [] |
| 87 configs = build_utils.ParseGypList(options.proguard_configs) | 86 configs = build_utils.ParseGypList(options.proguard_configs) |
| 88 if options.tested_apk_obfuscated_jar_path: | 87 if options.tested_apk_obfuscated_jar_path: |
| 89 # configs should only contain the process_resources.py generated config. | 88 # configs should only contain the process_resources.py generated config. |
| 90 assert len(configs) == 1, ( | 89 assert len(configs) == 1, ( |
| 91 'test apks should not have custom proguard configs: ' + str(configs)) | 90 'test apks should not have custom proguard configs: ' + str(configs)) |
| 92 tested_jar_info = build_utils.ReadJson( | 91 proguard.tested_apk_info(options.tested_apk_obfuscated_jar_path + '.info') |
| 93 options.tested_apk_obfuscated_jar_path + '.info') | |
| 94 exclude_paths = tested_jar_info['inputs'] | |
| 95 configs = tested_jar_info['configs'] | |
| 96 | 92 |
| 97 proguard.is_test(True) | 93 proguard.libraryjars([options.android_sdk_jar]) |
| 98 proguard.mapping(options.tested_apk_obfuscated_jar_path + '.mapping') | |
| 99 library_classpath.append(options.tested_apk_obfuscated_jar_path) | |
| 100 | |
| 101 proguard.libraryjars(library_classpath) | |
| 102 proguard_injars = [p for p in input_jars if p not in exclude_paths] | 94 proguard_injars = [p for p in input_jars if p not in exclude_paths] |
| 103 proguard.injars(proguard_injars) | 95 proguard.injars(proguard_injars) |
| 104 proguard.configs(configs) | 96 proguard.configs(configs) |
| 105 | 97 |
| 106 proguard.CheckOutput() | 98 proguard.CheckOutput() |
| 107 | 99 |
| 108 this_info = { | |
| 109 'inputs': proguard_injars, | |
| 110 'configs': configs | |
| 111 } | |
| 112 | |
| 113 build_utils.WriteJson( | |
| 114 this_info, options.obfuscated_jar_path + '.info') | |
| 115 | |
| 116 | 100 |
| 117 def main(argv): | 101 def main(argv): |
| 118 options, _ = ParseArgs(argv) | 102 options, _ = ParseArgs(argv) |
| 119 | 103 |
| 120 input_jars = build_utils.ParseGypList(options.input_jars_paths) | 104 input_jars = build_utils.ParseGypList(options.input_jars_paths) |
| 121 | 105 |
| 122 if options.testapp: | 106 if options.testapp: |
| 123 dependency_class_filters = [ | 107 dependency_class_filters = [ |
| 124 '*R.class', '*R$*.class', '*Manifest.class', '*BuildConfig.class'] | 108 '*R.class', '*R$*.class', '*Manifest.class', '*BuildConfig.class'] |
| 125 build_utils.MergeZips( | 109 build_utils.MergeZips( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 138 for f in output_files: | 122 for f in output_files: |
| 139 if os.path.exists(f): | 123 if os.path.exists(f): |
| 140 os.remove(f) | 124 os.remove(f) |
| 141 build_utils.Touch(f) | 125 build_utils.Touch(f) |
| 142 | 126 |
| 143 if options.stamp: | 127 if options.stamp: |
| 144 build_utils.Touch(options.stamp) | 128 build_utils.Touch(options.stamp) |
| 145 | 129 |
| 146 if __name__ == '__main__': | 130 if __name__ == '__main__': |
| 147 sys.exit(main(sys.argv[1:])) | 131 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |