(NOTE: I am not on the Bazel team and do not speak for them!)
Interesting! To be honest, the question mark (?) looks like a special operator that is not part of the name, and I find this confusing. And there are already so many confusing things in Bazel :-)
For example, config_setting() does not "set" anything at all, but defines an item that can be referenced in select() calls. This should have been called
config_condition() instead!.
I like to use `is_` or `has_` prefixes for these, as this makes my Bazel files clearer (e.g. "is_debug", "has_foo_feature").
I think that solves the issue you want to address in the second part of your proposal without introducing changes to Bazel.
Regarding constraint_setting(), their value cannot be selected with `--<label>=<value>` on the command line. The only thing that impacts them is the platform name. On the command line, this is done with `--platforms=<label>`. And during analysis, constraint values can only be changed by using transitions that change the value of
"//command_line_option:platforms". Note that despite the use of a plural (i.e. --platform
s), this option only takes a single label value, so this is not something you would use to set the value of a single build flag, independent from the others.
It looks like a build_setting() would be a better choice for your example:
```
# From foo/BUILD.bazel
# A user-settable build configuration boolean flag. Use `--//foo:vm=True` on the command-line to set it.
load("@bazel_skylib//lib:common_settings.bzl", "bool_flag")
bool_flag("vm")
# A condition to be referenced in select() statements that will hold true when //foo:vm is set.
config_setting(
name = "is_vm",
flag_values = {
":vm": True,
},
)
# From compilation_mode/BUILD.bazel
config_setting(
name = "is_dbg",
values = {
"compilation_mode": "dbg",
},
)
```
Oh, and constraint_setting() should really be named constraint_dimension(), and build_setting() should really be called build_variable() :-)
Hope this helps.