Chromium Code Reviews| Index: build/config/android/rules.gni |
| diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni |
| index 43d79d0153a7cf7ea0e1349968108ac6d9bb38ad..cbf0944dea4e8f3f6b7bfbefeda2328b8f72597d 100644 |
| --- a/build/config/android/rules.gni |
| +++ b/build/config/android/rules.gni |
| @@ -262,6 +262,73 @@ 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 target_gen_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 = [] |
| + foreach(output, invoker.outputs) { |
| + outputs += [gen_dir + "/" + output] |
|
mkosiba (inactive)
2014/09/03 16:27:23
I couldn't figure out how to make rebase_path work
brettw
2014/09/03 21:23:38
The thing that reads the outputs variable will int
mkosiba (inactive)
2014/09/04 11:31:22
That just changes the error to:
The given file
brettw
2014/09/08 19:56:15
Oh, sorry. The checker doesn't know about relative
mkosiba (inactive)
2014/09/09 09:00:12
Ok, this seems to work although I could have sworn
|
| + } |
| + |
| + args = [ |
| + "--output_dir", rebase_path(gen_dir, root_build_dir), |
| + ] |
| + foreach(output, invoker.outputs) { |
| + args += ["--assert_file", rebase_path(output, root_build_dir, gen_dir)] |
| + } |
| + 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 |
| # |