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

Side by Side Diff: build/config/android/rules.gni

Issue 379333003: Add beginnings of android_apk and unittest_apk templates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-filearg
Patch Set: 80-column lines Created 6 years, 5 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 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import("//build/config/android/config.gni") 5 import("//build/config/android/config.gni")
6 import("//build/config/android/internal_rules.gni") 6 import("//build/config/android/internal_rules.gni")
7 import("//tools/grit/grit_rule.gni") 7 import("//tools/grit/grit_rule.gni")
8 8
9 assert(is_android) 9 assert(is_android)
10 10
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 # deps: Specifies the dependencies of this target. 336 # deps: Specifies the dependencies of this target.
337 # grd_file: Path to the .grd file to generate strings.xml from. 337 # grd_file: Path to the .grd file to generate strings.xml from.
338 # 338 #
339 # Example 339 # Example
340 # java_strings_grd("foo_strings_grd") { 340 # java_strings_grd("foo_strings_grd") {
341 # grd_file = "foo_strings.grd" 341 # grd_file = "foo_strings.grd"
342 # } 342 # }
343 template("java_strings_grd") { 343 template("java_strings_grd") {
344 base_path = "$target_gen_dir/$target_name" 344 base_path = "$target_gen_dir/$target_name"
345 resources_zip = base_path + ".resources.zip" 345 resources_zip = base_path + ".resources.zip"
346 build_config = base_path + ".build_config"
346 347
347 write_build_config("${target_name}__build_config") { 348 write_build_config("${target_name}__build_config") {
348 type = "android_resources" 349 type = "android_resources"
349 if (defined(invoker.deps)) { 350 if (defined(invoker.deps)) {
350 deps = invoker.deps 351 deps = invoker.deps
351 } 352 }
352 } 353 }
353 354
354 grit_target_name = "${target_name}__grit" 355 grit_target_name = "${target_name}__grit"
355 grit_output_dir = base_path + "_grit_output" 356 grit_output_dir = base_path + "_grit_output"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 # ] 410 # ]
410 # srcjar_deps = [ 411 # srcjar_deps = [
411 # ":foo_generated_enum" 412 # ":foo_generated_enum"
412 # ] 413 # ]
413 # jar_excluded_patterns = [ 414 # jar_excluded_patterns = [
414 # "*/FooService.class", "*/FooService##*.class" 415 # "*/FooService.class", "*/FooService##*.class"
415 # ] 416 # ]
416 # } 417 # }
417 template("android_library") { 418 template("android_library") {
418 assert(defined(invoker.java_files)) 419 assert(defined(invoker.java_files))
419
420 base_path = "$target_gen_dir/$target_name" 420 base_path = "$target_gen_dir/$target_name"
421 build_config = base_path + ".build_config" 421 build_config = base_path + ".build_config"
422 jar_path = base_path + ".jar"
422 423
423 write_build_config("${target_name}__build_config") { 424 write_build_config("${target_name}__build_config") {
424 type = "android_library" 425 type = "android_library"
425 426
426 deps = [] 427 deps = []
427 if (defined(invoker.deps)) { 428 if (defined(invoker.deps)) {
428 deps += invoker.deps 429 deps += invoker.deps
429 } 430 }
430 431
431 # base_path 432 # base_path
432 } 433 }
433 434
434 jar_path = base_path + ".jar"
435 android_java_library(target_name) { 435 android_java_library(target_name) {
436 java_files = invoker.java_files 436 java_files = invoker.java_files
437 build_config = build_config 437 build_config = build_config
438 438
439 if (defined(invoker.jar_excluded_patterns)) { 439 if (defined(invoker.jar_excluded_patterns)) {
440 jar_excluded_patterns = invoker.jar_excluded_patterns 440 jar_excluded_patterns = invoker.jar_excluded_patterns
441 } 441 }
442 442
443 if (defined(invoker.srcjar_deps)) { 443 if (defined(invoker.srcjar_deps)) {
444 srcjar_deps = invoker.srcjar_deps 444 srcjar_deps = invoker.srcjar_deps
445 } 445 }
446 } 446 }
447 } 447 }
448
449
450 # Declare an Android apk target
451 #
452 # This target creates an Android APK containing java code, resources, assets,
453 # and (possibly) native libraries.
454 #
455 # Variables
456 # android_manifest: Path to AndroidManifest.xml.
457 # deps: List of dependencies. All Android java resources and libraries in the
458 # "transitive closure" of these dependencies will be included in the apk.
459 # Note: this "transitive closure" actually only includes such targets if
460 # they are depended on through android_library or android_resources targets
461 # (and so not through builtin targets like 'action', 'group', etc).
462 # java_files: List of .java files to include in the apk.
463 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
464 # will be added to java_files and be included in this apk.
465 # apk_name: Name for final apk.
466 # final_apk_path: Path to final built apk. Default is
467 # $root_out_dir/apks/$apk_name.apk. Setting this will override apk_name.
468 # native_libs: List paths of native libraries to include in this apk. If these
469 # libraries depend on other shared_library targets, those dependencies will
470 # also be included in the apk.
471 #
472 # Example
473 # android_apk("foo_apk") {
474 # android_manifest = "AndroidManifest.xml"
475 # java_files = [
476 # "android/org/chromium/foo/FooApplication.java",
477 # "android/org/chromium/foo/FooActivity.java",
478 # ]
479 # deps = [
480 # ":foo_support_java"
481 # ":foo_resources"
482 # ]
483 # srcjar_deps = [
484 # ":foo_generated_enum"
485 # ]
486 # native_libs = [
487 # native_lib_path
488 # ]
489 # }
490 template("android_apk") {
491 gen_dir = "$target_gen_dir/$target_name"
492 base_path = "$gen_dir/$target_name"
493 build_config = base_path + ".build_config"
494 resource_zip_path = base_path + ".resources.zip"
495 all_resources_zip_path = base_path + ".resources.all.zip"
496 resource_srcjar_path = base_path + ".resources.srcjar"
497 jar_path = base_path + ".jar"
498
499 # Just mark these as used for now.
500 assert(!defined(invoker.native_libs)
newt (away) 2014/07/17 20:11:47 why not just add "|| true" ?
cjhopman 2014/07/18 00:58:01 Done.
501 || invoker.native_libs == [] || invoker.native_libs != [])
502 assert(!defined(invoker.final_apk_path)
503 || invoker.final_apk_path == "" || invoker.final_apk_path != "")
504
505 final_deps = []
506
507 # TODO(cjhopman): Remove this once we correctly generate the real
508 # NativeLibraries.java
509 srcjar_deps = [ "//base:base_native_libraries_gen" ]
510 if (defined(invoker.srcjar_deps)) {
511 srcjar_deps += invoker.srcjar_deps
512 }
513
514 write_build_config("${target_name}__build_config") {
515 type = "android_apk"
516 srcjar = resource_srcjar_path
517 resources_zip = resource_zip_path
518
519 if (defined(invoker.deps)) {
520 deps = invoker.deps
521 }
522 }
523
524 final_deps += [":${target_name}__process_resources"]
525 process_resources("${target_name}__process_resources") {
526 android_manifest = invoker.android_manifest
527
528 resource_dirs = ["//build/android/ant/empty/res"]
529 zip_path = resource_zip_path
530 srcjar_path = resource_srcjar_path
531
532 generate_constant_ids = true
533 }
534
535 final_deps += [":${target_name}__java"]
536 android_java_library("${target_name}__java") {
537 java_files = invoker.java_files
538 }
539
540 # TODO(cjhopman): dex
541 # TODO(cjhopman): native
542 # TODO(cjhopman): create+finalize apk
543
544 group(target_name) {
545 deps = final_deps
546 }
547 }
548
549
550 # Declare an Android gtest apk
551 #
552 # This target creates an Android apk for running gtest-based unittests.
553 #
554 # Variables
555 # deps: Specifies the dependencies of this target. These will be passed to
556 # the underlying android_apk invocation and should include the java and
557 # resource dependencies of the apk.
558 # unittests_dep: This should be the label of the gtest native target. This
559 # target must be defined previously in the same file.
560 #
561 # Example
562 # unittest_apk("foo_unittests_apk") {
563 # deps = [ ":foo_java", ":foo_resources" ]
564 # unittests_dep = ":foo_unittests"
565 # }
566 template("unittest_apk") {
567 test_suite_name = get_label_info(invoker.unittests_dep, "name")
568 android_apk(target_name) {
569 apk_name = test_suite_name
570 final_apk_path = "$root_build_dir/${apk_name}_apk/${apk_name}-debug.apk"
571 java_files = [
572 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActiv ity.java"
573 ]
574 android_manifest = "//testing/android/java/AndroidManifest.xml"
575 unittests_outputs = get_target_outputs(invoker.unittests_dep)
576 native_libs = [unittests_outputs[0]]
577 if (defined(invoker.deps)) {
578 deps = invoker.deps
579 }
580 }
581 }
OLDNEW
« build/config/android/internal_rules.gni ('K') | « build/config/android/internal_rules.gni ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698