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

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

Issue 1549543002: GN(android): Allow android_instrumentation_test_apk() to depend on Java files in android_apk() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 5 years 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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 if options.type in ('java_binary', 'java_library', 'android_apk'): 312 if options.type in ('java_binary', 'java_library', 'android_apk'):
313 javac_classpath = [c['jar_path'] for c in direct_library_deps] 313 javac_classpath = [c['jar_path'] for c in direct_library_deps]
314 java_full_classpath = [c['jar_path'] for c in all_library_deps] 314 java_full_classpath = [c['jar_path'] for c in all_library_deps]
315 deps_info['resources_deps'] = [c['path'] for c in all_resources_deps] 315 deps_info['resources_deps'] = [c['path'] for c in all_resources_deps]
316 deps_info['jar_path'] = options.jar_path 316 deps_info['jar_path'] = options.jar_path
317 if options.type == 'android_apk' or options.supports_android: 317 if options.type == 'android_apk' or options.supports_android:
318 deps_info['dex_path'] = options.dex_path 318 deps_info['dex_path'] = options.dex_path
319 if options.type == 'android_apk': 319 if options.type == 'android_apk':
320 deps_info['apk_path'] = options.apk_path 320 deps_info['apk_path'] = options.apk_path
321 config['javac'] = { 321
322 'classpath': javac_classpath, 322 # Classpath values filled in below (after applying tested_apk_config).
323 } 323 config['javac'] = {}
324 config['java'] = {
325 'full_classpath': java_full_classpath
326 }
327 324
328 if options.type in ('java_binary', 'java_library'): 325 if options.type in ('java_binary', 'java_library'):
329 # Only resources might have srcjars (normal srcjar targets are listed in 326 # Only resources might have srcjars (normal srcjar targets are listed in
330 # srcjar_deps). A resource's srcjar contains the R.java file for those 327 # srcjar_deps). A resource's srcjar contains the R.java file for those
331 # resources, and (like Android's default build system) we allow a library to 328 # resources, and (like Android's default build system) we allow a library to
332 # refer to the resources in any of its dependents. 329 # refer to the resources in any of its dependents.
333 config['javac']['srcjars'] = [ 330 config['javac']['srcjars'] = [
334 c['srcjar'] for c in direct_resources_deps if 'srcjar' in c] 331 c['srcjar'] for c in direct_resources_deps if 'srcjar' in c]
335 332
336 if options.type == 'android_apk': 333 if options.type == 'android_apk':
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if proguard_enabled: 386 if proguard_enabled:
390 deps_info['proguard_info'] = options.proguard_info 387 deps_info['proguard_info'] = options.proguard_info
391 config['proguard'] = {} 388 config['proguard'] = {}
392 proguard_config = config['proguard'] 389 proguard_config = config['proguard']
393 proguard_config['input_paths'] = [options.jar_path] + java_full_classpath 390 proguard_config['input_paths'] = [options.jar_path] + java_full_classpath
394 proguard_config['tested_apk_info'] = '' 391 proguard_config['tested_apk_info'] = ''
395 392
396 # An instrumentation test apk should exclude the dex files that are in the apk 393 # An instrumentation test apk should exclude the dex files that are in the apk
397 # under test. 394 # under test.
398 if options.type == 'android_apk' and options.tested_apk_config: 395 if options.type == 'android_apk' and options.tested_apk_config:
399 tested_apk_deps = Deps([options.tested_apk_config])
400 tested_apk_library_deps = tested_apk_deps.All('java_library') 396 tested_apk_library_deps = tested_apk_deps.All('java_library')
401 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps] 397 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps]
398 # Include in the classpath classes that are added directly to the apk under
399 # test (those that are not a part of a java_library).
400 tested_apk_config = GetDepConfig(options.tested_apk_config)
401 javac_classpath.append(tested_apk_config['jar_path'])
402 # Exclude dex files from the test apk that exist within the apk under test.
402 deps_dex_files = [ 403 deps_dex_files = [
403 p for p in deps_dex_files if not p in tested_apk_deps_dex_files] 404 p for p in deps_dex_files if not p in tested_apk_deps_dex_files]
404 405
405 tested_apk_config = GetDepConfig(options.tested_apk_config)
406 expected_tested_package = tested_apk_config['package_name'] 406 expected_tested_package = tested_apk_config['package_name']
407 AndroidManifest(options.android_manifest).CheckInstrumentation( 407 AndroidManifest(options.android_manifest).CheckInstrumentation(
408 expected_tested_package) 408 expected_tested_package)
409 if tested_apk_config['proguard_enabled']: 409 if tested_apk_config['proguard_enabled']:
410 assert proguard_enabled, ('proguard must be enabled for instrumentation' 410 assert proguard_enabled, ('proguard must be enabled for instrumentation'
411 ' apks if it\'s enabled for the tested apk') 411 ' apks if it\'s enabled for the tested apk')
412 proguard_config['tested_apk_info'] = tested_apk_config['proguard_info'] 412 proguard_config['tested_apk_info'] = tested_apk_config['proguard_info']
413 413
414 deps_info['tested_apk_path'] = tested_apk_config['apk_path'] 414 deps_info['tested_apk_path'] = tested_apk_config['apk_path']
415 415
416 # Dependencies for the final dex file of an apk or a 'deps_dex'. 416 # Dependencies for the final dex file of an apk or a 'deps_dex'.
417 if options.type in ['android_apk', 'deps_dex']: 417 if options.type in ['android_apk', 'deps_dex']:
418 config['final_dex'] = {} 418 config['final_dex'] = {}
419 dex_config = config['final_dex'] 419 dex_config = config['final_dex']
420 dex_config['dependency_dex_files'] = deps_dex_files 420 dex_config['dependency_dex_files'] = deps_dex_files
421 421
422 if options.type in ('java_binary', 'java_library', 'android_apk'):
423 config['javac']['classpath'] = javac_classpath
424 config['java'] = {
425 'full_classpath': java_full_classpath
426 }
427
422 if options.type == 'android_apk': 428 if options.type == 'android_apk':
423 config['dist_jar'] = { 429 config['dist_jar'] = {
424 'dependency_jars': [ 430 'dependency_jars': [
425 c['jar_path'] for c in all_library_deps 431 c['jar_path'] for c in all_library_deps
426 ] 432 ]
427 } 433 }
428 manifest = AndroidManifest(options.android_manifest) 434 manifest = AndroidManifest(options.android_manifest)
429 deps_info['package_name'] = manifest.GetPackageName() 435 deps_info['package_name'] = manifest.GetPackageName()
430 if not options.tested_apk_config and manifest.GetInstrumentation(): 436 if not options.tested_apk_config and manifest.GetInstrumentation():
431 # This must then have instrumentation only for itself. 437 # This must then have instrumentation only for itself.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 build_utils.WriteJson(config, options.build_config, only_if_changed=True) 478 build_utils.WriteJson(config, options.build_config, only_if_changed=True)
473 479
474 if options.depfile: 480 if options.depfile:
475 build_utils.WriteDepfile( 481 build_utils.WriteDepfile(
476 options.depfile, 482 options.depfile,
477 deps.AllConfigPaths() + build_utils.GetPythonDependencies()) 483 deps.AllConfigPaths() + build_utils.GetPythonDependencies())
478 484
479 485
480 if __name__ == '__main__': 486 if __name__ == '__main__':
481 sys.exit(main(sys.argv[1:])) 487 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