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

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

Issue 2767613002: Expose resources in Robolectric/JUnit tests. (Closed)
Patch Set: GN generate resource dirs. 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']['resource_packages'] = list({
547 c['package_name'] for c in all_resources_deps if 'package_name' in c})
548 config['test_info']['resources_dirs'] = list({
549 d for c in all_resources_deps if 'resources_dirs' in c
550 for d in c['resources_dirs']})
551
552 if options.type in ('android_resources', 'android_apk', 'resource_rewriter'):
544 config['resources'] = {} 553 config['resources'] = {}
545 config['resources']['dependency_zips'] = [ 554 config['resources']['dependency_zips'] = [
546 c['resources_zip'] for c in all_resources_deps] 555 c['resources_zip'] for c in all_resources_deps]
556 config['resources']['dependency_dirs'] = [
557 c['resources_dirs'] for c in all_resources_deps]
547 config['resources']['extra_package_names'] = [] 558 config['resources']['extra_package_names'] = []
548 config['resources']['extra_r_text_files'] = [] 559 config['resources']['extra_r_text_files'] = []
549 560
550 if options.type == 'android_apk' or options.type == 'resource_rewriter': 561 if options.type == 'android_apk' or options.type == 'resource_rewriter':
551 config['resources']['extra_package_names'] = [ 562 config['resources']['extra_package_names'] = [
552 c['package_name'] for c in all_resources_deps if 'package_name' in c] 563 c['package_name'] for c in all_resources_deps if 'package_name' in c]
553 config['resources']['extra_r_text_files'] = [ 564 config['resources']['extra_r_text_files'] = [
554 c['r_text'] for c in all_resources_deps if 'r_text' in c] 565 c['r_text'] for c in all_resources_deps if 'r_text' in c]
555 566
556 if options.type in ['android_apk', 'deps_dex']: 567 if options.type in ['android_apk', 'deps_dex']:
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 deps_info['java_resources_jar'] = options.java_resources_jar_path 720 deps_info['java_resources_jar'] = options.java_resources_jar_path
710 721
711 build_utils.WriteJson(config, options.build_config, only_if_changed=True) 722 build_utils.WriteJson(config, options.build_config, only_if_changed=True)
712 723
713 if options.depfile: 724 if options.depfile:
714 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) 725 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs)
715 726
716 727
717 if __name__ == '__main__': 728 if __name__ == '__main__':
718 sys.exit(main(sys.argv[1:])) 729 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698