Index: build/config/android/rules.gni |
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni |
index 49ccc1d2991cb7c9fc751e983fa25c9a25d9c030..54206ffbf0c3270423ef6cada7536ef1315c4f45 100644 |
--- a/build/config/android/rules.gni |
+++ b/build/config/android/rules.gni |
@@ -367,6 +367,58 @@ template("java_cpp_enum") { |
} |
} |
+# Declare a target for generating Java classes from C++ strings. |
+# |
+# This target generates Java files from C++ strings using a script. |
+# |
+# 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. |
+# |
+# Variables |
+# sources: list of files to be processed by the script. For each source |
+# file the script will generate a .java file including all the strings |
+# in the source file with the name indicated in the derectives. |
+# |
+# Example |
+# java_cpp_string("foo_generated_string") { |
+# sources = [ |
+# "src/native_foo.cc", |
+# ] |
+# } |
+template("java_cpp_string") { |
+ action(target_name) { |
+ # The sources aren't compiled so don't check their dependencies. |
+ check_includes = false |
+ set_sources_assignment_filter([]) |
+ |
+ assert(defined(invoker.sources)) |
+ forward_variables_from(invoker, |
+ [ |
+ "sources", |
+ "testonly", |
+ "visibility", |
+ ]) |
+ |
+ script = "//build/android/gyp/java_cpp_string.py" |
+ depfile = "$target_gen_dir/$target_name.d" |
+ |
+ _srcjar_path = "${target_gen_dir}/${target_name}.srcjar" |
+ _rebased_srcjar_path = rebase_path(_srcjar_path, root_build_dir) |
+ _rebased_sources = rebase_path(invoker.sources, root_build_dir) |
+ |
+ args = [ |
+ "--depfile", |
+ rebase_path(depfile, root_build_dir), |
+ "--srcjar=$_rebased_srcjar_path", |
+ ] + _rebased_sources |
+ outputs = [ |
+ depfile, |
+ _srcjar_path, |
+ ] |
+ } |
+} |
+ |
# Declare a target for processing a Jinja template. |
# |
# Variables |