I have a build setting like:
string_flag(
name = "version",
build_setting_default = "0.1")
I want to use it to create a file, e.g.:
ctx.actions.run_shell(
outputs = ["report-%s.csv" % (version)],
inputs = ctx.files.inputs,
command = "$(location //build:report-generator.sh) 2>&1"
)
However, I get the following error:
Error in run_shell: at index 0 of outputs, got element of type string, want File
Here is the docs for File: https://docs.bazel.build/versions/main/skylark/lib/File.html
created during the analysis phase
So my question is, how do you get the value of a build setting during the analysis phase?
As the error message says, the outputs
argument to run_shell
expects a list of File
objects rather than strings. One generally obtains an appropriate output File
object by declaring an output in the rule class definition or using the ctx.actions.declare_file
method.