Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: build/android/gyp/apk_obfuscate.py

Issue 1436083002: Revert of GN: Enable proguard for apks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/gyp/proguard.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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]
88 input_jars = build_utils.ParseGypList(options.input_jars_paths) 89 input_jars = build_utils.ParseGypList(options.input_jars_paths)
89 90
90 exclude_paths = [] 91 exclude_paths = []
91 configs = build_utils.ParseGypList(options.proguard_configs) 92 configs = build_utils.ParseGypList(options.proguard_configs)
92 if options.tested_apk_obfuscated_jar_path: 93 if options.tested_apk_obfuscated_jar_path:
93 # configs should only contain the process_resources.py generated config. 94 # configs should only contain the process_resources.py generated config.
94 assert len(configs) == 1, ( 95 assert len(configs) == 1, (
95 'test apks should not have custom proguard configs: ' + str(configs)) 96 'test apks should not have custom proguard configs: ' + str(configs))
96 proguard.tested_apk_info(options.tested_apk_obfuscated_jar_path + '.info') 97 tested_jar_info = build_utils.ReadJson(
98 options.tested_apk_obfuscated_jar_path + '.info')
99 exclude_paths = tested_jar_info['inputs']
100 configs = tested_jar_info['configs']
97 101
98 proguard.libraryjars([options.android_sdk_jar]) 102 proguard.is_test(True)
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)
99 proguard_injars = [p for p in input_jars if p not in exclude_paths] 107 proguard_injars = [p for p in input_jars if p not in exclude_paths]
100 proguard.injars(proguard_injars) 108 proguard.injars(proguard_injars)
101 proguard.configs(configs) 109 proguard.configs(configs)
102 110
103 proguard.CheckOutput() 111 proguard.CheckOutput()
104 112
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
105 121
106 def main(argv): 122 def main(argv):
107 options, _ = ParseArgs(argv) 123 options, _ = ParseArgs(argv)
108 124
109 input_jars = build_utils.ParseGypList(options.input_jars_paths) 125 input_jars = build_utils.ParseGypList(options.input_jars_paths)
110 126
111 if options.testapp: 127 if options.testapp:
112 dependency_class_filters = [ 128 dependency_class_filters = [
113 '*R.class', '*R$*.class', '*Manifest.class', '*BuildConfig.class'] 129 '*R.class', '*R$*.class', '*Manifest.class', '*BuildConfig.class']
114 build_utils.MergeZips( 130 build_utils.MergeZips(
(...skipping 14 matching lines...) Expand all
129 for f in output_files: 145 for f in output_files:
130 if os.path.exists(f): 146 if os.path.exists(f):
131 os.remove(f) 147 os.remove(f)
132 build_utils.Touch(f) 148 build_utils.Touch(f)
133 149
134 if options.stamp: 150 if options.stamp:
135 build_utils.Touch(options.stamp) 151 build_utils.Touch(options.stamp)
136 152
137 if __name__ == '__main__': 153 if __name__ == '__main__':
138 sys.exit(main(sys.argv[1:])) 154 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | build/android/gyp/proguard.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698