-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config.string with allow_multiple=True should use list for build_setting_default #13817
Comments
Interesting. Are you comfortable if it still uses the same syntax I get your point, and agree this is worth addressing. I'd want to be cautious to make sure whatever solution doesn't create some unknown other consistency in some other API piece with different expectations. |
@gregestren What would you think of allowing both Edit: I now see that the problem is not that |
I ultimately came to the conclusion that the source of issues is that repeatable string flags should be represented as |
Thanks. I'll take a look. Also cc @aranguyen FYI who's been looking recently at flag parsing logic in general. |
@fmeum thanks for sending out the proposal. I don't know how to make comments on the proposal you linked so I'm dropping them here instead.
|
@aranguyen My proposal doesn't allow for this syntax, so it (luckily) doesn't have to specify this interaction. My proposal only affects how repeated flags are represented in Starlark, not how they are specified on the command-line: You still either specify a |
For all parts of Bazel other than option parsing, string build setting flags with `allow_multiple = True` should behave just like `string_list` settings, even though they are fundamentally of a different type. This requires a lot of special casing all over the code base and also causes confusing user-facing behavior when transitioning on such settings. This commit deprecates the `allow_multiple` named parameter of `config.string` and as a replacement introduces a new named parameter `repeatable` on `config.string_list`. Settings with the latter set to True behave exactly like `string` settings with `allow_multiple = True` with respect to command-line option parsing and exactly like ordinary `string_list` flags in all other situations. Fixes bazelbuild#13817 Closes bazelbuild#14911. PiperOrigin-RevId: 462146752 Change-Id: I91ddc4328a1b2244f4303fcda7b4228b182a5d56
For all parts of Bazel other than option parsing, string build setting flags with `allow_multiple = True` should behave just like `string_list` settings, even though they are fundamentally of a different type. This requires a lot of special casing all over the code base and also causes confusing user-facing behavior when transitioning on such settings. This commit deprecates the `allow_multiple` named parameter of `config.string` and as a replacement introduces a new named parameter `repeatable` on `config.string_list`. Settings with the latter set to True behave exactly like `string` settings with `allow_multiple = True` with respect to command-line option parsing and exactly like ordinary `string_list` flags in all other situations. Fixes bazelbuild#13817 Closes bazelbuild#14911. PiperOrigin-RevId: 462146752 Change-Id: I91ddc4328a1b2244f4303fcda7b4228b182a5d56
For all parts of Bazel other than option parsing, string build setting flags with `allow_multiple = True` should behave just like `string_list` settings, even though they are fundamentally of a different type. This requires a lot of special casing all over the code base and also causes confusing user-facing behavior when transitioning on such settings. This commit deprecates the `allow_multiple` named parameter of `config.string` and as a replacement introduces a new named parameter `repeatable` on `config.string_list`. Settings with the latter set to True behave exactly like `string` settings with `allow_multiple = True` with respect to command-line option parsing and exactly like ordinary `string_list` flags in all other situations. Fixes bazelbuild#13817 Closes bazelbuild#14911. PiperOrigin-RevId: 462146752 Change-Id: I91ddc4328a1b2244f4303fcda7b4228b182a5d56
For all parts of Bazel other than option parsing, string build setting flags with `allow_multiple = True` should behave just like `string_list` settings, even though they are fundamentally of a different type. This requires a lot of special casing all over the code base and also causes confusing user-facing behavior when transitioning on such settings. This commit deprecates the `allow_multiple` named parameter of `config.string` and as a replacement introduces a new named parameter `repeatable` on `config.string_list`. Settings with the latter set to True behave exactly like `string` settings with `allow_multiple = True` with respect to command-line option parsing and exactly like ordinary `string_list` flags in all other situations. Fixes #13817 Closes #14911. PiperOrigin-RevId: 462146752 Change-Id: I91ddc4328a1b2244f4303fcda7b4228b182a5d56 Co-authored-by: Fabian Meumertzheim <[email protected]>
I'm trying to migrate a native flag (
--protocopt
) to a Starlark flag. For this, we need a flag that a) can be supplied multiple times (like withallow_multiple=True
-config.string_list
doesn't allow this) and b) has an empty default.Today, it's impossible to get an empty list or a list with multiple elements as
ctx.build_setting_value
when usingconfig.string
withallow_multiple=True
.There are ways to work around this (i.e. setting
build_setting_default
to a nonsensical value and checking forctx.build_setting_value
with one element that is the specified default value), but that seems unnecessarily complex.From a technical perspective, changing the allowed type for
build_setting_default
whenallow_multiple=True
looks pretty straight forward to me.allow_multiple
was added in https://cs.opensource.google/bazel/bazel/+/a13f590b69bcbcaa10b1a49bfd9a4607dfbd8f47 after cutting Bazel 4.0.0, so its usage in the wild should be low.The text was updated successfully, but these errors were encountered: