Chromium Code Reviews| Index: build/config/android/rules.gni |
| diff --git a/build/config/android/rules.gni b/build/config/android/rules.gni |
| index 344202c71d156f076e821fb47842d5508fcb292c..2feeb7549b2baa9a7323f0ab2533024149ca30f8 100644 |
| --- a/build/config/android/rules.gni |
| +++ b/build/config/android/rules.gni |
| @@ -343,6 +343,116 @@ template("java_cpp_enum") { |
| } |
| } |
| +# Declare a target for processing a Jinja template. |
| +# |
| +# Variables |
| +# input: The template file to be processed. |
| +# output: Where to save the result. |
| +# variables: (Optional) A list of variables to make available to the template |
| +# processing environment, e.g. ["name=foo", "color=red"]. |
| +# |
| +# Example |
| +# jinja_template("chrome_shell_manifest") { |
| +# input = "shell/java/AndroidManifest.xml" |
| +# output = "$target_gen_dir/AndroidManifest.xml" |
| +# } |
| +template("jinja_template") { |
| + if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| + |
| + assert(defined(invoker.input)) |
| + assert(defined(invoker.output)) |
| + |
| + action(target_name) { |
| + sources = [invoker.input] |
| + script = "//build/android/gyp/jinja_template.py" |
| + depfile = "$target_gen_dir/$target_name.d" |
| + |
| + outputs = [ |
| + depfile, |
| + invoker.output, |
| + ] |
| + |
| + args = [ |
| + "--inputs", rebase_path(invoker.input, root_build_dir), |
| + "--output", rebase_path(invoker.output, root_build_dir), |
| + "--depfile", rebase_path(depfile, root_build_dir), |
| + ] |
| + if (defined(invoker.variables)) { |
| + variables = invoker.variables |
| + args += ["--variables=${variables}" ] |
| + } |
| + } |
| +} |
| + |
| +# Declare a target for processing Android resources as Jinja templates. |
| +# |
| +# This takes an Android resource directory where each resource is a Jinja |
| +# template, processes each template, then packages the results in a zip file |
| +# which can be consumed by an android resources, library, or apk target. |
| +# |
| +# If this target is included in the deps of an android resources/library/apk, |
| +# the resources will be included with that target. |
| +# |
| +# Variables |
| +# resources: The list of resources files to process. |
| +# res_dir: The resource directory containing the resources. |
| +# variables: (Optional) A list of variables to make available to the template |
| +# processing environment, e.g. ["name=foo", "color=red"]. |
| +# |
| +# Example |
| +# jinja_template_resources("chrome_shell_template_resources") { |
| +# res_dir = "shell/res_template" |
| +# resources = ["shell/res_template/xml/syncable.xml"] |
| +# variables = ["color=red"] |
| +# } |
| +template("jinja_template_resources") { |
| + if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| + |
| + assert(defined(invoker.resources)) |
| + assert(defined(invoker.res_dir)) |
| + |
| + base_path = "$target_gen_dir/$target_name" |
|
cjhopman
2014/10/17 18:54:25
for these variables set at the top level of the te
newt (away)
2014/10/20 22:45:12
Done.
|
| + resources_zip = base_path + ".resources.zip" |
| + build_config = base_path + ".build_config" |
| + |
| + write_build_config("${target_name}__build_config") { |
| + type = "android_resources" |
| + # Why?? I just copy-pasted this |
|
cjhopman
2014/10/17 18:54:25
You shouldn't need to forward the deps. Since deps
newt (away)
2014/10/20 22:45:12
Done.
|
| + if (defined(invoker.deps)) { |
| + deps = invoker.deps |
| + } |
| + } |
| + |
| + action("${target_name}__template") { |
| + sources = invoker.resources |
| + script = "//build/android/gyp/jinja_template.py" |
| + depfile = "$target_gen_dir/$target_name.d" |
| + |
| + outputs = [ |
| + depfile, |
| + resources_zip, |
| + ] |
| + |
| + rebased_resources = rebase_path(invoker.resources, root_build_dir) |
| + args = [ |
| + "--inputs=${rebased_resources}", |
| + "--inputs-base-dir", rebase_path(invoker.res_dir, root_build_dir), |
| + "--outputs-zip", rebase_path(resources_zip, root_build_dir), |
| + "--depfile", rebase_path(depfile, root_build_dir), |
| + ] |
| + if (defined(invoker.variables)) { |
| + variables = invoker.variables |
| + args += ["--variables=${variables}" ] |
| + } |
| + } |
| + |
| + group(target_name) { |
| + deps = [ |
| + ":${target_name}__build_config", |
| + ":${target_name}__template", |
| + ] |
| + } |
| +} |
| # Declare an Android resources target |
| # |
| @@ -689,6 +799,7 @@ template("android_java_prebuilt") { |
| group(target_name) { |
| deps = [ |
| ":${target_name}__dex", |
|
cjhopman
2014/10/17 18:54:25
sort.
newt (away)
2014/10/20 22:45:12
Done.
|
| + ":${target_name}__build_config", |
| ] |
| } |
| } |