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

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

Issue 2182303002: Merging under test java into instrumentation test java. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@runtimelibrary
Patch Set: Addressing agrieve's comments Created 4 years, 4 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 config['resources']['extra_r_text_files'] = [ 511 config['resources']['extra_r_text_files'] = [
512 c['r_text'] for c in all_resources_deps if 'r_text' in c] 512 c['r_text'] for c in all_resources_deps if 'r_text' in c]
513 513
514 if options.type in ['android_apk', 'deps_dex']: 514 if options.type in ['android_apk', 'deps_dex']:
515 deps_dex_files = [c['dex_path'] for c in all_library_deps] 515 deps_dex_files = [c['dex_path'] for c in all_library_deps]
516 516
517 if options.type in ('java_binary', 'java_library', 'android_apk'): 517 if options.type in ('java_binary', 'java_library', 'android_apk'):
518 javac_classpath = [c['jar_path'] for c in direct_library_deps] 518 javac_classpath = [c['jar_path'] for c in direct_library_deps]
519 java_full_classpath = [c['jar_path'] for c in all_library_deps] 519 java_full_classpath = [c['jar_path'] for c in all_library_deps]
520 520
521 # An instrumentation test apk should exclude the dex files that are in the apk 521 # An instrumentation test apk should include the java that is in the apk under
jbudorick 2016/07/28 16:56:00 Why should we do this two different ways rather th
smaier 2016/07/28 18:09:51 ProGuard is the tool which does the merging. Thus,
jbudorick 2016/07/28 18:18:22 I seem to have entirely misunderstood what you mea
522 # under test. 522 # test if ProGuard is enabled, but exclude that java if ProGuard is disabled.
523 if options.type == 'android_apk' and options.tested_apk_config: 523 if options.type == 'android_apk' and options.tested_apk_config:
524 tested_apk_config = GetDepConfig(options.tested_apk_config) 524 tested_apk_config = GetDepConfig(options.tested_apk_config)
525 525
526 expected_tested_package = tested_apk_config['package_name'] 526 expected_tested_package = tested_apk_config['package_name']
527 AndroidManifest(options.android_manifest).CheckInstrumentation( 527 AndroidManifest(options.android_manifest).CheckInstrumentation(
528 expected_tested_package) 528 expected_tested_package)
529 if options.proguard_enabled:
530 # Add all tested classes to the test's classpath to ensure that the test's
531 # java code is a superset of the tested apk's java code
532 java_full_classpath += [
533 jar for jar in tested_apk_config['java']['full_classpath']
534 if jar not in java_full_classpath]
535
529 if tested_apk_config['proguard_enabled']: 536 if tested_apk_config['proguard_enabled']:
530 assert options.proguard_enabled, ('proguard must be enabled for ' 537 assert options.proguard_enabled, ('proguard must be enabled for '
531 'instrumentation apks if it\'s enabled for the tested apk.') 538 'instrumentation apks if it\'s enabled for the tested apk.')
532 539
533 # Include in the classpath classes that are added directly to the apk under 540 # Include in the classpath classes that are added directly to the apk under
534 # test (those that are not a part of a java_library). 541 # test (those that are not a part of a java_library).
535 javac_classpath.append(tested_apk_config['jar_path']) 542 javac_classpath.append(tested_apk_config['jar_path'])
536 java_full_classpath.append(tested_apk_config['jar_path']) 543 java_full_classpath.append(tested_apk_config['jar_path'])
537 544
538 # Exclude dex files from the test apk that exist within the apk under test. 545 # Exclude dex files from the test apk that exist within the apk under test.
jbudorick 2016/07/28 18:18:22 (I expected a change here.)
smaier 2016/07/28 19:19:19 Sadly, this code applies only to the non-proguard
jbudorick 2016/07/28 19:25:14 So why isn't it changing here as well...?
539 # TODO(agrieve): When proguard is enabled, this filtering logic happens 546 # TODO(agrieve): When proguard is enabled, this filtering logic happens
540 # within proguard_util.py. Move the logic for the proguard case into 547 # within proguard_util.py. Move the logic for the proguard case into
541 # here as well. 548 # here as well.
542 tested_apk_library_deps = tested_apk_deps.All('java_library') 549 tested_apk_library_deps = tested_apk_deps.All('java_library')
543 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps] 550 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps]
544 deps_dex_files = [ 551 deps_dex_files = [
545 p for p in deps_dex_files if not p in tested_apk_deps_dex_files] 552 p for p in deps_dex_files if not p in tested_apk_deps_dex_files]
546 553
547 if options.type == 'android_apk': 554 if options.type == 'android_apk':
548 deps_info['proguard_enabled'] = options.proguard_enabled 555 deps_info['proguard_enabled'] = options.proguard_enabled
549 deps_info['proguard_info'] = options.proguard_info 556 deps_info['proguard_info'] = options.proguard_info
550 config['proguard'] = {} 557 config['proguard'] = {}
551 proguard_config = config['proguard'] 558 proguard_config = config['proguard']
552 proguard_config['input_paths'] = [options.jar_path] + java_full_classpath 559 proguard_config['input_paths'] = [options.jar_path] + java_full_classpath
553 560
554 # Dependencies for the final dex file of an apk or a 'deps_dex'. 561 # Dependencies for the final dex file of an apk or a 'deps_dex'.
555 if options.type in ['android_apk', 'deps_dex']: 562 if options.type in ['android_apk', 'deps_dex']:
556 config['final_dex'] = {} 563 config['final_dex'] = {}
557 dex_config = config['final_dex'] 564 dex_config = config['final_dex']
558 dex_config['dependency_dex_files'] = deps_dex_files 565 dex_config['dependency_dex_files'] = deps_dex_files
559 566
560 if options.type in ('java_binary', 'java_library', 'android_apk'): 567 if options.type in ('java_binary', 'java_library', 'android_apk'):
561 config['javac']['classpath'] = javac_classpath 568 config['javac']['classpath'] = javac_classpath
562 config['javac']['interface_classpath'] = [ 569 config['javac']['interface_classpath'] = [
563 _AsInterfaceJar(p) for p in javac_classpath] 570 _AsInterfaceJar(p) for p in javac_classpath]
564 config['java'] = { 571 deps_info['java'] = {
565 'full_classpath': java_full_classpath 572 'full_classpath': java_full_classpath
566 } 573 }
567 574
568 if options.type == 'android_apk': 575 if options.type == 'android_apk':
569 dependency_jars = [c['jar_path'] for c in all_library_deps] 576 dependency_jars = [c['jar_path'] for c in all_library_deps]
570 all_interface_jars = [ 577 all_interface_jars = [
571 _AsInterfaceJar(p) for p in dependency_jars + [options.jar_path]] 578 _AsInterfaceJar(p) for p in dependency_jars + [options.jar_path]]
572 config['dist_jar'] = { 579 config['dist_jar'] = {
573 'dependency_jars': dependency_jars, 580 'dependency_jars': dependency_jars,
574 'all_interface_jars': all_interface_jars, 581 'all_interface_jars': all_interface_jars,
(...skipping 24 matching lines...) Expand all
599 _MergeAssets(deps.All('android_assets'))) 606 _MergeAssets(deps.All('android_assets')))
600 607
601 build_utils.WriteJson(config, options.build_config, only_if_changed=True) 608 build_utils.WriteJson(config, options.build_config, only_if_changed=True)
602 609
603 if options.depfile: 610 if options.depfile:
604 build_utils.WriteDepfile(options.depfile, all_inputs) 611 build_utils.WriteDepfile(options.depfile, all_inputs)
605 612
606 613
607 if __name__ == '__main__': 614 if __name__ == '__main__':
608 sys.exit(main(sys.argv[1:])) 615 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698