I've a rule with a conditional attribute:
some_rule(
name = "my_rule",
some_attr = select({
":ts_diagnostics_mode_extended": ["--extendedDiagnostics"]
}),
)
and with the config setting:
config_setting(
name = "ts_diagnostics_mode_extended",
values = { "define": "ts_diagnostics_mode=extended_diagnostics" }
)
However, when building with bazel build :my_target --define ts_diagnostics_mode=extended_diagnostics I get
Configurable attribute "some_attr" doesn't match this configuration (would a default condition help?).
What's missing?
--define flags are handled specially by config_setting, via define_values, because they are multi-valued. I think this will work:
config_setting(
name = "ts_diagnostics_mode_extended",
define_values = { "ts_diagnostics_mode": "extended_diagnostics" }
)
While define_values indeed works, your original example with values should also work. define_values is only necessary when you want the config_setting to have multiple entries.
See this line in the define_values documentation:
--definecan still appear invalueswith normal flag syntax, and can be mixed freely with this attribute as long as dictionary keys remain distinct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With