-
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
Allow string_list flags to be set via repeated flag uses #14911
Conversation
I like what you're doing here but this is complicated enough (from an API perspective) where I'd like to see a proper design doc. Would you be up for that? I'm not asking anything complex: just a small doc that clearly states the issue and why this approach solves it effectively. And ensures everyone's collaboratively considering all angles. For example, there are important nuances (which you acknowledge in the PR) I'd like to be upfront clear: a repeated I'm asking this because I'd like to avoid the same outcome with This isn't a knock at your proposal (which is super-promising!). It's general caution I have for any API changes in this area. But I agree there are real API issues to address, and the status quo is insufficient. CC @brandjon @comius who are also thinking about general API curation. |
I'm also curious how or if this applies to other types. Like a theoretical |
70a4290
to
e33a5e4
Compare
I will try to get a short doc started. I'm now leaning towards using a more descriptive argument, e.g. something like
It would not require any additional code apart from adding the parameter to |
e33a5e4
to
70a4290
Compare
@gregestren I submitted bazelbuild/proposals#248. |
To be clear, I'm hesitant to support |
(this is a super-useful feature and we from |
FYI @fmeum , @aranguyen and I have a sync next week to try to move this forward. |
70a4290
to
72a44a3
Compare
@aranguyen I updated the PR to reflect the update to the proposal I submitted in bazelbuild/proposals#266 |
90b0660
to
e04ea41
Compare
+ " implementation function will be a list of strings. Insertion order and" | ||
+ " repeated values are both maintained. This list can be post-processed in the" | ||
+ " build setting implementation function if different behavior is desired.", | ||
"Deprecated, use a <code>string_list</code> setting with" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually do anything beside doc? I was thinking it would be nice to emit a WARNING from now on if allowMultiple is being used. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outside Google, such a warning probably wouldn't work that well: The ones seeing the warning (ruleset users on a new Bazel version) would not be the ones in a position to fix it (ruleset authors). In the past, I think that this has been handled via an --incompatible_*
flag, which is flipped at some point with a full downstream pipeline running against the popular rulesets before the flip.
@@ -3025,6 +3025,51 @@ public void testBuildSettingValue_allowMultipleSetting() throws Exception { | |||
.containsExactly("some-other-value", "some-other-other-value"); | |||
} | |||
|
|||
@SuppressWarnings("unchecked") | |||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of these test cases are great. Thank you for adding them. Could we also add test case for this example
--copt=a,b,c --> ["a,b,c"]
--copt=a --copt=b,c --> ["a", "b,c"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
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 `repeatable` parameter 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.
e04ea41
to
3b4b3a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I'm trying out a new internal review process. If all goes well, this should be merged soon. Thanks for your patience.
@@ -3025,6 +3025,51 @@ public void testBuildSettingValue_allowMultipleSetting() throws Exception { | |||
.containsExactly("some-other-value", "some-other-other-value"); | |||
} | |||
|
|||
@SuppressWarnings("unchecked") | |||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@bazel-io flag |
@gregestren Do you think we should add an incompatible flag disabling the old |
@bazel-io fork 5.3.0 |
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
@kshyanashree The |
@bazel-io fork 5.3.0 |
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]>
For all parts of Bazel other than option parsing, string build setting
flags with
allow_multiple = True
should behave just likestring_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 ofconfig.string
and as a replacement introduces a new named parameterrepeatable
onconfig.string_list
. Settings with the latter set to Truebehave exactly like
string
settings withallow_multiple = True
withrespect to command-line option parsing and exactly like ordinary
string_list
flags in all other situations.Fixes #13817