Reputation: 6022
This answer to Looking for examples of Bazel genrules that generate data files states that "A genrule needs to know all its input files and output files".
Is it possible to write a genrule whose outputs depend on the input file? For example
genrule(
name = "creator",
cmd = "xargs -a $< touch",
srcs = [ "meow.txt" ],
)
This would create a file for each word in meow.txt
, e.g.
Chico
Groucho
Harpo
would create three files.
The list of output files depends entirely on the content of meow.txt
and is not known in the BUILD file.
Upvotes: 0
Views: 1430
Reputation: 20530
That is beyond the capabilities of genrule
. However, it is possible write a custom rule that outputs a directory, into which arbitrary files can be written when the action executes.
Upvotes: 1