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
53 jni_generator_include,
57 "${jni_output_dir}/{{source_name_part}}_jni.h",
62 rebase_path(depfile, root_build_dir),
63 "--input_file={{source}}",
64 "--optimize_generation=1",
67 rebase_path(jni_output_dir, root_build_dir),
69 rebase_path(jni_generator_include, "//"),
70 "--native_exports_optional",
72 if (defined(invoker.jni_generator_jarjar_file)) {
75 rebase_path(jni_generator_jarjar_file, root_build_dir),
80 config("jni_includes_${target_name}") {
81 # TODO(cjhopman): #includes should probably all be relative to
82 # base_output_dir. Remove that from this config once the includes are
92 ":$foreach_target_name",
94 public_configs = [ ":jni_includes_${target_name}" ]
96 if (defined(invoker.deps)) {
99 if (defined(invoker.public_deps)) {
100 public_deps = invoker.public_deps
103 if (defined(invoker.visibility)) {
104 visibility = invoker.visibility
109 # Declare a jni target for a prebuilt jar
111 # This target generates the native jni bindings for a set of classes in a .jar.
113 # See base/android/jni_generator/jni_generator.py for more info about the
114 # format of generating JNI bindings.
117 # classes: list of .class files in the jar to generate jni for. These should
118 # include the full path to the .class file.
119 # jni_package: subdirectory path for generated bindings
120 # jar_file: the path to the .jar. If not provided, will default to the sdk's
123 # deps, public_deps: As normal
126 # generate_jar_jni("foo_jni") {
128 # "android/view/Foo.class",
130 # jni_package = "foo"
132 template("generate_jar_jni") {
133 set_sources_assignment_filter([])
134 if (defined(invoker.testonly)) {
135 testonly = invoker.testonly
138 assert(defined(invoker.classes))
139 assert(defined(invoker.jni_package))
141 if (defined(invoker.jar_file)) {
142 jar_file = invoker.jar_file
144 jar_file = android_sdk_jar
147 jni_package = invoker.jni_package
148 base_output_dir = "${root_gen_dir}/${target_name}/${jni_package}"
149 jni_output_dir = "${base_output_dir}/jni"
151 jni_generator_include = "//base/android/jni_generator/jni_generator_helper.h"
153 # TODO(cjhopman): make jni_generator.py support generating jni for multiple
154 # .class files from a .jar.
156 foreach(class, invoker.classes) {
158 _classname_list = process_file_template([ class ], "{{source_name_part}}")
159 classname = _classname_list[0]
160 jni_target_name = "${target_name}__jni_${classname}"
161 jni_actions += [ ":$jni_target_name" ]
162 action(jni_target_name) {
163 # The sources aren't compiled so don't check their dependencies.
164 check_includes = false
165 depfile = "$target_gen_dir/$target_name.d"
166 script = "//base/android/jni_generator/jni_generator.py"
169 jni_generator_include,
173 "${jni_output_dir}/${classname}_jni.h",
178 rebase_path(depfile, root_build_dir),
180 rebase_path(jar_file, root_build_dir),
183 "--optimize_generation=1",
186 rebase_path(jni_output_dir, root_build_dir),
188 rebase_path(jni_generator_include, root_build_dir),
189 "--native_exports_optional",
194 config("jni_includes_${target_name}") {
195 include_dirs = [ base_output_dir ]
200 if (defined(invoker.deps)) {
203 if (defined(invoker.public_deps)) {
204 public_deps = invoker.public_deps
206 public_configs = [ ":jni_includes_${target_name}" ]
210 # Declare a target for c-preprocessor-generated java files
212 # NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum
215 # This target generates java files using the host C pre-processor. Each file in
216 # sources will be compiled using the C pre-processor. If include_path is
217 # specified, it will be passed (with --I) to the pre-processor.
219 # This target will create a single .srcjar. Adding this target to an
220 # android_library target's srcjar_deps will make the generated java files be
221 # included in that library's final outputs.
224 # sources: list of files to be processed by the C pre-processor. For each
225 # file in sources, there will be one .java file in the final .srcjar. For a
226 # file named FooBar.template, a java file will be created with name
228 # inputs: additional compile-time dependencies. Any files
229 # `#include`-ed in the templates should be listed here.
230 # package_name: this will be the subdirectory for each .java file in the
234 # java_cpp_template("foo_generated_enum") {
236 # "android/java/templates/Foo.template",
239 # "android/java/templates/native_foo_header.h",
242 # package_name = "org/chromium/base/library_loader"
243 # include_path = "android/java/templates"
245 template("java_cpp_template") {
246 set_sources_assignment_filter([])
247 if (defined(invoker.testonly)) {
248 testonly = invoker.testonly
251 assert(defined(invoker.sources))
252 package_name = invoker.package_name + ""
254 if (defined(invoker.include_path)) {
255 include_path = invoker.include_path + ""
260 action_foreach("${target_name}__apply_gcc") {
261 script = "//build/android/gyp/gcc_preprocess.py"
262 if (defined(invoker.inputs)) {
263 inputs = invoker.inputs + []
265 depfile = "${target_gen_dir}/${target_name}_{{source_name_part}}.d"
267 sources = invoker.sources
270 "${target_gen_dir}/${target_name}/java_cpp_template/${package_name}"
271 gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java"
275 gcc_template_output_pattern,
280 rebase_path(depfile, root_build_dir),
282 rebase_path(include_path, root_build_dir),
284 rebase_path(gen_dir, root_build_dir) + "/{{source_name_part}}.java",
285 "--template={{source}}",
288 if (defined(invoker.defines)) {
289 foreach(def, invoker.defines) {
298 apply_gcc_outputs = get_target_outputs(":${target_name}__apply_gcc")
299 base_gen_dir = get_label_info(":${target_name}__apply_gcc", "target_gen_dir")
301 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
302 zip("${target_name}__zip_srcjar") {
303 inputs = apply_gcc_outputs
305 base_dir = base_gen_dir
310 ":${target_name}__zip_srcjar",
315 # Declare a target for generating Java classes from C++ enums.
317 # This target generates Java files from C++ enums using a script.
319 # This target will create a single .srcjar. Adding this target to an
320 # android_library target's srcjar_deps will make the generated java files be
321 # included in that library's final outputs.
324 # sources: list of files to be processed by the script. For each annotated
325 # enum contained in the sources files the script will generate a .java
326 # file with the same name as the name of the enum.
328 # outputs: list of outputs, relative to the output_dir. These paths are
329 # verified at build time by the script. To get the list programatically run:
330 # python build/android/gyp/java_cpp_enum.py \
331 # --print_output_only . path/to/header/file.h
334 # java_cpp_enum("foo_generated_enum") {
336 # "src/native_foo_header.h",
339 # "org/chromium/FooEnum.java",
342 template("java_cpp_enum") {
343 set_sources_assignment_filter([])
344 if (defined(invoker.testonly)) {
345 testonly = invoker.testonly
348 assert(defined(invoker.sources))
349 assert(defined(invoker.outputs))
351 action("${target_name}__generate_enum") {
352 # The sources aren't compiled so don't check their dependencies.
353 check_includes = false
355 sources = invoker.sources
356 script = "//build/android/gyp/java_cpp_enum.py"
357 gen_dir = "${target_gen_dir}/${target_name}/enums"
359 get_path_info(rebase_path(invoker.outputs, ".", gen_dir), "abspath")
362 foreach(output, rebase_path(outputs, root_build_dir)) {
368 args += [ rebase_path(gen_dir, root_build_dir) ]
369 args += rebase_path(invoker.sources, root_build_dir)
372 generate_enum_outputs = get_target_outputs(":${target_name}__generate_enum")
374 get_label_info(":${target_name}__generate_enum", "target_gen_dir")
376 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
377 zip("${target_name}__zip_srcjar") {
378 inputs = generate_enum_outputs
380 base_dir = base_gen_dir
385 ":${target_name}__zip_srcjar",
390 # Declare a target for processing a Jinja template.
393 # input: The template file to be processed.
394 # output: Where to save the result.
395 # variables: (Optional) A list of variables to make available to the template
396 # processing environment, e.g. ["name=foo", "color=red"].
399 # jinja_template("chrome_shell_manifest") {
400 # input = "shell/java/AndroidManifest.xml"
401 # output = "$target_gen_dir/AndroidManifest.xml"
403 template("jinja_template") {
404 set_sources_assignment_filter([])
405 if (defined(invoker.testonly)) {
406 testonly = invoker.testonly
409 assert(defined(invoker.input))
410 assert(defined(invoker.output))
412 action(target_name) {
416 script = "//build/android/gyp/jinja_template.py"
417 depfile = "$target_gen_dir/$target_name.d"
426 rebase_path(invoker.input, root_build_dir),
428 rebase_path(invoker.output, root_build_dir),
430 rebase_path(depfile, root_build_dir),
432 if (defined(invoker.variables)) {
433 variables = invoker.variables
434 args += [ "--variables=${variables}" ]
439 # Declare a target for processing Android resources as Jinja templates.
441 # This takes an Android resource directory where each resource is a Jinja
442 # template, processes each template, then packages the results in a zip file
443 # which can be consumed by an android resources, library, or apk target.
445 # If this target is included in the deps of an android resources/library/apk,
446 # the resources will be included with that target.
449 # resources: The list of resources files to process.
450 # res_dir: The resource directory containing the resources.
451 # variables: (Optional) A list of variables to make available to the template
452 # processing environment, e.g. ["name=foo", "color=red"].
455 # jinja_template_resources("chrome_shell_template_resources") {
456 # res_dir = "shell/res_template"
457 # resources = ["shell/res_template/xml/syncable.xml"]
458 # variables = ["color=red"]
460 template("jinja_template_resources") {
461 set_sources_assignment_filter([])
462 if (defined(invoker.testonly)) {
463 testonly = invoker.testonly
466 assert(defined(invoker.resources))
467 assert(defined(invoker.res_dir))
469 _base_path = "$target_gen_dir/$target_name"
470 _resources_zip = _base_path + ".resources.zip"
471 _build_config = _base_path + ".build_config"
473 write_build_config("${target_name}__build_config") {
474 build_config = _build_config
475 resources_zip = _resources_zip
476 type = "android_resources"
479 action("${target_name}__template") {
480 sources = invoker.resources
481 script = "//build/android/gyp/jinja_template.py"
482 depfile = "$target_gen_dir/$target_name.d"
489 rebased_resources = rebase_path(invoker.resources, root_build_dir)
491 "--inputs=${rebased_resources}",
493 rebase_path(invoker.res_dir, root_build_dir),
495 rebase_path(_resources_zip, root_build_dir),
497 rebase_path(depfile, root_build_dir),
499 if (defined(invoker.variables)) {
500 variables = invoker.variables
501 args += [ "--variables=${variables}" ]
507 ":${target_name}__build_config",
508 ":${target_name}__template",
513 # Declare an Android resources target
515 # This creates a resources zip file that will be used when building an Android
516 # library or apk and included into a final apk.
518 # To include these resources in a library/apk, this target should be listed in
519 # the library's deps. A library/apk will also include any resources used by its
523 # deps: Specifies the dependencies of this target. Any Android resources
524 # listed in deps will be included by libraries/apks that depend on this
526 # resource_dirs: List of directories containing resources for this target.
527 # android_manifest: AndroidManifest.xml for this target. Defaults to
528 # //build/android/AndroidManifest.xml.
529 # custom_package: java package for generated .java files.
530 # v14_verify_only: If true, don't generate v14/v17 resources and just verify
531 # that the resources are v14-compliant (see
532 # build/android/gyp/generate_v14_compatible_resources.py). Defaults to
534 # shared_resources: If true make a resource package that can be loaded by a
535 # different application at runtime to access the package's resources.
538 # android_resources("foo_resources") {
539 # deps = [":foo_strings_grd"]
540 # resource_dirs = ["res"]
541 # custom_package = "org.chromium.foo"
543 template("android_resources") {
544 set_sources_assignment_filter([])
545 if (defined(invoker.testonly)) {
546 testonly = invoker.testonly
549 assert(defined(invoker.resource_dirs))
550 assert(defined(invoker.android_manifest) || defined(invoker.custom_package))
552 base_path = "$target_gen_dir/$target_name"
553 zip_path = base_path + ".resources.zip"
554 srcjar_path = base_path + ".srcjar"
555 build_config = base_path + ".build_config"
557 write_build_config("${target_name}__build_config") {
558 type = "android_resources"
559 resources_zip = zip_path
561 if (defined(invoker.deps)) {
564 if (defined(invoker.android_manifest)) {
565 android_manifest = invoker.android_manifest
567 if (defined(invoker.custom_package)) {
568 custom_package = invoker.custom_package
572 android_manifest = "//build/android/AndroidManifest.xml"
573 if (defined(invoker.android_manifest)) {
574 android_manifest = invoker.android_manifest
577 process_resources("${target_name}__process_resources") {
578 resource_dirs = invoker.resource_dirs
579 if (defined(invoker.custom_package)) {
580 custom_package = invoker.custom_package
583 if (defined(invoker.v14_verify_only)) {
584 v14_verify_only = invoker.v14_verify_only
587 if (defined(invoker.shared_resources)) {
588 shared_resources = invoker.shared_resources
594 ":${target_name}__build_config",
595 ":${target_name}__process_resources",
600 # Declare a target that generates localized strings.xml from a .grd file.
602 # If this target is included in the deps of an android resources/library/apk,
603 # the strings.xml will be included with that target.
606 # deps: Specifies the dependencies of this target.
607 # grd_file: Path to the .grd file to generate strings.xml from.
608 # outputs: Expected grit outputs (see grit rule).
611 # java_strings_grd("foo_strings_grd") {
612 # grd_file = "foo_strings.grd"
614 template("java_strings_grd") {
615 set_sources_assignment_filter([])
616 if (defined(invoker.testonly)) {
617 testonly = invoker.testonly
620 base_path = "$target_gen_dir/$target_name"
621 resources_zip = base_path + ".resources.zip"
622 build_config = base_path + ".build_config"
624 write_build_config("${target_name}__build_config") {
625 type = "android_resources"
626 if (defined(invoker.deps)) {
631 # Put grit files into this subdirectory of target_gen_dir.
632 extra_output_path = target_name + "_grit_output"
634 grit_target_name = "${target_name}__grit"
635 grit_output_dir = "$target_gen_dir/$extra_output_path"
636 grit(grit_target_name) {
639 "ANDROID_JAVA_TAGGED_ONLY=false",
641 output_dir = grit_output_dir
643 source = invoker.grd_file
644 outputs = invoker.outputs
647 # This needs to get outputs from grit's internal target, not the final
649 generate_strings_outputs = get_target_outputs(":${grit_target_name}_grit")
651 zip("${target_name}__zip") {
652 base_dir = grit_output_dir
653 inputs = generate_strings_outputs
654 output = resources_zip
659 ":${target_name}__build_config",
660 ":${target_name}__zip",
665 # Declare a target that packages strings.xml generated from a grd file.
667 # If this target is included in the deps of an android resources/library/apk,
668 # the strings.xml will be included with that target.
671 # grit_output_dir: directory containing grit-generated files.
672 # generated_files: list of android resource files to package.
675 # java_strings_grd_prebuilt("foo_strings_grd") {
676 # grit_output_dir = "$root_gen_dir/foo/grit"
677 # generated_files = [
678 # "values/strings.xml"
681 template("java_strings_grd_prebuilt") {
682 set_sources_assignment_filter([])
683 if (defined(invoker.testonly)) {
684 testonly = invoker.testonly
687 base_path = "$target_gen_dir/$target_name"
688 resources_zip = base_path + ".resources.zip"
689 build_config = base_path + ".build_config"
691 write_build_config("${target_name}__build_config") {
692 type = "android_resources"
693 if (defined(invoker.deps)) {
698 zip("${target_name}__zip") {
699 base_dir = invoker.grit_output_dir
700 inputs = rebase_path(invoker.generated_files, ".", base_dir)
701 output = resources_zip
706 ":${target_name}__build_config",
707 ":${target_name}__zip",
712 # Declare a Java executable target
714 # This target creates an executable from java code and libraries. The executable
715 # will be in the output folder's /bin/ directory.
718 # deps: Specifies the dependencies of this target. Java targets in this list
719 # will be included in the executable (and the javac classpath).
721 # java_files: List of .java files included in this library.
722 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
723 # will be added to java_files and be included in this library.
724 # srcjars: List of srcjars to be included in this library, together with the
725 # ones obtained from srcjar_deps.
727 # bypass_platform_checks: Disables checks about cross-platform (Java/Android)
728 # dependencies for this target. This will allow depending on an
729 # android_library target, for example.
731 # chromium_code: If true, extra analysis warning/errors will be enabled.
736 # java_library("foo") {
737 # java_files = [ "org/chromium/foo/FooMain.java" ]
738 # deps = [ ":bar_java" ]
739 # main_class = "org.chromium.foo.FooMain"
741 template("java_binary") {
742 set_sources_assignment_filter([])
744 # TODO(cjhopman): This should not act like a java_library for dependents (i.e.
745 # dependents shouldn't get the jar in their classpath, etc.).
746 java_library_impl(target_name) {
747 if (defined(invoker.DEPRECATED_java_in_dir)) {
748 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
750 if (defined(invoker.chromium_code)) {
751 chromium_code = invoker.chromium_code
753 if (defined(invoker.datadeps)) {
754 deps = invoker.datadeps
756 if (defined(invoker.deps)) {
759 if (defined(invoker.java_files)) {
760 java_files = invoker.java_files
762 if (defined(invoker.srcjar_deps)) {
763 srcjar_deps = invoker.srcjar_deps
765 if (defined(invoker.srcjars)) {
766 srcjars = invoker.srcjars
768 if (defined(invoker.bypass_platform_checks)) {
769 bypass_platform_checks = invoker.bypass_platform_checks
771 if (defined(invoker.testonly)) {
772 testonly = invoker.testonly
775 main_class = invoker.main_class
779 # Declare a Junit executable target
781 # This target creates an executable from java code for running as a junit test
782 # suite. The executable will be in the output folder's /bin/ directory.
785 # deps: Specifies the dependencies of this target. Java targets in this list
786 # will be included in the executable (and the javac classpath).
788 # java_files: List of .java files included in this library.
789 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
790 # will be added to java_files and be included in this library.
791 # srcjars: List of srcjars to be included in this library, together with the
792 # ones obtained from srcjar_deps.
794 # chromium_code: If true, extra analysis warning/errors will be enabled.
797 # junit_binary("foo") {
798 # java_files = [ "org/chromium/foo/FooTest.java" ]
799 # deps = [ ":bar_java" ]
801 template("junit_binary") {
802 set_sources_assignment_filter([])
804 java_binary(target_name) {
805 bypass_platform_checks = true
806 main_class = "org.chromium.testing.local.JunitTestMain"
809 if (defined(invoker.DEPRECATED_java_in_dir)) {
810 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
812 if (defined(invoker.chromium_code)) {
813 chromium_code = invoker.chromium_code
816 "//testing/android/junit:junit_test_support",
817 "//third_party/junit",
818 "//third_party/mockito:mockito_java",
819 "//third_party/robolectric:robolectric_java",
820 "//third_party/robolectric:android-all-4.3_r2-robolectric-0",
822 if (defined(invoker.deps)) {
825 if (defined(invoker.java_files)) {
826 java_files = invoker.java_files
828 if (defined(invoker.srcjar_deps)) {
829 srcjar_deps = invoker.srcjar_deps
831 if (defined(invoker.srcjars)) {
832 srcjars = invoker.srcjars
837 # Declare an java library target
840 # deps: Specifies the dependencies of this target. Java targets in this list
841 # will be added to the javac classpath.
843 # java_files: List of .java files included in this library.
844 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
845 # will be added to java_files and be included in this library.
846 # srcjars: List of srcjars to be included in this library, together with the
847 # ones obtained from srcjar_deps.
848 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in
849 # this directory will be included in the library. This is only supported to
850 # ease the gyp->gn conversion and will be removed in the future.
852 # chromium_code: If true, extra analysis warning/errors will be enabled.
853 # jar_excluded_patterns: List of patterns of .class files to exclude from the
856 # proguard_preprocess: If true, proguard preprocessing will be run. This can
857 # be used to remove unwanted parts of the library.
858 # proguard_config: Path to the proguard config for preprocessing.
860 # supports_android: If true, Android targets (android_library, android_apk)
861 # may depend on this target. Note: if true, this target must only use the
862 # subset of Java available on Android.
863 # bypass_platform_checks: Disables checks about cross-platform (Java/Android)
864 # dependencies for this target. This will allow depending on an
865 # android_library target, for example.
870 # java_library("foo_java") {
872 # "org/chromium/foo/Foo.java",
873 # "org/chromium/foo/FooInterface.java",
874 # "org/chromium/foo/FooService.java",
880 # ":foo_generated_enum"
882 # jar_excluded_patterns = [
883 # "*/FooService.class", "*/FooService##*.class"
886 template("java_library") {
887 set_sources_assignment_filter([])
888 java_library_impl(target_name) {
889 if (defined(invoker.DEPRECATED_java_in_dir)) {
890 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
892 if (defined(invoker.chromium_code)) {
893 chromium_code = invoker.chromium_code
895 if (defined(invoker.datadeps)) {
896 deps = invoker.datadeps
898 if (defined(invoker.deps)) {
901 if (defined(invoker.jar_excluded_patterns)) {
902 jar_excluded_patterns = invoker.jar_excluded_patterns
904 if (defined(invoker.java_files)) {
905 java_files = invoker.java_files
907 if (defined(invoker.proguard_config)) {
908 proguard_config = invoker.proguard_config
910 if (defined(invoker.proguard_preprocess)) {
911 proguard_preprocess = invoker.proguard_preprocess
913 if (defined(invoker.srcjar_deps)) {
914 srcjar_deps = invoker.srcjar_deps
916 if (defined(invoker.srcjars)) {
917 srcjars = invoker.srcjars
919 if (defined(invoker.bypass_platform_checks)) {
920 bypass_platform_checks = invoker.bypass_platform_checks
922 if (defined(invoker.testonly)) {
923 testonly = invoker.testonly
925 if (defined(invoker.jar_path)) {
926 jar_path = invoker.jar_path
929 if (defined(invoker.supports_android) && invoker.supports_android) {
930 supports_android = true
935 # Declare an java library target for a prebuilt jar
938 # deps: Specifies the dependencies of this target. Java targets in this list
939 # will be added to the javac classpath.
940 # jar_path: Path to the prebuilt jar.
941 # proguard_preprocess: If true, proguard preprocessing will be run. This can
942 # be used to remove unwanted parts of the library.
943 # proguard_config: Path to the proguard config for preprocessing.
946 # java_prebuilt("foo_java") {
947 # jar_path = "foo.jar"
953 template("java_prebuilt") {
954 set_sources_assignment_filter([])
955 java_prebuilt_impl(target_name) {
956 jar_path = invoker.jar_path
957 if (defined(invoker.testonly)) {
958 testonly = invoker.testonly
960 if (defined(invoker.deps)) {
963 if (defined(invoker.proguard_config)) {
964 proguard_config = invoker.proguard_config
966 if (defined(invoker.proguard_preprocess)) {
967 proguard_preprocess = invoker.proguard_preprocess
972 # Declare an Android library target
974 # This target creates an Android library containing java code and Android
978 # deps: Specifies the dependencies of this target. Java targets in this list
979 # will be added to the javac classpath. Android resources in dependencies
980 # will be used when building this library.
982 # java_files: List of .java files included in this library.
983 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
984 # will be added to java_files and be included in this library.
985 # srcjars: List of srcjars to be included in this library, together with the
986 # ones obtained from srcjar_deps.
987 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in
988 # this directory will be included in the library. This is only supported to
989 # ease the gyp->gn conversion and will be removed in the future.
991 # chromium_code: If true, extra analysis warning/errors will be enabled.
992 # jar_excluded_patterns: List of patterns of .class files to exclude from the
995 # proguard_preprocess: If true, proguard preprocessing will be run. This can
996 # be used to remove unwanted parts of the library.
997 # proguard_config: Path to the proguard config for preprocessing.
999 # dex_path: If set, the resulting .dex.jar file will be placed under this
1004 # android_library("foo_java") {
1006 # "android/org/chromium/foo/Foo.java",
1007 # "android/org/chromium/foo/FooInterface.java",
1008 # "android/org/chromium/foo/FooService.java",
1014 # ":foo_generated_enum"
1016 # jar_excluded_patterns = [
1017 # "*/FooService.class", "*/FooService##*.class"
1020 template("android_library") {
1021 set_sources_assignment_filter([])
1022 assert(!defined(invoker.jar_path),
1023 "android_library does not support a custom jar path")
1024 java_library_impl(target_name) {
1025 if (defined(invoker.DEPRECATED_java_in_dir)) {
1026 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
1028 if (defined(invoker.chromium_code)) {
1029 chromium_code = invoker.chromium_code
1031 if (defined(invoker.datadeps)) {
1032 deps = invoker.datadeps
1034 if (defined(invoker.deps)) {
1037 if (defined(invoker.jar_excluded_patterns)) {
1038 jar_excluded_patterns = invoker.jar_excluded_patterns
1040 if (defined(invoker.java_files)) {
1041 java_files = invoker.java_files
1043 if (defined(invoker.proguard_config)) {
1044 proguard_config = invoker.proguard_config
1046 if (defined(invoker.proguard_preprocess)) {
1047 proguard_preprocess = invoker.proguard_preprocess
1049 if (defined(invoker.srcjar_deps)) {
1050 srcjar_deps = invoker.srcjar_deps
1052 if (defined(invoker.srcjars)) {
1053 srcjars = invoker.srcjars
1055 if (defined(invoker.testonly)) {
1056 testonly = invoker.testonly
1058 if (defined(invoker.visibility)) {
1059 visibility = invoker.visibility
1061 if (defined(invoker.dex_path)) {
1062 dex_path = invoker.dex_path
1064 if (defined(invoker.manifest_entries)) {
1065 manifest_entries = invoker.manifest_entries
1068 supports_android = true
1069 requires_android = true
1071 if (!defined(jar_excluded_patterns)) {
1072 jar_excluded_patterns = []
1074 jar_excluded_patterns += [
1078 "*/Manifest##*.class",
1083 # Declare a target that packages a set of Java dependencies into a standalone
1087 # deps: specifies the dependencies of this target. Android libraries in deps
1088 # will be packaged into the resulting .dex.jar file.
1089 # dex_path: location at which the output file will be put
1090 template("android_standalone_library") {
1091 set_sources_assignment_filter([])
1092 deps_dex(target_name) {
1094 dex_path = invoker.dex_path
1095 if (defined(invoker.excluded_jars)) {
1096 excluded_jars = invoker.excluded_jars
1101 # Declare an Android library target for a prebuilt jar
1103 # This target creates an Android library containing java code and Android
1107 # deps: Specifies the dependencies of this target. Java targets in this list
1108 # will be added to the javac classpath. Android resources in dependencies
1109 # will be used when building this library.
1110 # jar_path: Path to the prebuilt jar.
1111 # proguard_preprocess: If true, proguard preprocessing will be run. This can
1112 # be used to remove unwanted parts of the library.
1113 # proguard_config: Path to the proguard config for preprocessing.
1116 # android_java_prebuilt("foo_java") {
1117 # jar_path = "foo.jar"
1123 template("android_java_prebuilt") {
1124 set_sources_assignment_filter([])
1125 java_prebuilt_impl(target_name) {
1126 jar_path = invoker.jar_path
1127 supports_android = true
1128 requires_android = true
1129 if (defined(invoker.testonly)) {
1130 testonly = invoker.testonly
1132 if (defined(invoker.deps)) {
1135 if (defined(invoker.proguard_config)) {
1136 proguard_config = invoker.proguard_config
1138 if (defined(invoker.proguard_preprocess)) {
1139 proguard_preprocess = invoker.proguard_preprocess
1144 # Declare an Android apk target
1146 # This target creates an Android APK containing java code, resources, assets,
1147 # and (possibly) native libraries.
1150 # android_manifest: Path to AndroidManifest.xml.
1151 # datadeps: List of dependencies needed at runtime. These will be built but
1152 # won't change the generated .apk in any way (in fact they may be built
1153 # after the .apk is).
1154 # deps: List of dependencies. All Android java resources and libraries in the
1155 # "transitive closure" of these dependencies will be included in the apk.
1156 # Note: this "transitive closure" actually only includes such targets if
1157 # they are depended on through android_library or android_resources targets
1158 # (and so not through builtin targets like 'action', 'group', etc).
1159 # java_files: List of .java files to include in the apk.
1160 # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
1161 # will be added to java_files and be included in this apk.
1162 # apk_name: Name for final apk.
1163 # final_apk_path: Path to final built apk. Default is
1164 # $root_out_dir/apks/$apk_name.apk. Setting this will override apk_name.
1165 # native_libs: List paths of native libraries to include in this apk. If these
1166 # libraries depend on other shared_library targets, those dependencies will
1167 # also be included in the apk.
1168 # testonly: Marks this target as "test-only".
1170 # DEPRECATED_java_in_dir: Directory containing java files. All .java files in
1171 # this directory will be included in the library. This is only supported to
1172 # ease the gyp->gn conversion and will be removed in the future.
1175 # android_apk("foo_apk") {
1176 # android_manifest = "AndroidManifest.xml"
1178 # "android/org/chromium/foo/FooApplication.java",
1179 # "android/org/chromium/foo/FooActivity.java",
1182 # ":foo_support_java"
1186 # ":foo_generated_enum"
1192 template("android_apk") {
1193 set_sources_assignment_filter([])
1194 if (defined(invoker.testonly)) {
1195 testonly = invoker.testonly
1198 assert(defined(invoker.final_apk_path) || defined(invoker.apk_name))
1199 gen_dir = "$target_gen_dir/$target_name"
1200 base_path = "$gen_dir/$target_name"
1201 _build_config = "$base_path.build_config"
1202 resources_zip_path = "$base_path.resources.zip"
1203 all_resources_zip_path = "$base_path.resources.all.zip"
1204 jar_path = "$base_path.jar"
1205 final_dex_path = "$gen_dir/classes.dex"
1206 _template_name = target_name
1207 _final_apk_path = ""
1208 if (defined(invoker.final_apk_path)) {
1209 _final_apk_path = invoker.final_apk_path
1210 } else if (defined(invoker.apk_name)) {
1211 _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk"
1213 _dist_jar_path_list =
1214 process_file_template(
1215 [ _final_apk_path ],
1216 "$root_build_dir/test.lib.java/{{source_name_part}}.jar")
1217 _dist_jar_path = _dist_jar_path_list[0]
1221 _keystore_path = android_default_keystore_path
1222 _keystore_name = android_default_keystore_name
1223 _keystore_password = android_default_keystore_password
1225 if (defined(invoker.keystore_path)) {
1226 _keystore_path = invoker.keystore_path
1227 _keystore_name = invoker.keystore_name
1228 _keystore_password = invoker.keystore_password
1232 if (defined(invoker.srcjar_deps)) {
1233 _srcjar_deps += invoker.srcjar_deps
1236 _load_library_from_apk = false
1238 if (defined(invoker.native_libs)) {
1239 _use_chromium_linker = false
1240 if (defined(invoker.use_chromium_linker)) {
1241 _use_chromium_linker =
1242 invoker.use_chromium_linker && chromium_linker_supported
1245 if (defined(invoker.load_library_from_apk) &&
1246 invoker.load_library_from_apk) {
1247 _load_library_from_apk = true
1248 assert(_use_chromium_linker,
1249 "Loading library from the apk requires use" +
1250 " of the Chromium linker.")
1253 _enable_relocation_packing = false
1254 if (defined(invoker.enable_relocation_packing) &&
1255 invoker.enable_relocation_packing) {
1256 _enable_relocation_packing = relocation_packing_supported
1257 assert(_use_chromium_linker,
1258 "Relocation packing requires use of the" + " Chromium linker.")
1261 _native_libs = process_file_template(
1262 invoker.native_libs,
1263 "$root_build_dir/lib.stripped/{{source_file_part}}")
1265 _native_libs_dir = base_path + "/libs"
1267 if (_use_chromium_linker) {
1269 [ "$root_build_dir/lib.stripped/libchromium_android_linker.so" ]
1272 _enable_relocation_packing = false
1273 if (_use_chromium_linker && defined(invoker.enable_relocation_packing) &&
1274 invoker.enable_relocation_packing) {
1275 _enable_relocation_packing = true
1278 _native_lib_version_name = ""
1279 if (defined(invoker.native_lib_version_name)) {
1280 _native_lib_version_name = invoker.native_lib_version_name
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
1292 if (defined(invoker.deps)) {
1296 native_libs = _native_libs
1301 final_deps += [ ":${_template_name}__process_resources" ]
1302 process_resources("${_template_name}__process_resources") {
1303 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
1304 android_manifest = invoker.android_manifest
1305 resource_dirs = [ "//build/android/ant/empty/res" ]
1306 zip_path = resources_zip_path
1307 generate_constant_ids = true
1308 build_config = _build_config
1310 _srcjar_deps += [ ":${_template_name}__process_resources" ]
1312 if (_native_libs != []) {
1313 _enable_chromium_linker_tests = false
1314 if (defined(invoker.enable_chromium_linker_tests)) {
1315 _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
1318 java_cpp_template("${_template_name}__native_libraries_java") {
1319 package_name = "org/chromium/base/library_loader"
1321 "//base/android/java/templates/NativeLibraries.template",
1328 "NATIVE_LIBRARIES_LIST=" +
1329 "@FileArg($_rebased_build_config:native:java_libraries_list)",
1330 "NATIVE_LIBRARIES_VERSION_NUMBER=\"$_native_lib_version_name\"",
1332 if (_use_chromium_linker) {
1333 defines += [ "ENABLE_CHROMIUM_LINKER" ]
1335 if (_load_library_from_apk) {
1336 defines += [ "ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE" ]
1338 if (_enable_chromium_linker_tests) {
1339 defines += [ "ENABLE_CHROMIUM_LINKER_TESTS" ]
1342 _srcjar_deps += [ ":${_template_name}__native_libraries_java" ]
1345 final_deps += [ ":${_template_name}__java" ]
1346 java_library_impl("${_template_name}__java") {
1347 supports_android = true
1348 requires_android = true
1349 override_build_config = _build_config
1350 android_manifest = invoker.android_manifest
1351 chromium_code = true
1352 if (defined(invoker.java_files)) {
1353 java_files = invoker.java_files
1354 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
1355 DEPRECATED_java_in_dir = invoker.DEPRECATED_java_in_dir
1359 srcjar_deps = _srcjar_deps
1360 dex_path = base_path + ".dex.jar"
1363 if (_dist_jar_path != "") {
1364 final_deps += [ ":${_template_name}__create_dist_jar" ]
1366 # TODO(cjhopman): This is only ever needed to calculate the list of tests to
1367 # run. See build/android/pylib/instrumentation/test_jar.py. We should be
1368 # able to just do that calculation at build time instead.
1369 action("${_template_name}__create_dist_jar") {
1370 script = "//build/android/gyp/create_dist_jar.py"
1371 depfile = "$target_gen_dir/$target_name.d"
1381 rebase_path(depfile, root_build_dir),
1383 rebase_path(_dist_jar_path, root_build_dir),
1384 "--inputs=@FileArg($_rebased_build_config:dist_jar:dependency_jars)",
1386 inputs += [ jar_path ]
1387 _rebased_jar_path = rebase_path([ jar_path ], root_build_dir)
1388 args += [ "--inputs=$_rebased_jar_path" ]
1392 final_deps += [ ":${_template_name}__final_dex" ]
1393 dex("${_template_name}__final_dex") {
1395 ":${_template_name}__java",
1403 output = final_dex_path
1404 dex_arg_key = "${_rebased_build_config}:final_dex:dependency_dex_files"
1405 args = [ "--inputs=@FileArg($dex_arg_key)" ]
1408 if (_native_libs != []) {
1409 action("${_template_name}__prepare_native") {
1410 script = "//build/android/gyp/pack_arm_relocations.py"
1411 packed_libraries_dir = "$_native_libs_dir/$android_app_abi"
1412 depfile = "$target_gen_dir/$target_name.d"
1416 inputs = [ _build_config ] + _native_libs
1418 skip_packing_list = [
1420 "libchromium_android_linker.so",
1423 enable_packing_arg = 0
1424 if (_enable_relocation_packing) {
1425 enable_packing_arg = 1
1426 deps += [ relocation_packer_target ]
1431 rebase_path(depfile, root_build_dir),
1432 "--enable-packing=$enable_packing_arg",
1433 "--has-relocations-with-addends=$relocations_have_addends",
1434 "--exclude-packing-list=$skip_packing_list",
1435 "--android-pack-relocations",
1436 rebase_path(relocation_packer_exe, root_build_dir),
1437 "--android-objcopy",
1438 rebase_path(android_objcopy, root_build_dir),
1439 "--stripped-libraries-dir",
1440 rebase_path(root_build_dir, root_build_dir),
1441 "--packed-libraries-dir",
1442 rebase_path(packed_libraries_dir, root_build_dir),
1443 "--libraries=@FileArg(${_rebased_build_config}:native:libraries)",
1448 rebased_gdbserver = rebase_path([ android_gdbserver ], root_build_dir)
1449 inputs += [ android_gdbserver ]
1450 args += [ "--libraries=$rebased_gdbserver" ]
1455 final_deps += [ ":${_template_name}__create" ]
1456 create_apk("${_template_name}__create") {
1457 apk_path = _final_apk_path
1458 android_manifest = invoker.android_manifest
1459 resources_zip = all_resources_zip_path
1460 dex_path = final_dex_path
1461 load_library_from_apk = _load_library_from_apk
1464 if (defined(invoker.version_code)) {
1465 version_code = invoker.version_code
1468 version_name = "Developer Build"
1469 if (defined(invoker.version_name)) {
1470 version_name = invoker.version_name
1473 keystore_name = _keystore_name
1474 keystore_path = _keystore_path
1475 keystore_password = _keystore_password
1478 if (defined(invoker.asset_location)) {
1479 asset_location = invoker.asset_location
1481 # We don't know the exact dependencies that create the assets in
1482 # |asset_location|; we depend on all caller deps until a better solution
1483 # is figured out (http://crbug.com/433330).
1484 if (defined(invoker.deps)) {
1485 deps += invoker.deps
1489 if (_native_libs != []) {
1490 native_libs_dir = _native_libs_dir
1491 deps += [ ":${_template_name}__prepare_native" ]
1495 group(target_name) {
1497 if (defined(invoker.datadeps)) {
1498 datadeps = invoker.datadeps
1503 # Declare an Android gtest apk
1505 # This target creates an Android apk for running gtest-based unittests.
1508 # deps: Specifies the dependencies of this target. These will be passed to
1509 # the underlying android_apk invocation and should include the java and
1510 # resource dependencies of the apk.
1511 # unittests_dep: This should be the label of the gtest native target. This
1512 # target must be defined previously in the same file.
1513 # unittests_binary: The basename of the library produced by the unittests_dep
1514 # target. If unspecified, it assumes the name of the unittests_dep target
1515 # (which will be correct unless that target specifies an "output_name".
1516 # TODO(brettw) make this automatic by allowing get_target_outputs to
1517 # support executables.
1518 # apk_name: The name of the produced apk. If unspecified, it uses the name
1519 # of the unittests_dep target postfixed with "_apk"
1522 # unittest_apk("foo_unittests_apk") {
1523 # deps = [ ":foo_java", ":foo_resources" ]
1524 # unittests_dep = ":foo_unittests"
1526 template("unittest_apk") {
1527 set_sources_assignment_filter([])
1530 assert(defined(invoker.unittests_dep), "Need unittests_dep for $target_name")
1532 test_suite_name = get_label_info(invoker.unittests_dep, "name")
1534 # This trivial assert is needed in case both unittests_binary and apk_name
1535 # are defined, as otherwise test_suite_name would not be used.
1536 assert(test_suite_name != "")
1538 if (defined(invoker.unittests_binary)) {
1539 unittests_binary = invoker.unittests_binary
1541 unittests_binary = "lib" + test_suite_name + ".so"
1544 if (defined(invoker.apk_name)) {
1545 apk_name = invoker.apk_name
1547 apk_name = test_suite_name
1550 android_apk(target_name) {
1551 _apk_name = apk_name
1552 final_apk_path = "$root_build_dir/${_apk_name}_apk/${_apk_name}-debug.apk"
1554 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java",
1555 "//testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java",
1557 android_manifest = "//testing/android/java/AndroidManifest.xml"
1558 native_libs = [ unittests_binary ]
1559 if (defined(invoker.asset_location)) {
1560 asset_location = invoker.asset_location
1564 "//build/android/pylib/remote/device/dummy:remote_device_dummy_apk",
1566 if (defined(invoker.deps)) {
1567 deps += invoker.deps
1570 "//tools/android/forwarder2",
1571 "//tools/android/md5sum",
1573 if (defined(invoker.datadeps)) {
1574 datadeps += invoker.datadeps
1579 # Generate .java files from .aidl files.
1581 # This target will store the .java files in a srcjar and should be included in
1582 # an android_library or android_apk's srcjar_deps.
1585 # sources: Paths to .aidl files to compile.
1586 # import_include: Path to directory containing .java files imported by the
1588 # interface_file: Preprocessed aidl file to import.
1591 # android_aidl("foo_aidl") {
1592 # import_include = "java/src"
1594 # "java/src/com/foo/bar/FooBarService.aidl",
1595 # "java/src/com/foo/bar/FooBarServiceCallback.aidl",
1598 template("android_aidl") {
1599 set_sources_assignment_filter([])
1600 if (defined(invoker.testonly)) {
1601 testonly = invoker.testonly
1604 srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
1605 aidl_path = "${android_sdk_build_tools}/aidl"
1606 framework_aidl = "$android_sdk/framework.aidl"
1608 action(target_name) {
1609 script = "//build/android/gyp/aidl.py"
1610 sources = invoker.sources
1612 imports = [ framework_aidl ]
1613 if (defined(invoker.interface_file)) {
1614 assert(invoker.interface_file != "")
1615 imports += [ invoker.interface_file ]
1618 inputs = [ aidl_path ] + imports
1620 depfile = "${target_gen_dir}/${target_name}.d"
1625 rebased_imports = rebase_path(imports, root_build_dir)
1628 rebase_path(depfile, root_build_dir),
1630 rebase_path(aidl_path, root_build_dir),
1631 "--imports=$rebased_imports",
1633 rebase_path(srcjar_path, root_build_dir),
1635 if (defined(invoker.import_include) && invoker.import_include != "") {
1636 # TODO(cjhopman): aidl supports creating a depfile. We should be able to
1637 # switch to constructing a depfile for the overall action from that
1638 # instead of having all the .java files in the include paths as inputs.
1639 rebased_import_includes =
1640 rebase_path([ invoker.import_include ], root_build_dir)
1641 args += [ "--includes=$rebased_import_includes" ]
1643 _java_files_build_rel =
1644 exec_script("//build/android/gyp/find.py",
1645 rebase_path([ invoker.import_include ], root_build_dir),
1647 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
1648 inputs += _java_files
1650 args += rebase_path(sources, root_build_dir)
1654 # Creates a dist directory for a native executable.
1656 # Running a native executable on a device requires all the shared library
1657 # dependencies of that executable. To make it easier to install and run such an
1658 # executable, this will create a directory containing the native exe and all
1659 # it's library dependencies.
1661 # Note: It's usually better to package things as an APK than as a native
1665 # dist_dir: Directory for the exe and libraries. Everything in this directory
1666 # will be deleted before copying in the exe and libraries.
1667 # binary: Path to (stripped) executable.
1670 # create_native_executable_dist("foo_dist") {
1671 # dist_dir = "$root_build_dir/foo_dist"
1672 # binary = "$root_build_dir/exe.stripped/foo"
1674 template("create_native_executable_dist") {
1675 set_sources_assignment_filter([])
1676 if (defined(invoker.testonly)) {
1677 testonly = invoker.testonly
1680 dist_dir = invoker.dist_dir
1681 binary = invoker.binary
1683 template_name = target_name
1686 "${target_gen_dir}/${template_name}_library_dependencies.list"
1690 #'<(DEPTH)/build/android/setup.gyp:copy_system_libraries',
1693 stripped_libraries_dir = "$root_build_dir/lib.stripped"
1694 final_deps += [ ":${template_name}__find_library_dependencies" ]
1695 action("${template_name}__find_library_dependencies") {
1696 script = "//build/android/gyp/write_ordered_libraries.py"
1697 depfile = "$target_gen_dir/$target_name.d"
1706 rebased_binaries = rebase_path([ binary ], root_build_dir)
1709 rebase_path(depfile, root_build_dir),
1710 "--input-libraries=$rebased_binaries",
1712 rebase_path(stripped_libraries_dir, root_build_dir),
1714 rebase_path(libraries_list, root_build_dir),
1716 rebase_path(android_readelf, root_build_dir),
1720 final_deps += [ ":${template_name}__copy_libraries_and_exe" ]
1721 copy_ex("${template_name}__copy_libraries_and_exe") {
1728 rebased_binaries_list = rebase_path([ binary ], root_build_dir)
1729 rebased_libraries_list = rebase_path(libraries_list, root_build_dir)
1731 "--files=$rebased_binaries_list",
1732 "--files=@FileArg($rebased_libraries_list:libraries)",
1736 group(target_name) {
1741 # Compile a protocol buffer to java.
1743 # This generates java files from protocol buffers and creates an Android library
1744 # containing the classes.
1747 # sources: Paths to .proto files to compile.
1748 # proto_path: Root directory of .proto files.
1751 # proto_java_library("foo_proto_java") {
1752 # proto_path = [ "src/foo" ]
1753 # sources = [ "$proto_path/foo.proto" ]
1755 template("proto_java_library") {
1756 set_sources_assignment_filter([])
1757 _protoc_dep = "//third_party/android_protobuf:android_protoc($host_toolchain)"
1758 _protoc_out_dir = get_label_info(_protoc_dep, "root_out_dir")
1759 _protoc_bin = "$_protoc_out_dir/android_protoc"
1760 _proto_path = invoker.proto_path
1762 _template_name = target_name
1764 action("${_template_name}__protoc_java") {
1765 srcjar_path = "$target_gen_dir/$target_name.srcjar"
1766 script = "//build/protoc_java.py"
1770 sources = invoker.sources
1771 depfile = "$target_gen_dir/$target_name.d"
1778 rebase_path(depfile, root_build_dir),
1780 rebase_path(_protoc_bin, root_build_dir),
1782 rebase_path(_proto_path, root_build_dir),
1784 rebase_path(srcjar_path, root_build_dir),
1785 ] + rebase_path(sources, root_build_dir)
1788 android_library(target_name) {
1790 srcjar_deps = [ ":${_template_name}__protoc_java" ]
1792 "//third_party/android_protobuf:protobuf_nano_javalib",
1797 # TODO(GYP): implement this.
1798 template("uiautomator_test") {
1799 set_sources_assignment_filter([])
1800 if (defined(invoker.testonly)) {
1801 testonly = invoker.testonly
1803 assert(target_name != "")
1804 assert(invoker.deps != [] || true)
1805 group(target_name) {