Hi Konstantin,
Indeed, Bazel does not support dynamic dependencies. See e.g. the following thread for a related discussion:
A couple ideas how you could work around this in your case:
1. It sounds like you control the code generator. Would it be feasible to change it to produce easily predictable outputs? E.g. just a single .cpp and .h file.
2. You could use BUILD file generation, a la gazelle, to generate targets with predeclared outputs based on the sources that the code generator reads.
This could potentially be done in repository rules, so that Bazel reruns the code generation automatically when the inputs change.
3. As you say you could use directory outputs and write a custom rule that determines the compiler/linker and compiler/linker flags from the cc toolchain and then runs an action that compiles the .cpp files into a static archive in one go. This way you don't have to track individual .cpp files in Starlark.
The header files are a bit trickier. One option would be to merge the generated headers into one single header at a predictable output path.
Best, Andreas