Inside a .bzl
file,
I specify a program to generate some code.
It looks something like this:
def generate_code():
native.genrule(
name = "foo",
outs = ["file.hpp"],
tools = ["//path/to:tool"],
cmd = $(location path/to:tool) $(@D)
)
This works fine,
however the problem is that the tool might generate more files than are specified in outs
.
I'm trying to find a way to either have bazel stop the build if more files are generated than specified, or to have the outs automatically be everything generated.
I'm not aware of a generalized way to have bazel error out if additional, unexpected files were generated.
One thing I could recommend is wrapping your tool in another tool which verifies the output files in the target directory and only returns success if no unexpected files were generated.
As for a generalized solution that intentionally includes all files in an output directory, consider using actions.declare_directory and creating a skylark rule instead of using
native.genrule
.