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
3 # found in the LICENSE file.
5 import("//base/android/linker/config.gni")
6 import("//build/config/android/config.gni")
7 import("//build/config/android/internal_rules.gni")
8 import("//tools/grit/grit_rule.gni")
9 import("//tools/relocation_packer/config.gni")
13 # Declare a jni target
15 # This target generates the native jni bindings for a set of .java files.
17 # See base/android/jni_generator/jni_generator.py for more info about the
18 # format of generating JNI bindings.
21 # sources: list of .java files to generate jni for
22 # jni_package: subdirectory path for generated bindings
25 # generate_jni("foo_jni") {
27 # "android/java/src/org/chromium/foo/Foo.java",
28 # "android/java/src/org/chromium/foo/FooUtil.java",
32 template("generate_jni") {
33 set_sources_assignment_filter([])
34 if (defined(invoker.testonly)) {
35 testonly = invoker.testonly
38 assert(defined(invoker.sources))
39 assert(defined(invoker.jni_package))
40 jni_package = invoker.jni_package
41 base_output_dir = "${target_gen_dir}/${target_name}"
42 package_output_dir = "${base_output_dir}/${jni_package}"
43 jni_output_dir = "${package_output_dir}/jni"
45 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h"
47 foreach_target_name = "${target_name}__jni_gen"
48 action_foreach(foreach_target_name) {
49 script = "//base/android/jni_generator/jni_generator.py"
50 depfile = "$target_gen_dir/$target_name.{{source_name_part}}.d"
51 sources = invoker.sources
54 "${jni_output_dir}/{{source_name_part}}_jni.h",
59 rebase_path(depfile, root_build_dir),
60 "--input_file={{source}}",
61 "--optimize_generation=1",
64 rebase_path(jni_output_dir, root_build_dir),
66 rebase_path(jni_generator_include, jni_output_dir),
67 "--native_exports_optional",
69 if (defined(invoker.jni_generator_jarjar_file)) {
72 rebase_path(jni_generator_jarjar_file, root_build_dir),
77 config("jni_includes_${target_name}") {
78 # TODO(cjhopman): #includes should probably all be relative to
79 # base_output_dir. Remove that from this config once the includes are
89 ":$foreach_target_name",
91 public_configs = [ ":jni_includes_${target_name}" ]
93 if (defined(invoker.deps)) {
96 if (defined(invoker.public_deps)) {
97 public_deps = invoker.public_deps
100 if (defined(invoker.visibility)) {
101 visibility = invoker.visibility
106 # Declare a jni target for a prebuilt jar
108 # This target generates the native jni bindings for a set of classes in a .jar.
110 # See base/android/jni_generator/jni_generator.py for more info about the
111 # format of generating JNI bindings.
114 # classes: list of .class files in the jar to generate jni for. These should
115 # include the full path to the .class file.
116 # jni_package: subdirectory path for generated bindings
117 # jar_file: the path to the .jar. If not provided, will default to the sdk's
120 # deps, public_deps: As normal
123 # generate_jar_jni("foo_jni") {
125 # "android/view/Foo.class",
127 # jni_package = "foo"
129 template("generate_jar_jni") {
130 set_sources_assignment_filter([])
131 if (defined(invoker.testonly)) {
132 testonly = invoker.testonly
135 assert(defined(invoker.classes))
136 assert(defined(invoker.jni_package))
138 if (defined(invoker.jar_file)) {
139 jar_file = invoker.jar_file
141 jar_file = android_sdk_jar
144 jni_package = invoker.jni_package
145 base_output_dir = "${root_gen_dir}/${target_name}/${jni_package}"
146 jni_output_dir = "${base_output_dir}/jni"
148 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h"
150 # TODO(cjhopman): make jni_generator.py support generating jni for multiple
151 # .class files from a .jar.
153 foreach(class, invoker.classes) {
155 _classname_list = process_file_template([ class ], "{{source_name_part}}")
156 classname = _classname_list[0]
157 jni_target_name = "${target_name}__jni_${classname}"
158 jni_actions += [ ":$jni_target_name" ]
159 action(jni_target_name) {
160 # The sources aren't compiled so don't check their dependencies.
161 check_includes = false
162 depfile = "$target_gen_dir/$target_name.d"
163 script = "//base/android/jni_generator/jni_generator.py"
169 "${jni_output_dir}/${classname}_jni.h",
174 rebase_path(depfile, root_build_dir),
176 rebase_path(jar_file, root_build_dir),
179 "--optimize_generation=1",
182 rebase_path(jni_output_dir, root_build_dir),
184 rebase_path(jni_generator_include, jni_output_dir),
185 "--native_exports_optional",
190 config("jni_includes_${target_name}") {
191 include_dirs = [ base_output_dir ]
196 if (defined(invoker.deps)) {
199 if (defined(invoker.public_deps)) {
200 public_deps = invoker.public_deps
202 public_configs = [ ":jni_includes_${target_name}" ]
206 # Declare a target for c-preprocessor-generated java files
208 # NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum
211 # This target generates java files using the host C pre-processor. Each file in
212 # sources will be compiled using the C pre-processor. If include_path is
213 # specified, it will be passed (with --I) to the pre-processor.
215 # This target will create a single .srcjar. Adding this target to an
216 # android_library target's srcjar_deps will make the generated java files be
217 # included in that library's final outputs.
220 # sources: list of files to be processed by the C pre-processor. For each
221 # file in sources, there will be one .java file in the final .srcjar. For a
222 # file named FooBar.template, a java file will be created with name
224 # inputs: additional compile-time dependencies. Any files
225 # `#include`-ed in the templates should be listed here.
226 # package_name: this will be the subdirectory for each .java file in the
230 # java_cpp_template("foo_generated_enum") {
232 # "android/java/templates/Foo.template",
235 # "android/java/templates/native_foo_header.h",
238 # package_name = "org/chromium/base/library_loader"
239 # include_path = "android/java/templates"
241 template("java_cpp_template") {
242 set_sources_assignment_filter([])
243 if (defined(invoker.testonly)) {
244 testonly = invoker.testonly
247 assert(defined(invoker.sources))
248 package_name = invoker.package_name + ""
250 if (defined(invoker.include_path)) {
251 include_path = invoker.include_path + ""
256 action_foreach("${target_name}__apply_gcc") {
257 script = "//build/android/gyp/gcc_preprocess.py"
258 if (defined(invoker.inputs)) {
259 inputs = invoker.inputs + []
261 depfile = "${target_gen_dir}/${target_name}_{{source_name_part}}.d"
263 sources = invoker.sources
266 "${target_gen_dir}/${target_name}/java_cpp_template/${package_name}"
267 gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java"
271 gcc_template_output_pattern,
276 rebase_path(depfile, root_build_dir),
278 rebase_path(include_path, root_build_dir),
280 rebase_path(gen_dir, root_build_dir) + "/{{source_name_part}}.java",
281 "--template={{source}}",
284 if (defined(invoker.defines)) {
285 foreach(def, invoker.defines) {
294 apply_gcc_outputs = get_target_outputs(":${target_name}__apply_gcc")
295 base_gen_dir = get_label_info(":${target_name}__apply_gcc", "target_gen_dir")
297 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
298 zip("${target_name}__zip_srcjar") {
299 inputs = apply_gcc_outputs
301 base_dir = base_gen_dir
306 ":${target_name}__zip_srcjar",
311 # Declare a target for generating Java classes from C++ enums.
313 # This target generates Java files from C++ enums using a script.
315 # This target will create a single .srcjar. Adding this target to an
316 # android_library target's srcjar_deps will make the generated java files be
317 # included in that library's final outputs.
320 # sources: list of files to be processed by the script. For each annotated
321 # enum contained in the sources files the script will generate a .java
322 # file with the same name as the name of the enum.
324 # outputs: list of outputs, relative to the output_dir. These paths are
325 # verified at build time by the script. To get the list programatically run:
326 # python build/android/gyp/java_cpp_enum.py \
327 # --print_output_only . path/to/header/file.h
330 # java_cpp_enum("foo_generated_enum") {
332 # "src/native_foo_header.h",
335 # "org/chromium/FooEnum.java",
338 template("java_cpp_enum") {
339 set_sources_assignment_filter([])
340 if (defined(invoker.testonly)) {
341 testonly = invoker.testonly
344 assert(defined(invoker.sources))
345 assert(defined(invoker.outputs))
347 action("${target_name}__generate_enum") {
348 # The sources aren't compiled so don't check their dependencies.
349 check_includes = false
351 sources = invoker.sources
352 script = "//build/android/gyp/java_cpp_enum.py"
353 gen_dir = "${target_gen_dir}/${target_name}/enums"
355 get_path_info(rebase_path(invoker.outputs, ".", gen_dir), "abspath")
358 foreach(output, rebase_path(outputs, root_build_dir)) {
364 args += [ rebase_path(gen_dir, root_build_dir) ]
365 args += rebase_path(invoker.sources, root_build_dir)
368 generate_enum_outputs = get_target_outputs(":${target_name}__generate_enum")
370 get_label_info(":${target_name}__generate_enum", "target_gen_dir")
372 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
373 zip("${target_name}__zip_srcjar") {
374 inputs = generate_enum_outputs
376 base_dir = base_gen_dir
381 ":${target_name}__zip_srcjar",
386 # Declare a target for processing a Jinja template.
389 # input: The template file to be processed.
390 # output: Where to save the result.
391 # variables: (Optional) A list of variables to make available to the template
392 # processing environment, e.g. ["name=foo", "color=red"].
395 # jinja_template("chrome_shell_manifest") {
396 # input = "shell/java/AndroidManifest.xml"
397 # output = "$target_gen_dir/AndroidManifest.xml"
399 template("jinja_template") {
400 set_sources_assignment_filter([])
401 if (defined(invoker.testonly)) {
402 testonly = invoker.testonly
405 assert(defined(invoker.input))
406 assert(defined(invoker.output))
408 action(target_name) {
412 script = "//build/android/gyp/jinja_template.py"
413 depfile = "$target_gen_dir/$target_name.d"
422 rebase_path(invoker.input, root_build_dir),
424 rebase_path(invoker.output, root_build_dir),
426 rebase_path(depfile, root_build_dir),
428 if (defined(invoker.variables)) {
429 variables = invoker.variables
430 args += [ "--variables=${variables}" ]
435 # Declare a target for processing Android resources as Jinja templates.
437 # This takes an Android resource directory where each resource is a Jinja
438 # template, processes each template, then packages the results in a zip file
439 # which can be consumed by an android resources, library, or apk target.
441 # If this target is included in the deps of an android resources/library/apk,
442 # the resources will be included with that target.
445 # resources: The list of resources files to process.
446 # res_dir: The resource directory containing the resources.
447 # variables: (Optional) A list of variables to make available to the template
448 # processing environment, e.g. ["name=foo", "color=red"].
451 # jinja_template_resources("chrome_shell_template_resources") {
452 # res_dir = "shell/res_template"
453 # resources = ["shell/res_template/xml/syncable.xml"]
454 # variables = ["color=red"]
456 template("jinja_template_resources") {
457 set_sources_assignment_filter([])
458 if (defined(invoker.testonly)) {
459 testonly = invoker.testonly
462 assert(defined(invoker.resources))
463 assert(defined(invoker.res_dir))
465 _base_path = "$target_gen_dir/$target_name"
466 _resources_zip = _base_path + ".resources.zip"
467 _build_config = _base_path + ".build_config"
469 write_build_config("${target_name}__build_config") {
470 build_config = _build_config
471 resources_zip = _resources_zip
472 type = "android_resources"
475 action("${target_name}__template") {
476 sources = invoker.resources
477 script = "//build/android/gyp/jinja_template.py"
478 depfile = "$target_gen_dir/$target_name.d"
485 rebased_resources = rebase_path(invoker.resources, root_build_dir)
487 "--inputs=${rebased_resources}",
489 rebase_path(invoker.res_dir, root_build_dir),
491 rebase_path(_resources_zip, root_build_dir),
493 rebase_path(depfile, root_build_dir),
495 if (defined(invoker.variables)) {
496 variables = invoker.variables
497 args += [ "--variables=${variables}" ]
503 ":${target_name}__build_config",
504 ":${target_name}__template",
509 # Declare an Android resources target
511 # This creates a resources zip file that will be used when building an Android
512 # library or apk and included into a final apk.
514 # To include these resources in a library/apk, this target should be listed in
515 # the library's deps. A library/apk will also include any resources used by its
519 # deps: Specifies the dependencies of this target. Any Android resources
520 # listed in deps will be included by libraries/apks that depend on this
522 # resource_dirs: List of directories containing resources for this target.
523 # android_manifest: AndroidManifest.xml for this target. Defaults to
524 # //build/android/AndroidManifest.xml.
525 # custom_package: java package for generated .java files.
526 # v14_verify_only: If true, don't generate v14/v17 resources and just verify
527 # that the resources are v14-compliant (see
528 # build/android/gyp/generate_v14_compatible_resources.py). Defaults to
530 # shared_resources: If true make a resource package that can be loaded by a
531 # different application at runtime to access the package's resources.
534 # android_resources("foo_resources") {
535 # deps = [":foo_strings_grd"]
536 # resource_dirs = ["res"]
537 # custom_package = "org.chromium.foo"
539 template("android_resources") {
540 set_sources_assignment_filter([])
541 if (defined(invoker.testonly)) {
542 testonly = invoker.testonly
545 assert(defined(invoker.resource_dirs))
546 assert(defined(invoker.android_manifest) || defined(invoker.custom_package))
548 base_path = "$target_gen_dir/$target_name"
549 zip_path = base_path + ".resources.zip"
550 srcjar_path = base_path + ".srcjar"
551 build_config = base_path + ".build_config"
553 write_build_config("${target_name}__build_config") {
554 type = "android_resources"
555 resources_zip = zip_path
557 if (defined(invoker.deps)) {
560 if (defined(invoker.android_manifest)) {
561 android_manifest = invoker.android_manifest
563 if (defined(invoker.custom_package)) {
564 custom_package = invoker.custom_package
568 android_manifest = "//build/android/AndroidManifest.xml"
569 if (defined(invoker.android_manifest)) {
570 android_manifest = invoker.android_manifest
573 process_resources("${target_name}__process_resources") {
574 resource_dirs = invoker.resource_dirs
575 if (defined(invoker.custom_package)) {
576 custom_package = invoker.custom_package
579 if (defined(invoker.v14_verify_only)) {
580 v14_verify_only = invoker.v14_verify_only
583 if (defined(invoker.shared_resources)) {
584 shared_resources = invoker.shared_resources
590 ":${target_name}__build_config",
591 ":${target_name}__process_resources",
596 # Declare a target that generates localized strings.xml from a .grd file.
598 # If this target is included in the deps of an android resources/library/apk,
599 # the strings.xml will be included with that target.
602 # deps: Specifies the dependencies of this target.
603 # grd_file: Path to the .grd file to generate strings.xml from.
604 # outputs: Expected grit outputs (see grit rule).
607 # java_strings_grd("foo_strings_grd") {
608 # grd_file = "foo_strings.grd"
610 template("java_strings_grd") {
611 set_sources_assignment_filter([])
612 if (defined(invoker.testonly)) {
613 testonly = invoker.testonly
616 base_path = "$target_gen_dir/$target_name"
617 resources_zip = base_path + ".resources.zip"
618 build_config = base_path + ".build_config"
620 write_build_config("${target_name}__build_config") {
621 type = "android_resources"
622 if (defined(invoker.deps)) {
627 # Put grit files into this subdirectory of target_gen_dir.
628 extra_output_path = target_name + "_grit_output"
630 grit_target_name = "${target_name}__grit"
631 grit_output_dir = "$target_gen_dir/$extra_output_path"
632 grit(grit_target_name) {
635 "ANDROID_JAVA_TAGGED_ONLY=false",
637 output_dir = grit_output_dir
639 source = invoker.grd_file
640 outputs = invoker.outputs
643 # This needs to get outputs from grit's internal target, not the final
645 generate_strings_outputs = get_target_outputs(":${grit_target_name}_grit")
647 zip("${target_name}__zip") {
648 base_dir = grit_output_dir
649 inputs = generate_strings_outputs
650 output = resources_zip
655 ":${target_name}__build_config",
656 ":${target_name}__zip",
661 # Declare a target that packages strings.xml generated from a grd file.
663 # If this target is included in the deps of an android resources/library/apk,
664 # the strings.xml will be included with that target.
667 # grit_output_dir: directory containing grit-generated files.
668 # generated_files: list of android resource files to package.
671 # java_strings_grd_prebuilt("foo_strings_grd") {
672 # grit_output_dir = "$root_gen_dir/foo/grit"
673 # generated_files = [
674 # "values/strings.xml"
677 template("java_strings_grd_prebuilt") {
678 set_sources_assignment_filter([])
679 if (defined(invoker.testonly)) {
680 testonly = invoker.testonly
683 base_path = "$target_gen_dir/$target_name"
684 resources_zip = base_path + ".resources.zip"
685 build_config = base_path + ".build_config"
687 write_build_config("${target_name}__build_config") {
688 type = "android_resources"
689 if (defined(invoker.deps)) {
694 zip("${target_name}__zip") {
695 base_dir = invoker.grit_output_dir
696 inputs = rebase_path(invoker.generated_files, ".", base_dir)
697 output = resources_zip
702 ":${target_name}__build_config",
703 ":${target_name}__zip",
708 # Declare a Java executable target
710 # This target creates an executable from java code and libraries. The executable
711 # will be in the output folder's /bin/ directory.
714 # deps: Specifies the dependencies of this target. Java targets in this list
715 # will be included in the executable (and the javac classpath).
717 # java_files: List of .java files included in this library.
718 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
719 # will be added to java_files and be included in this library.
720 # srcjars: List of srcjars to be included in this library, together with the
721 # ones obtained from srcjar_deps.
723 # bypass_platform_checks: Disables checks about cross-platform (Java/Android)
724 # dependencies for this target. This will allow depending on an
725 # android_library target, for example.
727 # chromium_code: If true, extra analysis warning/errors will be enabled.
732 # java_binary("foo") {
733 # java_files = [ "org/chromium/foo/FooMain.java" ]
734 # deps = [ ":bar_java" ]
735 # main_class = "org.chromium.foo.FooMain"
737 template("java_binary") {
738 set_sources_assignment_filter([])
740 # TODO(cjhopman): This should not act like a java_library for dependents (i.e.
741 # dependents shouldn't get the jar in their classpath, etc.).
742 java_library_impl(target_name) {
743 if (defined(invoker.DEPRECATED_java_in_dir)) {
744 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
746 if (defined(invoker.chromium_code)) {
747 chromium_code = invoker.chromium_code
749 if (defined(invoker.datadeps)) {
750 deps = invoker.datadeps
752 if (defined(invoker.deps)) {
755 if (defined(invoker.java_files)) {
756 java_files = invoker.java_files
758 if (defined(invoker.srcjar_deps)) {
759 srcjar_deps = invoker.srcjar_deps
761 if (defined(invoker.srcjars)) {
762 srcjars = invoker.srcjars
764 if (defined(invoker.bypass_platform_checks)) {
765 bypass_platform_checks = invoker.bypass_platform_checks
767 if (defined(invoker.testonly)) {
768 testonly = invoker.testonly
771 main_class = invoker.main_class
775 # Declare a Junit executable target
777 # This target creates an executable from java code for running as a junit test
778 # suite. The executable will be in the output folder's /bin/ directory.
781 # deps: Specifies the dependencies of this target. Java targets in this list
782 # will be included in the executable (and the javac classpath).
784 # java_files: List of .java files included in this library.
785 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
786 # will be added to java_files and be included in this library.
787 # srcjars: List of srcjars to be included in this library, together with the
788 # ones obtained from srcjar_deps.
790 # chromium_code: If true, extra analysis warning/errors will be enabled.
793 # junit_binary("foo") {
794 # java_files = [ "org/chromium/foo/FooTest.java" ]
795 # deps = [ ":bar_java" ]
797 template("junit_binary") {
798 set_sources_assignment_filter([])
800 java_binary(target_name) {
801 bypass_platform_checks = true
802 main_class = "org.chromium.testing.local.JunitTestMain"
805 if (defined(invoker.DEPRECATED_java_in_dir)) {
806 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
808 if (defined(invoker.chromium_code)) {
809 chromium_code = invoker.chromium_code
812 "//testing/android/junit:junit_test_support",
813 "//third_party/junit",
814 "//third_party/mockito:mockito_java",
815 "//third_party/robolectric:robolectric_java",
816 "//third_party/robolectric:android-all-4.3_r2-robolectric-0",
818 if (defined(invoker.deps)) {
821 if (defined(invoker.java_files)) {
822 java_files = invoker.java_files
824 if (defined(invoker.srcjar_deps)) {
825 srcjar_deps = invoker.srcjar_deps
827 if (defined(invoker.srcjars)) {
828 srcjars = invoker.srcjars
833 # Declare a java library target
836 # deps: Specifies the dependencies of this target. Java targets in this list
837 # will be added to the javac classpath.
839 # java_files: List of .java files included in this library.
840 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
841 # will be added to java_files and be included in this library.
842 # srcjars: List of srcjars to be included in this library, together with the
843 # ones obtained from srcjar_deps.
844 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in
845 # this directory will be included in the library. This is only supported to
846 # ease the gyp->gn conversion and will be removed in the future.
848 # chromium_code: If true, extra analysis warning/errors will be enabled.
849 # jar_excluded_patterns: List of patterns of .class files to exclude from the
852 # proguard_preprocess: If true, proguard preprocessing will be run. This can
853 # be used to remove unwanted parts of the library.
854 # proguard_config: Path to the proguard config for preprocessing.
856 # supports_android: If true, Android targets (android_library, android_apk)
857 # may depend on this target. Note: if true, this target must only use the
858 # subset of Java available on Android.
859 # bypass_platform_checks: Disables checks about cross-platform (Java/Android)
860 # dependencies for this target. This will allow depending on an
861 # android_library target, for example.
866 # java_library("foo_java") {
868 # "org/chromium/foo/Foo.java",
869 # "org/chromium/foo/FooInterface.java",
870 # "org/chromium/foo/FooService.java",
876 # ":foo_generated_enum"
878 # jar_excluded_patterns = [
879 # "*/FooService.class", "*/FooService##*.class"
882 template("java_library") {
883 set_sources_assignment_filter([])
884 java_library_impl(target_name) {
885 if (defined(invoker.DEPRECATED_java_in_dir)) {
886 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
888 if (defined(invoker.chromium_code)) {
889 chromium_code = invoker.chromium_code
891 if (defined(invoker.datadeps)) {
892 deps = invoker.datadeps
894 if (defined(invoker.deps)) {
897 if (defined(invoker.jar_excluded_patterns)) {
898 jar_excluded_patterns = invoker.jar_excluded_patterns
900 if (defined(invoker.java_files)) {
901 java_files = invoker.java_files
903 if (defined(invoker.proguard_config)) {
904 proguard_config = invoker.proguard_config
906 if (defined(invoker.proguard_preprocess)) {
907 proguard_preprocess = invoker.proguard_preprocess
909 if (defined(invoker.srcjar_deps)) {
910 srcjar_deps = invoker.srcjar_deps
912 if (defined(invoker.srcjars)) {
913 srcjars = invoker.srcjars
915 if (defined(invoker.bypass_platform_checks)) {
916 bypass_platform_checks = invoker.bypass_platform_checks
918 if (defined(invoker.testonly)) {
919 testonly = invoker.testonly
921 if (defined(invoker.jar_path)) {
922 jar_path = invoker.jar_path
925 if (defined(invoker.supports_android) && invoker.supports_android) {
926 supports_android = true
931 # Declare a java library target for a prebuilt jar
934 # deps: Specifies the dependencies of this target. Java targets in this list
935 # will be added to the javac classpath.
936 # jar_path: Path to the prebuilt jar.
937 # proguard_preprocess: If true, proguard preprocessing will be run. This can
938 # be used to remove unwanted parts of the library.
939 # proguard_config: Path to the proguard config for preprocessing.
942 # java_prebuilt("foo_java") {
943 # jar_path = "foo.jar"
949 template("java_prebuilt") {
950 set_sources_assignment_filter([])
951 java_prebuilt_impl(target_name) {
952 jar_path = invoker.jar_path
953 if (defined(invoker.testonly)) {
954 testonly = invoker.testonly
956 if (defined(invoker.deps)) {
959 if (defined(invoker.proguard_config)) {
960 proguard_config = invoker.proguard_config
962 if (defined(invoker.proguard_preprocess)) {
963 proguard_preprocess = invoker.proguard_preprocess
968 # Declare an Android library target
970 # This target creates an Android library containing java code and Android
974 # deps: Specifies the dependencies of this target. Java targets in this list
975 # will be added to the javac classpath. Android resources in dependencies
976 # will be used when building this library.
978 # java_files: List of .java files included in this library.
979 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
980 # will be added to java_files and be included in this library.
981 # srcjars: List of srcjars to be included in this library, together with the
982 # ones obtained from srcjar_deps.
983 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in
984 # this directory will be included in the library. This is only supported to
985 # ease the gyp->gn conversion and will be removed in the future.
987 # chromium_code: If true, extra analysis warning/errors will be enabled.
988 # jar_excluded_patterns: List of patterns of .class files to exclude from the
991 # proguard_preprocess: If true, proguard preprocessing will be run. This can
992 # be used to remove unwanted parts of the library.
993 # proguard_config: Path to the proguard config for preprocessing.
995 # dex_path: If set, the resulting .dex.jar file will be placed under this
1000 # android_library("foo_java") {
1002 # "android/org/chromium/foo/Foo.java",
1003 # "android/org/chromium/foo/FooInterface.java",
1004 # "android/org/chromium/foo/FooService.java",
1010 # ":foo_generated_enum"
1012 # jar_excluded_patterns = [
1013 # "*/FooService.class", "*/FooService##*.class"
1016 template("android_library") {
1017 set_sources_assignment_filter([])
1018 assert(!defined(invoker.jar_path),
1019 "android_library does not support a custom jar path")
1020 java_library_impl(target_name) {
1021 if (defined(invoker.DEPRECATED_java_in_dir)) {
1022 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
1024 if (defined(invoker.chromium_code)) {
1025 chromium_code = invoker.chromium_code
1027 if (defined(invoker.datadeps)) {
1028 deps = invoker.datadeps
1030 if (defined(invoker.deps)) {
1033 if (defined(invoker.jar_excluded_patterns)) {
1034 jar_excluded_patterns = invoker.jar_excluded_patterns
1036 if (defined(invoker.java_files)) {
1037 java_files = invoker.java_files
1039 if (defined(invoker.proguard_config)) {
1040 proguard_config = invoker.proguard_config
1042 if (defined(invoker.proguard_preprocess)) {
1043 proguard_preprocess = invoker.proguard_preprocess
1045 if (defined(invoker.srcjar_deps)) {
1046 srcjar_deps = invoker.srcjar_deps
1048 if (defined(invoker.srcjars)) {
1049 srcjars = invoker.srcjars
1051 if (defined(invoker.testonly)) {
1052 testonly = invoker.testonly
1054 if (defined(invoker.visibility)) {
1055 visibility = invoker.visibility
1057 if (defined(invoker.dex_path)) {
1058 dex_path = invoker.dex_path
1060 if (defined(invoker.manifest_entries)) {
1061 manifest_entries = invoker.manifest_entries
1064 supports_android = true
1065 requires_android = true
1067 if (!defined(jar_excluded_patterns)) {
1068 jar_excluded_patterns = []
1070 jar_excluded_patterns += [
1074 "*/Manifest##*.class",
1079 # Declare a target that packages a set of Java dependencies into a standalone
1083 # deps: specifies the dependencies of this target. Android libraries in deps
1084 # will be packaged into the resulting .dex.jar file.
1085 # dex_path: location at which the output file will be put
1086 template("android_standalone_library") {
1087 set_sources_assignment_filter([])
1088 deps_dex(target_name) {
1090 dex_path = invoker.dex_path
1091 if (defined(invoker.excluded_jars)) {
1092 excluded_jars = invoker.excluded_jars
1097 # Declare an Android library target for a prebuilt jar
1099 # This target creates an Android library containing java code and Android
1103 # deps: Specifies the dependencies of this target. Java targets in this list
1104 # will be added to the javac classpath. Android resources in dependencies
1105 # will be used when building this library.
1106 # jar_path: Path to the prebuilt jar.
1107 # proguard_preprocess: If true, proguard preprocessing will be run. This can
1108 # be used to remove unwanted parts of the library.
1109 # proguard_config: Path to the proguard config for preprocessing.
1112 # android_java_prebuilt("foo_java") {
1113 # jar_path = "foo.jar"
1119 template("android_java_prebuilt") {
1120 set_sources_assignment_filter([])
1121 java_prebuilt_impl(target_name) {
1122 jar_path = invoker.jar_path
1123 supports_android = true
1124 requires_android = true
1125 if (defined(invoker.testonly)) {
1126 testonly = invoker.testonly
1128 if (defined(invoker.deps)) {
1131 if (defined(invoker.proguard_config)) {
1132 proguard_config = invoker.proguard_config
1134 if (defined(invoker.proguard_preprocess)) {
1135 proguard_preprocess = invoker.proguard_preprocess
1140 # Declare an Android apk target
1142 # This target creates an Android APK containing java code, resources, assets,
1143 # and (possibly) native libraries.
1146 # android_manifest: Path to AndroidManifest.xml.
1147 # datadeps: List of dependencies needed at runtime. These will be built but
1148 # won't change the generated .apk in any way (in fact they may be built
1149 # after the .apk is).
1150 # deps: List of dependencies. All Android java resources and libraries in the
1151 # "transitive closure" of these dependencies will be included in the apk.
1152 # Note: this "transitive closure" actually only includes such targets if
1153 # they are depended on through android_library or android_resources targets
1154 # (and so not through builtin targets like 'action', 'group', etc).
1155 # java_files: List of .java files to include in the apk.
1156 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
1157 # will be added to java_files and be included in this apk.
1158 # apk_name: Name for final apk.
1159 # final_apk_path: Path to final built apk. Default is
1160 # $root_out_dir/apks/$apk_name.apk. Setting this will override apk_name.
1161 # native_libs: List paths of native libraries to include in this apk. If these
1162 # libraries depend on other shared_library targets, those dependencies will
1163 # also be included in the apk.
1164 # apk_under_test: For an instrumentation test apk, this is the target of the
1166 # testonly: Marks this target as "test-only".
1168 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in
1169 # this directory will be included in the library. This is only supported to
1170 # ease the gyp->gn conversion and will be removed in the future.
1173 # android_apk("foo_apk") {
1174 # android_manifest = "AndroidManifest.xml"
1176 # "android/org/chromium/foo/FooApplication.java",
1177 # "android/org/chromium/foo/FooActivity.java",
1180 # ":foo_support_java"
1184 # ":foo_generated_enum"
1190 template("android_apk") {
1191 set_sources_assignment_filter([])
1192 if (defined(invoker.testonly)) {
1193 testonly = invoker.testonly
1196 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name))
1197 assert(defined(invoker.android_manifest))
1198 gen_dir = "$target_gen_dir/$target_name"
1199 base_path = "$gen_dir/$target_name"
1200 _build_config = "$target_gen_dir/$target_name.build_config"
1201 resources_zip_path = "$base_path.resources.zip"
1202 all_resources_zip_path = "$base_path.resources.all.zip"
1203 jar_path = "$base_path.jar"
1204 final_dex_path = "$gen_dir/classes.dex"
1205 _template_name = target_name
1206 _final_apk_path = ""
1207 if (defined(invoker.final_apk_path)) {
1208 _final_apk_path = invoker.final_apk_path
1209 } else if (defined(invoker.apk_name)) {
1210 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk"
1212 _dist_jar_path_list =
1213 process_file_template(
1214 [ _final_apk_path ],
1215 "$root_build_dir/test.lib.java/{{source_name_part}}.jar")
1216 _dist_jar_path = _dist_jar_path_list[0]
1220 _keystore_path = android_default_keystore_path
1221 _keystore_name = android_default_keystore_name
1222 _keystore_password = android_default_keystore_password
1224 if (defined(invoker.keystore_path)) {
1225 _keystore_path = invoker.keystore_path
1226 _keystore_name = invoker.keystore_name
1227 _keystore_password = invoker.keystore_password
1231 if (defined(invoker.srcjar_deps)) {
1232 _srcjar_deps += invoker.srcjar_deps
1235 _load_library_from_apk = false
1237 if (defined(invoker.native_libs)) {
1238 _use_chromium_linker = false
1239 if (defined(invoker.use_chromium_linker)) {
1240 _use_chromium_linker =
1241 invoker.use_chromium_linker && chromium_linker_supported
1244 if (defined(invoker.load_library_from_apk) &&
1245 invoker.load_library_from_apk) {
1246 _load_library_from_apk = true
1247 assert(_use_chromium_linker,
1248 "Loading library from the apk requires use" +
1249 " of the Chromium linker.")
1252 _enable_relocation_packing = false
1253 if (defined(invoker.enable_relocation_packing) &&
1254 invoker.enable_relocation_packing) {
1255 _enable_relocation_packing = relocation_packing_supported
1256 assert(_use_chromium_linker,
1257 "Relocation packing requires use of the" + " Chromium linker.")
1260 _native_libs = process_file_template(
1261 invoker.native_libs,
1262 "$root_build_dir/lib.stripped/{{source_file_part}}")
1264 _native_libs_dir = base_path + "/libs"
1266 if (_use_chromium_linker) {
1268 [ "$root_build_dir/lib.stripped/libchromium_android_linker.so" ]
1271 _enable_relocation_packing = false
1272 if (_use_chromium_linker && defined(invoker.enable_relocation_packing) &&
1273 invoker.enable_relocation_packing) {
1274 _enable_relocation_packing = true
1277 _native_lib_version_name = ""
1278 if (defined(invoker.native_lib_version_name)) {
1279 _native_lib_version_name = invoker.native_lib_version_name
1283 _android_manifest = invoker.android_manifest
1284 _rebased_build_config = rebase_path(_build_config, root_build_dir)
1286 write_build_config("${_template_name}__build_config") {
1287 type = "android_apk"
1288 dex_path = final_dex_path
1289 resources_zip = resources_zip_path
1290 build_config = _build_config
1291 android_manifest = _android_manifest
1293 if (defined(invoker.deps)) {
1297 if (defined(invoker.apk_under_test)) {
1298 apk_under_test = invoker.apk_under_test
1301 native_libs = _native_libs
1306 final_deps += [ ":${_template_name}__process_resources" ]
1307 process_resources("${_template_name}__process_resources") {
1308 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
1309 android_manifest = _android_manifest
1310 resource_dirs = [ "//build/android/ant/empty/res" ]
1311 zip_path = resources_zip_path
1312 generate_constant_ids = true
1313 build_config = _build_config
1315 _srcjar_deps += [ ":${_template_name}__process_resources" ]
1317 if (_native_libs != []) {
1318 _enable_chromium_linker_tests = false
1319 if (defined(invoker.enable_chromium_linker_tests)) {
1320 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
1323 java_cpp_template("${_template_name}__native_libraries_java") {
1324 package_name = "org/chromium/base/library_loader"
1326 "//base/android/java/templates/NativeLibraries.template",
1333 "NATIVE_LIBRARIES_LIST=" +
1334 "@FileArg($_rebased_build_config:native:java_libraries_list)",
1335 "NATIVE_LIBRARIES_VERSION_NUMBER=\"$_native_lib_version_name\"",
1337 if (_use_chromium_linker) {
1338 defines += [ "ENABLE_CHROMIUM_LINKER" ]
1340 if (_load_library_from_apk) {
1341 defines += [ "ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE" ]
1343 if (_enable_chromium_linker_tests) {
1344 defines += [ "ENABLE_CHROMIUM_LINKER_TESTS" ]
1347 _srcjar_deps += [ ":${_template_name}__native_libraries_java" ]
1350 final_deps += [ ":${_template_name}__java" ]
1351 java_library_impl("${_template_name}__java") {
1352 supports_android = true
1353 requires_android = true
1354 override_build_config = _build_config
1355 android_manifest = _android_manifest
1356 chromium_code = true
1357 if (defined(invoker.java_files)) {
1358 java_files = invoker.java_files
1359 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
1360 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
1364 srcjar_deps = _srcjar_deps
1365 dex_path = base_path + ".dex.jar"
1368 if (_dist_jar_path != "") {
1369 final_deps += [ ":${_template_name}__create_dist_jar" ]
1371 # TODO(cjhopman): This is only ever needed to calculate the list of tests to
1372 # run. See build/android/pylib/instrumentation/test_jar.py. We should be
1373 # able to just do that calculation at build time instead.
1374 action("${_template_name}__create_dist_jar") {
1375 script = "//build/android/gyp/create_dist_jar.py"
1376 depfile = "$target_gen_dir/$target_name.d"
1386 rebase_path(depfile, root_build_dir),
1388 rebase_path(_dist_jar_path, root_build_dir),
1389 "--inputs=@FileArg($_rebased_build_config:dist_jar:dependency_jars)",
1391 inputs += [ jar_path ]
1392 _rebased_jar_path = rebase_path([ jar_path ], root_build_dir)
1393 args += [ "--inputs=$_rebased_jar_path" ]
1397 final_deps += [ ":${_template_name}__final_dex" ]
1398 dex("${_template_name}__final_dex") {
1400 ":${_template_name}__java",
1408 output = final_dex_path
1409 dex_arg_key = "${_rebased_build_config}:final_dex:dependency_dex_files"
1410 args = [ "--inputs=@FileArg($dex_arg_key)" ]
1413 if (_native_libs != []) {
1414 action("${_template_name}__prepare_native") {
1415 script = "//build/android/gyp/pack_arm_relocations.py"
1416 packed_libraries_dir = "$_native_libs_dir/$android_app_abi"
1417 depfile = "$target_gen_dir/$target_name.d"
1421 inputs = [ _build_config ] + _native_libs
1423 skip_packing_list = [
1425 "libchromium_android_linker.so",
1428 enable_packing_arg = 0
1429 if (_enable_relocation_packing) {
1430 enable_packing_arg = 1
1431 deps += [ relocation_packer_target ]
1436 rebase_path(depfile, root_build_dir),
1437 "--enable-packing=$enable_packing_arg",
1438 "--has-relocations-with-addends=$relocations_have_addends",
1439 "--exclude-packing-list=$skip_packing_list",
1440 "--android-pack-relocations",
1441 rebase_path(relocation_packer_exe, root_build_dir),
1442 "--android-objcopy",
1443 rebase_path(android_objcopy, root_build_dir),
1444 "--stripped-libraries-dir",
1445 rebase_path(root_build_dir, root_build_dir),
1446 "--packed-libraries-dir",
1447 rebase_path(packed_libraries_dir, root_build_dir),
1448 "--libraries=@FileArg(${_rebased_build_config}:native:libraries)",
1453 rebased_gdbserver = rebase_path([ android_gdbserver ], root_build_dir)
1454 inputs += [ android_gdbserver ]
1455 args += [ "--libraries=$rebased_gdbserver" ]
1460 final_deps += [ ":${_template_name}__create" ]
1461 create_apk("${_template_name}__create") {
1462 apk_path = _final_apk_path
1463 android_manifest = _android_manifest
1464 resources_zip = all_resources_zip_path
1465 dex_path = final_dex_path
1466 load_library_from_apk = _load_library_from_apk
1469 if (defined(invoker.version_code)) {
1470 version_code = invoker.version_code
1473 version_name = "Developer Build"
1474 if (defined(invoker.version_name)) {
1475 version_name = invoker.version_name
1478 keystore_name = _keystore_name
1479 keystore_path = _keystore_path
1480 keystore_password = _keystore_password
1483 if (defined(invoker.asset_location)) {
1484 asset_location = invoker.asset_location
1486 # We don't know the exact dependencies that create the assets in
1487 # |asset_location|; we depend on all caller deps until a better solution
1488 # is figured out (http://crbug.com/433330).
1489 if (defined(invoker.deps)) {
1490 deps += invoker.deps
1494 if (_native_libs != []) {
1495 native_libs_dir = _native_libs_dir
1496 deps += [ ":${_template_name}__prepare_native" ]
1500 group(target_name) {
1502 if (defined(invoker.datadeps)) {
1503 datadeps = invoker.datadeps
1508 # Declare an Android gtest apk
1510 # This target creates an Android apk for running gtest-based unittests.
1513 # deps: Specifies the dependencies of this target. These will be passed to
1514 # the underlying android_apk invocation and should include the java and
1515 # resource dependencies of the apk.
1516 # unittests_dep: This should be the label of the gtest native target. This
1517 # target must be defined previously in the same file.
1518 # unittests_binary: The basename of the library produced by the unittests_dep
1519 # target. If unspecified, it assumes the name of the unittests_dep target
1520 # (which will be correct unless that target specifies an "output_name".
1521 # TODO(brettw) make this automatic by allowing get_target_outputs to
1522 # support executables.
1523 # apk_name: The name of the produced apk. If unspecified, it uses the name
1524 # of the unittests_dep target postfixed with "_apk"
1527 # unittest_apk("foo_unittests_apk") {
1528 # deps = [ ":foo_java", ":foo_resources" ]
1529 # unittests_dep = ":foo_unittests"
1531 template("unittest_apk") {
1532 set_sources_assignment_filter([])
1535 assert(defined(invoker.unittests_dep), "Need unittests_dep for $target_name")
1537 test_suite_name = get_label_info(invoker.unittests_dep, "name")
1539 # This trivial assert is needed in case both unittests_binary and apk_name
1540 # are defined, as otherwise test_suite_name would not be used.
1541 assert(test_suite_name != "")
1543 if (defined(invoker.unittests_binary)) {
1544 unittests_binary = invoker.unittests_binary
1546 unittests_binary = "lib" + test_suite_name + ".so"
1549 if (defined(invoker.apk_name)) {
1550 apk_name = invoker.apk_name
1552 apk_name = test_suite_name
1555 android_apk(target_name) {
1556 final_apk_path = "$root_build_dir/${apk_name}_apk/${apk_name}-debug.apk"
1558 "//testing/android/native_test/java/src/org/chromium/native_test/ChromeNativeTestActivity.java",
1559 "//testing/android/native_test/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java",
1561 android_manifest = "//testing/android/native_test/java/AndroidManifest.xml"
1562 native_libs = [ unittests_binary ]
1563 if (defined(invoker.asset_location)) {
1564 asset_location = invoker.asset_location
1568 "//build/android/pylib/remote/device/dummy:remote_device_dummy_apk",
1569 "//testing/android/appurify_support:appurify_support_java",
1571 if (defined(invoker.deps)) {
1572 deps += invoker.deps
1575 "//tools/android/forwarder2",
1576 "//tools/android/md5sum",
1578 if (defined(invoker.datadeps)) {
1579 datadeps += invoker.datadeps
1584 # Generate .java files from .aidl files.
1586 # This target will store the .java files in a srcjar and should be included in
1587 # an android_library or android_apk's srcjar_deps.
1590 # sources: Paths to .aidl files to compile.
1591 # import_include: Path to directory containing .java files imported by the
1593 # interface_file: Preprocessed aidl file to import.
1596 # android_aidl("foo_aidl") {
1597 # import_include = "java/src"
1599 # "java/src/com/foo/bar/FooBarService.aidl",
1600 # "java/src/com/foo/bar/FooBarServiceCallback.aidl",
1603 template("android_aidl") {
1604 set_sources_assignment_filter([])
1605 if (defined(invoker.testonly)) {
1606 testonly = invoker.testonly
1609 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
1610 aidl_path = "${android_sdk_build_tools}/aidl"
1611 framework_aidl = "$android_sdk/framework.aidl"
1613 action(target_name) {
1614 script = "//build/android/gyp/aidl.py"
1615 sources = invoker.sources
1617 imports = [ framework_aidl ]
1618 if (defined(invoker.interface_file)) {
1619 assert(invoker.interface_file != "")
1620 imports += [ invoker.interface_file ]
1623 inputs = [ aidl_path ] + imports
1625 depfile = "${target_gen_dir}/${target_name}.d"
1630 rebased_imports = rebase_path(imports, root_build_dir)
1633 rebase_path(depfile, root_build_dir),
1635 rebase_path(aidl_path, root_build_dir),
1636 "--imports=$rebased_imports",
1638 rebase_path(srcjar_path, root_build_dir),
1640 if (defined(invoker.import_include) && invoker.import_include != "") {
1641 # TODO(cjhopman): aidl supports creating a depfile. We should be able to
1642 # switch to constructing a depfile for the overall action from that
1643 # instead of having all the .java files in the include paths as inputs.
1644 rebased_import_includes =
1645 rebase_path([ invoker.import_include ], root_build_dir)
1646 args += [ "--includes=$rebased_import_includes" ]
1648 _java_files_build_rel =
1649 exec_script("//build/android/gyp/find.py",
1650 rebase_path([ invoker.import_include ], root_build_dir),
1652 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
1653 inputs += _java_files
1655 args += rebase_path(sources, root_build_dir)
1659 # Creates a dist directory for a native executable.
1661 # Running a native executable on a device requires all the shared library
1662 # dependencies of that executable. To make it easier to install and run such an
1663 # executable, this will create a directory containing the native exe and all
1664 # it's library dependencies.
1666 # Note: It's usually better to package things as an APK than as a native
1670 # dist_dir: Directory for the exe and libraries. Everything in this directory
1671 # will be deleted before copying in the exe and libraries.
1672 # binary: Path to (stripped) executable.
1675 # create_native_executable_dist("foo_dist") {
1676 # dist_dir = "$root_build_dir/foo_dist"
1677 # binary = "$root_build_dir/exe.stripped/foo"
1679 template("create_native_executable_dist") {
1680 set_sources_assignment_filter([])
1681 if (defined(invoker.testonly)) {
1682 testonly = invoker.testonly
1685 dist_dir = invoker.dist_dir
1686 binary = invoker.binary
1688 template_name = target_name
1691 "${target_gen_dir}/${template_name}_library_dependencies.list"
1695 #'<(DEPTH)/build/android/setup.gyp:copy_system_libraries',
1698 stripped_libraries_dir = "$root_build_dir/lib.stripped"
1699 final_deps += [ ":${template_name}__find_library_dependencies" ]
1700 action("${template_name}__find_library_dependencies") {
1701 script = "//build/android/gyp/write_ordered_libraries.py"
1702 depfile = "$target_gen_dir/$target_name.d"
1711 rebased_binaries = rebase_path([ binary ], root_build_dir)
1714 rebase_path(depfile, root_build_dir),
1715 "--input-libraries=$rebased_binaries",
1717 rebase_path(stripped_libraries_dir, root_build_dir),
1719 rebase_path(libraries_list, root_build_dir),
1721 rebase_path(android_readelf, root_build_dir),
1725 final_deps += [ ":${template_name}__copy_libraries_and_exe" ]
1726 copy_ex("${template_name}__copy_libraries_and_exe") {
1733 rebased_binaries_list = rebase_path([ binary ], root_build_dir)
1734 rebased_libraries_list = rebase_path(libraries_list, root_build_dir)
1736 "--files=$rebased_binaries_list",
1737 "--files=@FileArg($rebased_libraries_list:libraries)",
1741 group(target_name) {
1746 # Compile a protocol buffer to java.
1748 # This generates java files from protocol buffers and creates an Android library
1749 # containing the classes.
1752 # sources: Paths to .proto files to compile.
1753 # proto_path: Root directory of .proto files.
1756 # proto_java_library("foo_proto_java") {
1757 # proto_path = [ "src/foo" ]
1758 # sources = [ "$proto_path/foo.proto" ]
1760 template("proto_java_library") {
1761 set_sources_assignment_filter([])
1762 _protoc_dep = "//third_party/android_protobuf:android_protoc($host_toolchain)"
1763 _protoc_out_dir = get_label_info(_protoc_dep, "root_out_dir")
1764 _protoc_bin = "$_protoc_out_dir/android_protoc"
1765 _proto_path = invoker.proto_path
1767 _template_name = target_name
1769 action("${_template_name}__protoc_java") {
1770 srcjar_path = "$target_gen_dir/$target_name.srcjar"
1771 script = "//build/protoc_java.py"
1775 sources = invoker.sources
1776 depfile = "$target_gen_dir/$target_name.d"
1783 rebase_path(depfile, root_build_dir),
1785 rebase_path(_protoc_bin, root_build_dir),
1787 rebase_path(_proto_path, root_build_dir),
1789 rebase_path(srcjar_path, root_build_dir),
1790 ] + rebase_path(sources, root_build_dir)
1793 android_library(target_name) {
1795 srcjar_deps = [ ":${_template_name}__protoc_java" ]
1797 "//third_party/android_protobuf:protobuf_nano_javalib",
1802 # TODO(GYP): implement this.
1803 template("uiautomator_test") {
1804 set_sources_assignment_filter([])
1805 if (defined(invoker.testonly)) {
1806 testonly = invoker.testonly
1808 assert(target_name != "")
1809 assert(invoker.deps != [] || true)
1810 group(target_name) {