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

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

Issue 2767613002: Expose resources in Robolectric/JUnit tests. (Closed)
Patch Set: Simplify changes to write_build_confg Created 3 years, 8 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
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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 'java_binary': ['build_config', 'jar_path'], 337 'java_binary': ['build_config', 'jar_path'],
338 'java_library': ['build_config', 'jar_path'], 338 'java_library': ['build_config', 'jar_path'],
339 'java_prebuilt': ['build_config', 'jar_path'], 339 'java_prebuilt': ['build_config', 'jar_path'],
340 'android_assets': ['build_config'], 340 'android_assets': ['build_config'],
341 'android_resources': ['build_config', 'resources_zip'], 341 'android_resources': ['build_config', 'resources_zip'],
342 'android_apk': ['build_config', 'jar_path', 'dex_path', 'resources_zip'], 342 'android_apk': ['build_config', 'jar_path', 'dex_path', 'resources_zip'],
343 'deps_dex': ['build_config', 'dex_path'], 343 'deps_dex': ['build_config', 'dex_path'],
344 'dist_jar': ['build_config'], 344 'dist_jar': ['build_config'],
345 'resource_rewriter': ['build_config'], 345 'resource_rewriter': ['build_config'],
346 'group': ['build_config'], 346 'group': ['build_config'],
347 'junit_binary': ['build_config'],
347 } 348 }
348 required_options = required_options_map.get(options.type) 349 required_options = required_options_map.get(options.type)
349 if not required_options: 350 if not required_options:
350 raise Exception('Unknown type: <%s>' % options.type) 351 raise Exception('Unknown type: <%s>' % options.type)
351 352
352 build_utils.CheckOptions(options, parser, required_options) 353 build_utils.CheckOptions(options, parser, required_options)
353 354
354 # Java prebuilts are the same as libraries except for in gradle files. 355 # Java prebuilts are the same as libraries except for in gradle files.
355 is_java_prebuilt = options.type == 'java_prebuilt' 356 is_java_prebuilt = options.type == 'java_prebuilt'
356 if is_java_prebuilt: 357 if is_java_prebuilt:
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 else: 534 else:
534 owned_resource_zips.add(c['resources_zip']) 535 owned_resource_zips.add(c['resources_zip'])
535 536
536 for c in all_library_deps: 537 for c in all_library_deps:
537 if c['supports_android']: 538 if c['supports_android']:
538 owned_resource_dirs.difference_update(c['owned_resources_dirs']) 539 owned_resource_dirs.difference_update(c['owned_resources_dirs'])
539 owned_resource_zips.difference_update(c['owned_resources_zips']) 540 owned_resource_zips.difference_update(c['owned_resources_zips'])
540 deps_info['owned_resources_dirs'] = list(owned_resource_dirs) 541 deps_info['owned_resources_dirs'] = list(owned_resource_dirs)
541 deps_info['owned_resources_zips'] = list(owned_resource_zips) 542 deps_info['owned_resources_zips'] = list(owned_resource_zips)
542 543
543 if options.type in ('android_resources','android_apk', 'resource_rewriter'): 544 if options.type == 'junit_binary':
545 config['test_info'] = {}
546 config['test_info']['resources_dirs'] = [
agrieve 2017/04/11 00:25:03 This hurts my head to look at :P. Better to just u
mikecase (-- gone --) 2017/04/11 18:04:31 Done
547 d for c in all_resources_deps if 'resources_dirs' in c
548 for d in c['resources_dirs']]
549
550 if options.type in ('android_resources', 'android_apk', 'resource_rewriter'):
544 config['resources'] = {} 551 config['resources'] = {}
545 config['resources']['dependency_zips'] = [ 552 config['resources']['dependency_zips'] = [
546 c['resources_zip'] for c in all_resources_deps] 553 c['resources_zip'] for c in all_resources_deps]
547 config['resources']['extra_package_names'] = [] 554 config['resources']['extra_package_names'] = []
548 config['resources']['extra_r_text_files'] = [] 555 config['resources']['extra_r_text_files'] = []
549 556
550 if options.type == 'android_apk' or options.type == 'resource_rewriter': 557 if options.type == 'android_apk' or options.type == 'resource_rewriter':
551 config['resources']['extra_package_names'] = [ 558 config['resources']['extra_package_names'] = [
552 c['package_name'] for c in all_resources_deps if 'package_name' in c] 559 c['package_name'] for c in all_resources_deps if 'package_name' in c]
553 config['resources']['extra_r_text_files'] = [ 560 config['resources']['extra_r_text_files'] = [
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 deps_info['java_resources_jar'] = options.java_resources_jar_path 716 deps_info['java_resources_jar'] = options.java_resources_jar_path
710 717
711 build_utils.WriteJson(config, options.build_config, only_if_changed=True) 718 build_utils.WriteJson(config, options.build_config, only_if_changed=True)
712 719
713 if options.depfile: 720 if options.depfile:
714 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) 721 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs)
715 722
716 723
717 if __name__ == '__main__': 724 if __name__ == '__main__':
718 sys.exit(main(sys.argv[1:])) 725 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698