facebook / facebook/buck2

genrule with output folder consumed by cxx_library

Open
#520 17 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
4.4k
Forks
394
PR merge metrics
No merged PRs in 30d

Description

I want to have a genrule that outputs multiple cpp files to a directory, and then have those files consumed and all compiled by a cxx_library. I tried this:

```
genrule(
name="foo-gen",
srcs=["foo.json", "generate.py"],
out = "foo-folder", # This is the folder where all the output files go
cmd = "python generate.py foo.json -o ${out}/foo"
)

cxx_library(
name = "foo",
srcs = glob(["$(output :foo-gen)/foo/*.cpp)"])
```

This doesn't work, I guess because you can't expand string parameter macros inside of a glob. The problem appears to be with the cxx rule, and not with the genrule, as the genrule can certainly create the directory and output multiple files there.

Is there anything that can be done to handle this use case (generate multiple files from one input, consume them from a dependent rule)?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.