bazelbuild / rules_dotnet

.NET rules for Bazel
Apache License 2.0
188 stars 83 forks source link

Transitions in csharp_ rules causes code generators to run multiple times #415

Open peakschris opened 7 months ago

peakschris commented 7 months ago

Two rules, csharp_binary and cc_binary both depend on a single code generation rule. However, because csharp_binary uses transitions, the code generation rule runs multiple times, once for cc_binary, and another time for each csharp_binary target framework.

Here is a minimal worked example: https://github.com/peakschris/bazel-cs-gen-transitions

I've found an unpleasant workaround to use rules_dotnet's 'default_transition' as cfg= in the custom codegen rule, but this causes all code generations to run in a directory with ST-hash, rather than the actual default configuration. And it only works if rules_dotnet is the only ruleset using transitions.

Possible solutions

purkhusid commented 7 months ago

It's on my list to see if I can optimize the transitions a bit since I'm encountering some double building as well. Can't say when I will have the time though.