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