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

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

Issue 2623243002: android: Create a GN template for create_dist_jar.py (Closed)
Patch Set: interface jars condition was inverted Created 3 years, 11 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 | « no previous file | build/config/android/internal_rules.gni » ('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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 parser.error('\n'.join(build_utils.ParseGnList(options.fail))) 331 parser.error('\n'.join(build_utils.ParseGnList(options.fail)))
332 332
333 required_options_map = { 333 required_options_map = {
334 'java_binary': ['build_config', 'jar_path'], 334 'java_binary': ['build_config', 'jar_path'],
335 'java_library': ['build_config', 'jar_path'], 335 'java_library': ['build_config', 'jar_path'],
336 'java_prebuilt': ['build_config', 'jar_path'], 336 'java_prebuilt': ['build_config', 'jar_path'],
337 'android_assets': ['build_config'], 337 'android_assets': ['build_config'],
338 'android_resources': ['build_config', 'resources_zip'], 338 'android_resources': ['build_config', 'resources_zip'],
339 'android_apk': ['build_config', 'jar_path', 'dex_path', 'resources_zip'], 339 'android_apk': ['build_config', 'jar_path', 'dex_path', 'resources_zip'],
340 'deps_dex': ['build_config', 'dex_path'], 340 'deps_dex': ['build_config', 'dex_path'],
341 'dist_jar': ['build_config'],
341 'resource_rewriter': ['build_config'], 342 'resource_rewriter': ['build_config'],
342 'group': ['build_config'], 343 'group': ['build_config'],
343 } 344 }
344 required_options = required_options_map.get(options.type) 345 required_options = required_options_map.get(options.type)
345 if not required_options: 346 if not required_options:
346 raise Exception('Unknown type: <%s>' % options.type) 347 raise Exception('Unknown type: <%s>' % options.type)
347 348
348 build_utils.CheckOptions(options, parser, required_options) 349 build_utils.CheckOptions(options, parser, required_options)
349 350
350 # Java prebuilts are the same as libraries except for in gradle files. 351 # Java prebuilts are the same as libraries except for in gradle files.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 if options.type in ('java_binary', 'java_library', 'android_apk'): 446 if options.type in ('java_binary', 'java_library', 'android_apk'):
446 deps_info['jar_path'] = options.jar_path 447 deps_info['jar_path'] = options.jar_path
447 if options.type == 'android_apk' or options.supports_android: 448 if options.type == 'android_apk' or options.supports_android:
448 deps_info['dex_path'] = options.dex_path 449 deps_info['dex_path'] = options.dex_path
449 if options.type == 'android_apk': 450 if options.type == 'android_apk':
450 deps_info['apk_path'] = options.apk_path 451 deps_info['apk_path'] = options.apk_path
451 deps_info['incremental_apk_path'] = options.incremental_apk_path 452 deps_info['incremental_apk_path'] = options.incremental_apk_path
452 deps_info['incremental_install_script_path'] = ( 453 deps_info['incremental_install_script_path'] = (
453 options.incremental_install_script_path) 454 options.incremental_install_script_path)
454 455
456 if options.type in ('java_binary', 'java_library', 'android_apk', 'dist_jar'):
455 # Classpath values filled in below (after applying tested_apk_config). 457 # Classpath values filled in below (after applying tested_apk_config).
456 config['javac'] = {} 458 config['javac'] = {}
457 459
458
459 if options.type in ('java_binary', 'java_library'): 460 if options.type in ('java_binary', 'java_library'):
460 # Only resources might have srcjars (normal srcjar targets are listed in 461 # Only resources might have srcjars (normal srcjar targets are listed in
461 # srcjar_deps). A resource's srcjar contains the R.java file for those 462 # srcjar_deps). A resource's srcjar contains the R.java file for those
462 # resources, and (like Android's default build system) we allow a library to 463 # resources, and (like Android's default build system) we allow a library to
463 # refer to the resources in any of its dependents. 464 # refer to the resources in any of its dependents.
464 config['javac']['srcjars'] = [ 465 config['javac']['srcjars'] = [
465 c['srcjar'] for c in all_resources_deps if 'srcjar' in c] 466 c['srcjar'] for c in all_resources_deps if 'srcjar' in c]
466 467
467 # Used to strip out R.class for android_prebuilt()s. 468 # Used to strip out R.class for android_prebuilt()s.
468 if options.type == 'java_library': 469 if options.type == 'java_library':
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 538
538 if options.type == 'android_apk' or options.type == 'resource_rewriter': 539 if options.type == 'android_apk' or options.type == 'resource_rewriter':
539 config['resources']['extra_package_names'] = [ 540 config['resources']['extra_package_names'] = [
540 c['package_name'] for c in all_resources_deps if 'package_name' in c] 541 c['package_name'] for c in all_resources_deps if 'package_name' in c]
541 config['resources']['extra_r_text_files'] = [ 542 config['resources']['extra_r_text_files'] = [
542 c['r_text'] for c in all_resources_deps if 'r_text' in c] 543 c['r_text'] for c in all_resources_deps if 'r_text' in c]
543 544
544 if options.type in ['android_apk', 'deps_dex']: 545 if options.type in ['android_apk', 'deps_dex']:
545 deps_dex_files = [c['dex_path'] for c in all_library_deps] 546 deps_dex_files = [c['dex_path'] for c in all_library_deps]
546 547
547 if options.type in ('java_binary', 'java_library', 'android_apk'): 548 if options.type in ('java_binary', 'java_library', 'android_apk', 'dist_jar'):
548 javac_classpath = [c['jar_path'] for c in direct_library_deps] 549 javac_classpath = [c['jar_path'] for c in direct_library_deps]
549 java_full_classpath = [c['jar_path'] for c in all_library_deps] 550 java_full_classpath = [c['jar_path'] for c in all_library_deps]
550 551
551 if options.extra_classpath_jars: 552 if options.extra_classpath_jars:
552 extra_jars = build_utils.ParseGnList(options.extra_classpath_jars) 553 extra_jars = build_utils.ParseGnList(options.extra_classpath_jars)
553 deps_info['extra_classpath_jars'] = extra_jars 554 deps_info['extra_classpath_jars'] = extra_jars
554 javac_classpath += extra_jars 555 javac_classpath += extra_jars
555 556
556 # The java code for an instrumentation test apk is assembled differently for 557 # The java code for an instrumentation test apk is assembled differently for
557 # ProGuard vs. non-ProGuard. 558 # ProGuard vs. non-ProGuard.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 lib_configs.update(c.get('proguard_configs', ())) 617 lib_configs.update(c.get('proguard_configs', ()))
617 proguard_config['lib_paths'] = list(extra_jars) 618 proguard_config['lib_paths'] = list(extra_jars)
618 proguard_config['lib_configs'] = list(lib_configs) 619 proguard_config['lib_configs'] = list(lib_configs)
619 620
620 # Dependencies for the final dex file of an apk or a 'deps_dex'. 621 # Dependencies for the final dex file of an apk or a 'deps_dex'.
621 if options.type in ['android_apk', 'deps_dex']: 622 if options.type in ['android_apk', 'deps_dex']:
622 config['final_dex'] = {} 623 config['final_dex'] = {}
623 dex_config = config['final_dex'] 624 dex_config = config['final_dex']
624 dex_config['dependency_dex_files'] = deps_dex_files 625 dex_config['dependency_dex_files'] = deps_dex_files
625 626
626 if options.type in ('java_binary', 'java_library', 'android_apk'): 627 if options.type in ('java_binary', 'java_library', 'android_apk', 'dist_jar'):
627 config['javac']['classpath'] = javac_classpath 628 config['javac']['classpath'] = javac_classpath
628 config['javac']['interface_classpath'] = [ 629 config['javac']['interface_classpath'] = [
629 _AsInterfaceJar(p) for p in javac_classpath] 630 _AsInterfaceJar(p) for p in javac_classpath]
630 deps_info['java'] = { 631 deps_info['java'] = {
631 'full_classpath': java_full_classpath 632 'full_classpath': java_full_classpath
632 } 633 }
633 634
635 if options.type in ('android_apk', 'dist_jar'):
636 dependency_jars = [c['jar_path'] for c in all_library_deps]
637 all_interface_jars = [_AsInterfaceJar(p) for p in dependency_jars]
638 if options.type == 'android_apk':
639 all_interface_jars.append(_AsInterfaceJar(options.jar_path))
640
641 config['dist_jar'] = {
642 'dependency_jars': dependency_jars,
643 'all_interface_jars': all_interface_jars,
644 }
645
634 if options.type == 'android_apk': 646 if options.type == 'android_apk':
635 dependency_jars = [c['jar_path'] for c in all_library_deps] 647 dependency_jars = [c['jar_path'] for c in all_library_deps]
636 all_interface_jars = [
637 _AsInterfaceJar(p) for p in dependency_jars + [options.jar_path]]
638 config['dist_jar'] = {
639 'dependency_jars': dependency_jars,
640 'all_interface_jars': all_interface_jars,
641 }
642 manifest = AndroidManifest(options.android_manifest) 648 manifest = AndroidManifest(options.android_manifest)
643 deps_info['package_name'] = manifest.GetPackageName() 649 deps_info['package_name'] = manifest.GetPackageName()
644 if not options.tested_apk_config and manifest.GetInstrumentation(): 650 if not options.tested_apk_config and manifest.GetInstrumentation():
645 # This must then have instrumentation only for itself. 651 # This must then have instrumentation only for itself.
646 manifest.CheckInstrumentation(manifest.GetPackageName()) 652 manifest.CheckInstrumentation(manifest.GetPackageName())
647 653
648 library_paths = [] 654 library_paths = []
649 java_libraries_list = None 655 java_libraries_list = None
650 runtime_deps_files = build_utils.ParseGnList( 656 runtime_deps_files = build_utils.ParseGnList(
651 options.shared_libraries_runtime_deps or '[]') 657 options.shared_libraries_runtime_deps or '[]')
(...skipping 26 matching lines...) Expand all
678 _CreateLocalePaksAssetJavaList(config['uncompressed_assets'])) 684 _CreateLocalePaksAssetJavaList(config['uncompressed_assets']))
679 685
680 build_utils.WriteJson(config, options.build_config, only_if_changed=True) 686 build_utils.WriteJson(config, options.build_config, only_if_changed=True)
681 687
682 if options.depfile: 688 if options.depfile:
683 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) 689 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs)
684 690
685 691
686 if __name__ == '__main__': 692 if __name__ == '__main__':
687 sys.exit(main(sys.argv[1:])) 693 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | build/config/android/internal_rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698