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

Unified Diff: build/config/android/rules.gni

Issue 484603004: New C++ -> Java enum build rule + parser/generator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/java_cpp_enum.gypi ('k') | build/gyp_chromium » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/android/rules.gni
diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni
index 510f516f47d3532544d8be43333bc274a6dc8294..a19d3e97b3005fee8bd5df9beaccae17a8f0f852 100644
--- a/build/config/android/rules.gni
+++ b/build/config/android/rules.gni
@@ -261,6 +261,71 @@ template("java_cpp_template") {
}
}
+# Declare a target for generating Java classes from C++ enums.
+#
+# This target generates Java files from C++ enums 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 annotated
+# enum contained in the sources files the script will generate a .java
+# file with the same name as the name of the enum.
+#
+# outputs: list of outputs, relative to the output_dir. These paths are
+# verified at build time by the script. To get the list programatically run:
+# python build/android/gyp/java_cpp_enum.py --output_dir=. \
+# --print_output_only path/to/header/file.h
+#
+# Example
+# java_cpp_enum("foo_generated_enum") {
+# sources = [
+# "src/native_foo_header.h",
+# ]
+# outputs = [
+# "org/chromium/FooEnum.java",
+# ]
+# }
+template("java_cpp_enum") {
+ assert(defined(invoker.sources))
+ assert(defined(invoker.outputs))
+
+ action("${target_name}__generate_enum") {
+ sources = rebase_path(invoker.sources, root_build_dir)
+ script = "//build/android/gyp/java_cpp_enum.py"
+ gen_dir = "${target_gen_dir}/${target_name}/enums"
+ outputs = get_path_info(
+ rebase_path(invoker.outputs, ".", gen_dir), "abspath")
+
+ args = [
+ "--output_dir", rebase_path(gen_dir, root_build_dir),
+ ]
+ foreach(output, rebase_path(outputs, root_build_dir)) {
+ args += ["--assert_file", output]
+ }
+ args += sources
+ }
+
+ generate_enum_outputs = get_target_outputs(":${target_name}__generate_enum")
+ base_gen_dir = get_label_info(":${target_name}__generate_enum",
+ "target_gen_dir")
+
+ srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
+ zip("${target_name}__zip_srcjar") {
+ inputs = generate_enum_outputs
+ output = srcjar_path
+ base_dir = base_gen_dir
+ }
+
+ group(target_name) {
+ deps = [
+ ":${target_name}__zip_srcjar"
+ ]
+ }
+}
+
# Declare an Android resources target
#
« no previous file with comments | « build/android/java_cpp_enum.gypi ('k') | build/gyp_chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698