Shorthand for including an output file of a genrule directory as a src
See original GitHub issueIf you have a genrule that creates a directory with several files, it’s a bit of a pain to write another genrule
rule for each (expected) output, just to be able to pass it to *_library (java, python, etc). It would be nice to allow you to somehow specify this in the sources - maybe via flavors (although it is a bit hackish)? e.g.
genrule(
name='gen_my_thing',
out='things',
cmd='$(exe :my_custom_generator) $SRCDIR $OUT',
srcs=glob(['File1.java', 'File2.java']),
)
java_library(
name='lib',
srcs=[
':gen_my_thing#lib_output/File1Out.java',
':gen_my_thing#lib_output/File2Out.java',
]
)
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:11 (7 by maintainers)
Top Results From Across the Web
General Rules | Bazel
The build system automatically deletes any existing output files, but creates any necessary parent directories before it runs a genrule.
Read more >Writing additional build rules - Please Build
To this end each rule builds in its own temporary directory (under plz-out/tmp ) containing only files defined as inputs to the rule....
Read more >Bazel: genrule that outputs a directory - Stack Overflow
The output of a genrule must be a fixed list of files. As a work-around, you can create a zip from the output...
Read more >Experimentations on Bazel: genrule - DEV Community
When outs is a list of one file, then $@ can be used as a shortcut to identify the output file. Go back...
Read more >How to use gen-file outs from one rule as srcs in another genrule
Right now this creates the generated header in the bazel-out directory. How can I make this create the output file in bazel-genfiles instead ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, that works.
For those who stumble on this, try something like:
You need to know the names of the files in advance and write them in the build files.
You can do that using a python loop if you wish, but you cannot list files in the output directory.
The same limitation exists with the new syntax.