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

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

Issue 1127233005: Don't include tested apks resources in test apk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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 | « build/android/gyp/javac.py ('k') | chrome/android/BUILD.gn » ('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 """Writes a build_config file. 7 """Writes a build_config file.
8 8
9 The build_config file for a target is a json file containing information about 9 The build_config file for a target is a json file containing information about
10 how to build that target based on the target's dependencies. This includes 10 how to build that target based on the target's dependencies. This includes
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if not path in dep_config_cache: 72 if not path in dep_config_cache:
73 dep_config_cache[path] = build_utils.ReadJson(path)['deps_info'] 73 dep_config_cache[path] = build_utils.ReadJson(path)['deps_info']
74 return dep_config_cache[path] 74 return dep_config_cache[path]
75 75
76 76
77 def DepsOfType(wanted_type, configs): 77 def DepsOfType(wanted_type, configs):
78 return [c for c in configs if c['type'] == wanted_type] 78 return [c for c in configs if c['type'] == wanted_type]
79 79
80 80
81 def GetAllDepsConfigsInOrder(deps_config_paths): 81 def GetAllDepsConfigsInOrder(deps_config_paths):
82 def Deps(path): 82 def GetDeps(path):
83 return set(GetDepConfig(path)['deps_configs']) 83 return set(GetDepConfig(path)['deps_configs'])
84 return build_utils.GetSortedTransitiveDependencies(deps_config_paths, Deps) 84 return build_utils.GetSortedTransitiveDependencies(deps_config_paths, GetDeps)
85 85
86 class Deps(object):
newt (away) 2015/05/12 01:01:24 more blank lines!
87 def __init__(self, direct_deps_config_paths):
88 self.all_deps_config_paths = GetAllDepsConfigsInOrder(
89 direct_deps_config_paths)
90 self.direct_deps_configs = [
91 GetDepConfig(p) for p in direct_deps_config_paths]
92 self.all_deps_configs = [
93 GetDepConfig(p) for p in self.all_deps_config_paths]
94
95 def All(self, wanted_type=None):
96 if type is None:
97 return self.all_deps_configs
98 return DepsOfType(wanted_type, self.all_deps_configs)
99
100 def Direct(self, wanted_type=None):
101 if wanted_type is None:
102 return self.direct_deps_configs
103 return DepsOfType(wanted_type, self.direct_deps_configs)
104
105 def AllConfigPaths(self):
106 return self.all_deps_config_paths
86 107
87 def main(argv): 108 def main(argv):
88 parser = optparse.OptionParser() 109 parser = optparse.OptionParser()
89 build_utils.AddDepfileOption(parser) 110 build_utils.AddDepfileOption(parser)
90 parser.add_option('--build-config', help='Path to build_config output.') 111 parser.add_option('--build-config', help='Path to build_config output.')
91 parser.add_option( 112 parser.add_option(
92 '--type', 113 '--type',
93 help='Type of this target (e.g. android_library).') 114 help='Type of this target (e.g. android_library).')
94 parser.add_option( 115 parser.add_option(
95 '--possible-deps-configs', 116 '--possible-deps-configs',
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 options.possible_deps_configs) 179 options.possible_deps_configs)
159 180
160 allow_unknown_deps = options.type == 'android_apk' 181 allow_unknown_deps = options.type == 'android_apk'
161 unknown_deps = [ 182 unknown_deps = [
162 c for c in possible_deps_config_paths if not os.path.exists(c)] 183 c for c in possible_deps_config_paths if not os.path.exists(c)]
163 if unknown_deps and not allow_unknown_deps: 184 if unknown_deps and not allow_unknown_deps:
164 raise Exception('Unknown deps: ' + str(unknown_deps)) 185 raise Exception('Unknown deps: ' + str(unknown_deps))
165 186
166 direct_deps_config_paths = [ 187 direct_deps_config_paths = [
167 c for c in possible_deps_config_paths if not c in unknown_deps] 188 c for c in possible_deps_config_paths if not c in unknown_deps]
168 all_deps_config_paths = GetAllDepsConfigsInOrder(direct_deps_config_paths)
169 189
170 direct_deps_configs = [GetDepConfig(p) for p in direct_deps_config_paths] 190 deps = Deps(direct_deps_config_paths)
171 all_deps_configs = [GetDepConfig(p) for p in all_deps_config_paths] 191 direct_library_deps = deps.Direct('java_library')
192 all_library_deps = deps.All('java_library')
172 193
173 direct_library_deps = DepsOfType('java_library', direct_deps_configs) 194 direct_resources_deps = deps.Direct('android_resources')
174 all_library_deps = DepsOfType('java_library', all_deps_configs) 195 all_resources_deps = deps.All('android_resources')
175
176 direct_resources_deps = DepsOfType('android_resources', direct_deps_configs)
177 all_resources_deps = DepsOfType('android_resources', all_deps_configs)
178 # Resources should be ordered with the highest-level dependency first so that 196 # Resources should be ordered with the highest-level dependency first so that
179 # overrides are done correctly. 197 # overrides are done correctly.
180 all_resources_deps.reverse() 198 all_resources_deps.reverse()
181 199
200 if options.type == 'android_apk' and options.tested_apk_config:
201 tested_apk_deps = Deps([options.tested_apk_config])
202 tested_apk_resources_deps = tested_apk_deps.All('android_resources')
203 all_resources_deps = [
204 d for d in all_resources_deps if not d in tested_apk_resources_deps]
205
182 # Initialize some common config. 206 # Initialize some common config.
183 config = { 207 config = {
184 'deps_info': { 208 'deps_info': {
185 'name': os.path.basename(options.build_config), 209 'name': os.path.basename(options.build_config),
186 'path': options.build_config, 210 'path': options.build_config,
187 'type': options.type, 211 'type': options.type,
188 'deps_configs': direct_deps_config_paths, 212 'deps_configs': direct_deps_config_paths,
189 } 213 }
190 } 214 }
191 deps_info = config['deps_info'] 215 deps_info = config['deps_info']
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 if options.type == 'android_apk': 273 if options.type == 'android_apk':
250 config['resources']['extra_package_names'] = [ 274 config['resources']['extra_package_names'] = [
251 c['package_name'] for c in all_resources_deps if 'package_name' in c] 275 c['package_name'] for c in all_resources_deps if 'package_name' in c]
252 276
253 if options.type in ['android_apk', 'deps_dex']: 277 if options.type in ['android_apk', 'deps_dex']:
254 deps_dex_files = [c['dex_path'] for c in all_library_deps] 278 deps_dex_files = [c['dex_path'] for c in all_library_deps]
255 279
256 # An instrumentation test apk should exclude the dex files that are in the apk 280 # An instrumentation test apk should exclude the dex files that are in the apk
257 # under test. 281 # under test.
258 if options.type == 'android_apk' and options.tested_apk_config: 282 if options.type == 'android_apk' and options.tested_apk_config:
259 tested_apk_config_paths = GetAllDepsConfigsInOrder( 283 tested_apk_deps = Deps([options.tested_apk_config])
260 [options.tested_apk_config]) 284 tested_apk_library_deps = tested_apk_deps.All('java_library')
261 tested_apk_configs = [GetDepConfig(p) for p in tested_apk_config_paths]
262 tested_apk_library_deps = DepsOfType('java_library', tested_apk_configs)
263 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps] 285 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps]
264 deps_dex_files = [ 286 deps_dex_files = [
265 p for p in deps_dex_files if not p in tested_apk_deps_dex_files] 287 p for p in deps_dex_files if not p in tested_apk_deps_dex_files]
266 288
267 tested_apk_config = GetDepConfig(options.tested_apk_config) 289 tested_apk_config = GetDepConfig(options.tested_apk_config)
268 expected_tested_package = tested_apk_config['package_name'] 290 expected_tested_package = tested_apk_config['package_name']
269 AndroidManifest(options.android_manifest).CheckInstrumentation( 291 AndroidManifest(options.android_manifest).CheckInstrumentation(
270 expected_tested_package) 292 expected_tested_package)
271 293
272 # Dependencies for the final dex file of an apk or a 'deps_dex'. 294 # Dependencies for the final dex file of an apk or a 'deps_dex'.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 config['native'] = { 331 config['native'] = {
310 'libraries': library_paths, 332 'libraries': library_paths,
311 'java_libraries_list': java_libraries_list 333 'java_libraries_list': java_libraries_list
312 } 334 }
313 335
314 build_utils.WriteJson(config, options.build_config, only_if_changed=True) 336 build_utils.WriteJson(config, options.build_config, only_if_changed=True)
315 337
316 if options.depfile: 338 if options.depfile:
317 build_utils.WriteDepfile( 339 build_utils.WriteDepfile(
318 options.depfile, 340 options.depfile,
319 all_deps_config_paths + build_utils.GetPythonDependencies()) 341 deps.AllConfigPaths() + build_utils.GetPythonDependencies())
320 342
321 343
322 if __name__ == '__main__': 344 if __name__ == '__main__':
323 sys.exit(main(sys.argv[1:])) 345 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « build/android/gyp/javac.py ('k') | chrome/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698