Chromium Code Reviews| Index: build/config/android/rules.gni |
| diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni |
| index 6820ba3c76c5f766b0543f538f4b07baf11fd317..f124fa02a2a125e206a49a59dd40c6b65c507ad3 100644 |
| --- a/build/config/android/rules.gni |
| +++ b/build/config/android/rules.gni |
| @@ -2,6 +2,8 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import("internal_rules.gni") |
| + |
| # Declare a jni target |
| # |
| # This target generates the native jni bindings for a set of .java files. |
| @@ -59,3 +61,83 @@ template("generate_jni") { |
| hard_dep = true |
| } |
| } |
| + |
| +# Declare a target for c-preprocessor-generated java files |
| +# |
| +# This target generates java files using the host C pre-processor. Each file in |
| +# sources will be compiled using the C pre-processor. If include_path is |
| +# specified, it will be passed (with --I) to the pre-processor. |
| +# |
| +# This target will create a single .srcjar. Adding this target to a 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 C pre-processor. For each |
| +# file in sources, there will be one .java file in the final .srcjar. For a |
| +# file named FooBar.template, a java file will be created with name |
| +# FooBar.java. |
| +# source_prereqs: additional compile-time dependencies. Any files |
| +# `#include`-ed in the templates should be listed here. |
| +# package_name: this will be the subdirectory for each .java file in the .srcjar. |
| +# |
| +# Example |
| +# java_cpp_template("foo_generated_enum") { |
| +# sources = [ |
| +# "android/java/templates/Foo.template", |
| +# ] |
| +# source_prereqs = [ |
| +# "android/java/templates/native_foo_header.h", |
| +# ] |
| +# |
| +# package_name = "org/chromium/base/library_loader" |
| +# include_path = "android/java/templates" |
| +# } |
| +template("java_cpp_template") { |
| + assert(defined(invoker.sources)) |
| + package_name = invoker.package_name + "" |
| + |
| + if (defined(invoker.include_path)) { |
| + include_path = invoker.include_path + "" |
| + } else { |
| + include_path = "//" |
| + } |
| + |
| + base_gen_dir = "${root_gen_dir}/java_cpp_template/${target_name}/${package_name}" |
|
brettw
2014/05/06 18:06:35
Can you put the string on the next line to make it
|
| + gen_dir = "${base_gen_dir}/${package_name}" |
| + gcc_template_output_pattern = "${gen_dir}/{{source_name_part}}.java" |
| + apply_gcc_outputs = process_file_template( |
| + invoker.sources, gcc_template_output_pattern |
| + ) |
|
brettw
2014/05/06 18:06:35
) goes on prev line.
|
| + |
| + action_foreach("${target_name}__apply_gcc") { |
| + script = "//build/android/gyp/gcc_preprocess.py" |
| + if (defined(invoker.source_prereqs)) { |
| + source_prereqs = invoker.source_prereqs + [] |
| + } |
| + |
| + sources = invoker.sources |
| + outputs = [ |
| + gcc_template_output_pattern |
| + ] |
| + |
| + args = [ |
| + "--include-path", rebase_path(include_path), |
| + "--output", rebase_path(gen_dir) + "/{{source_name_part}}.java", |
| + "--template={{source}}", |
| + ] |
| + } |
| + |
| + srcjar_path = get_target_gen_path(":${target_name}", ".srcjar") |
| + _zip("${target_name}__zip_srcjar") { |
| + inputs = apply_gcc_outputs |
| + output = srcjar_path |
| + base_dir = base_gen_dir |
| + } |
| + |
| + group(target_name) { |
| + deps = [ |
| + ":${target_name}__zip_srcjar" |
| + ] |
| + } |
| +} |