aos: Support generated replacements in jinja2_template

I have a rule that generates replacements for a Jinja2 template. I
can't use any of the current mechanisms to do this so I decided to
enhance the rule.

You can now specify a `parameters_file` attribute whose contents will
be added to the available variables inside the template.

This came up when I wanted to copy the spyglass colors into a foxglove
script.

I couldn't figure out a good way to write a build test for this
because the //build_tests package in BRT's vendored copy of AOS
doesn't load properly.

Change-Id: Ib046817e5b698d5358b787e67953503ed2b57f78
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/tools/build_rules/template.bzl b/tools/build_rules/template.bzl
index 28d3c82..7174969 100644
--- a/tools/build_rules/template.bzl
+++ b/tools/build_rules/template.bzl
@@ -17,9 +17,11 @@
     args.add(json.encode(parameters))
     args.add(out)
     args.add_all(include_dirs, before_each = "--include_dir")
+    if ctx.file.parameters_file:
+        args.add("--replacements_file", ctx.file.parameters_file)
 
     ctx.actions.run(
-        inputs = ctx.files.src + ctx.files.includes,
+        inputs = ctx.files.src + ctx.files.includes + ctx.files.parameters_file,
         tools = [ctx.executable._jinja2],
         progress_message = "Generating " + out.short_path,
         outputs = [out],
@@ -50,6 +52,10 @@
             default = {},
             doc = """The string list parameters to supply to Jinja2.""",
         ),
+        "parameters_file": attr.label(
+            allow_single_file = True,
+            doc = """A JSON file whose contents are supplied as parameters to Jinja2.""",
+        ),
         "includes": attr.label_list(
             allow_files = True,
             doc = """Files which are included by the template.""",