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

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

Issue 2083683002: 🎄 Refactor: include apk_under_test.jar in full_class_path (and add TODO) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lint-resources
Patch Set: Refactor: include apk_under_test.jar in full_class_path (and add TODO) Created 4 years, 6 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 | no next file » | 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 348
349 if deps_require_android and not options.requires_android: 349 if deps_require_android and not options.requires_android:
350 raise Exception('Some deps require building for the Android platform: ' + 350 raise Exception('Some deps require building for the Android platform: ' +
351 str(deps_require_android)) 351 str(deps_require_android))
352 352
353 if deps_not_support_android and options.supports_android: 353 if deps_not_support_android and options.supports_android:
354 raise Exception('Not all deps support the Android platform: ' + 354 raise Exception('Not all deps support the Android platform: ' +
355 str(deps_not_support_android)) 355 str(deps_not_support_android))
356 356
357 if options.type in ('java_binary', 'java_library', 'android_apk'): 357 if options.type in ('java_binary', 'java_library', 'android_apk'):
358 javac_classpath = [c['jar_path'] for c in direct_library_deps]
359 java_full_classpath = [c['jar_path'] for c in all_library_deps]
360 deps_info['resources_deps'] = [c['path'] for c in all_resources_deps] 358 deps_info['resources_deps'] = [c['path'] for c in all_resources_deps]
361 deps_info['jar_path'] = options.jar_path 359 deps_info['jar_path'] = options.jar_path
362 if options.type == 'android_apk' or options.supports_android: 360 if options.type == 'android_apk' or options.supports_android:
363 deps_info['dex_path'] = options.dex_path 361 deps_info['dex_path'] = options.dex_path
364 if options.type == 'android_apk': 362 if options.type == 'android_apk':
365 deps_info['apk_path'] = options.apk_path 363 deps_info['apk_path'] = options.apk_path
366 deps_info['incremental_apk_path'] = options.incremental_apk_path 364 deps_info['incremental_apk_path'] = options.incremental_apk_path
367 deps_info['incremental_install_script_path'] = ( 365 deps_info['incremental_install_script_path'] = (
368 options.incremental_install_script_path) 366 options.incremental_install_script_path)
369 367
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 459
462 if options.type == 'android_apk' or options.type == 'resource_rewriter': 460 if options.type == 'android_apk' or options.type == 'resource_rewriter':
463 config['resources']['extra_package_names'] = [ 461 config['resources']['extra_package_names'] = [
464 c['package_name'] for c in all_resources_deps if 'package_name' in c] 462 c['package_name'] for c in all_resources_deps if 'package_name' in c]
465 config['resources']['extra_r_text_files'] = [ 463 config['resources']['extra_r_text_files'] = [
466 c['r_text'] for c in all_resources_deps if 'r_text' in c] 464 c['r_text'] for c in all_resources_deps if 'r_text' in c]
467 465
468 if options.type in ['android_apk', 'deps_dex']: 466 if options.type in ['android_apk', 'deps_dex']:
469 deps_dex_files = [c['dex_path'] for c in all_library_deps] 467 deps_dex_files = [c['dex_path'] for c in all_library_deps]
470 468
471 proguard_enabled = options.proguard_enabled 469 if options.type in ('java_binary', 'java_library', 'android_apk'):
470 javac_classpath = [c['jar_path'] for c in direct_library_deps]
471 java_full_classpath = [c['jar_path'] for c in all_library_deps]
472
473 # An instrumentation test apk should exclude the dex files that are in the apk
474 # under test.
475 if options.type == 'android_apk' and options.tested_apk_config:
476 tested_apk_config = GetDepConfig(options.tested_apk_config)
477
478 expected_tested_package = tested_apk_config['package_name']
479 AndroidManifest(options.android_manifest).CheckInstrumentation(
480 expected_tested_package)
481 if tested_apk_config['proguard_enabled']:
482 assert options.proguard_enabled, ('proguard must be enabled for '
483 'instrumentation apks if it\'s enabled for the tested apk.')
484
485 # Include in the classpath classes that are added directly to the apk under
486 # test (those that are not a part of a java_library).
487 javac_classpath.append(tested_apk_config['jar_path'])
488 java_full_classpath.append(tested_apk_config['jar_path'])
489
490 # Exclude dex files from the test apk that exist within the apk under test.
491 # TODO(agrieve): When proguard is enabled, this filtering logic happens
492 # within proguard_util.py. Move the logic for the proguard case into
493 # here as well.
494 tested_apk_library_deps = tested_apk_deps.All('java_library')
495 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps]
496 deps_dex_files = [
497 p for p in deps_dex_files if not p in tested_apk_deps_dex_files]
498
472 if options.type == 'android_apk': 499 if options.type == 'android_apk':
473 deps_info['proguard_enabled'] = proguard_enabled 500 deps_info['proguard_enabled'] = options.proguard_enabled
474
475 if proguard_enabled:
476 deps_info['proguard_info'] = options.proguard_info 501 deps_info['proguard_info'] = options.proguard_info
477 config['proguard'] = {} 502 config['proguard'] = {}
478 proguard_config = config['proguard'] 503 proguard_config = config['proguard']
479 proguard_config['input_paths'] = [options.jar_path] + java_full_classpath 504 proguard_config['input_paths'] = [options.jar_path] + java_full_classpath
480 505
481 # An instrumentation test apk should exclude the dex files that are in the apk
482 # under test.
483 if options.type == 'android_apk' and options.tested_apk_config:
484 tested_apk_library_deps = tested_apk_deps.All('java_library')
485 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps]
486 # Include in the classpath classes that are added directly to the apk under
487 # test (those that are not a part of a java_library).
488 tested_apk_config = GetDepConfig(options.tested_apk_config)
489 javac_classpath.append(tested_apk_config['jar_path'])
490 # Exclude dex files from the test apk that exist within the apk under test.
491 deps_dex_files = [
492 p for p in deps_dex_files if not p in tested_apk_deps_dex_files]
493
494 expected_tested_package = tested_apk_config['package_name']
495 AndroidManifest(options.android_manifest).CheckInstrumentation(
496 expected_tested_package)
497 if tested_apk_config['proguard_enabled']:
498 assert proguard_enabled, ('proguard must be enabled for instrumentation'
499 ' apks if it\'s enabled for the tested apk')
500
501 # Dependencies for the final dex file of an apk or a 'deps_dex'. 506 # Dependencies for the final dex file of an apk or a 'deps_dex'.
502 if options.type in ['android_apk', 'deps_dex']: 507 if options.type in ['android_apk', 'deps_dex']:
503 config['final_dex'] = {} 508 config['final_dex'] = {}
504 dex_config = config['final_dex'] 509 dex_config = config['final_dex']
505 dex_config['dependency_dex_files'] = deps_dex_files 510 dex_config['dependency_dex_files'] = deps_dex_files
506 511
507 if options.type in ('java_binary', 'java_library', 'android_apk'): 512 if options.type in ('java_binary', 'java_library', 'android_apk'):
508 config['javac']['classpath'] = javac_classpath 513 config['javac']['classpath'] = javac_classpath
509 config['javac']['interface_classpath'] = [ 514 config['javac']['interface_classpath'] = [
510 _AsInterfaceJar(p) for p in javac_classpath] 515 _AsInterfaceJar(p) for p in javac_classpath]
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 _MergeAssets(deps.All('android_assets'))) 571 _MergeAssets(deps.All('android_assets')))
567 572
568 build_utils.WriteJson(config, options.build_config, only_if_changed=True) 573 build_utils.WriteJson(config, options.build_config, only_if_changed=True)
569 574
570 if options.depfile: 575 if options.depfile:
571 build_utils.WriteDepfile(options.depfile, all_inputs) 576 build_utils.WriteDepfile(options.depfile, all_inputs)
572 577
573 578
574 if __name__ == '__main__': 579 if __name__ == '__main__':
575 sys.exit(main(sys.argv[1:])) 580 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698