Index: build/config/android/rules.gni |
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni |
index 76f57dd73758fced358cfcbdb9ca90f6d11362fb..60d0fff1b70b0dc3ab990400757706f8b759a596 100644 |
--- a/build/config/android/rules.gni |
+++ b/build/config/android/rules.gni |
@@ -397,6 +397,63 @@ template("java_cpp_enum") { |
} |
} |
+# Declare a target for generating Java constants from Google API Keys. |
+# |
+# This target will create a single .srcjar. Adding this target to an |
+# android_library target's srcjar_deps will make the generated java files be |
+# included in that library's final outputs. |
+# |
+# Example |
+# java_google_api_keys("foo_generated_keys") { |
+# } |
+template("java_google_api_keys") { |
+ set_sources_assignment_filter([]) |
+ forward_variables_from(invoker, [ "testonly" ]) |
+ |
+ generate_google_api_keys_target_name = |
+ "${target_name}__generate_google_api_keys" |
+ zip_srcjar_target_name = "${target_name}__zip_srcjar" |
+ final_target_name = target_name |
+ |
+ action(generate_google_api_keys_target_name) { |
+ visibility = [ ":$zip_srcjar_target_name" ] |
+ |
+ # The sources aren't compiled so don't check their dependencies. |
+ check_includes = false |
+ |
+ script = "//build/android/gyp/java_google_api_keys.py" |
+ gen_dir = "${target_gen_dir}/${target_name}/java_google_api_keys" |
+ outputs = [ |
+ get_path_info(rebase_path("GoogleAPIKeys.java", ".", gen_dir), "abspath"), |
+ ] |
+ |
+ args = [ rebase_path(gen_dir, root_build_dir) ] |
+ } |
+ |
+ generate_google_api_keys_outputs = |
+ get_target_outputs(":$generate_google_api_keys_target_name") |
+ base_gen_dir = |
+ get_label_info(":$generate_google_api_keys_target_name", "target_gen_dir") |
+ |
+ srcjar_path = "${target_gen_dir}/${target_name}.srcjar" |
+ zip(zip_srcjar_target_name) { |
+ visibility = [ ":$final_target_name" ] |
+ inputs = generate_google_api_keys_outputs |
+ output = srcjar_path |
+ base_dir = base_gen_dir |
+ deps = [ |
+ ":$generate_google_api_keys_target_name", |
+ ] |
+ } |
+ |
+ group(final_target_name) { |
+ forward_variables_from(invoker, [ "visibility" ]) |
+ public_deps = [ |
+ ":$zip_srcjar_target_name", |
+ ] |
+ } |
+} |
+ |
# Declare a target for processing a Jinja template. |
# |
# Variables |