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
Add an array type to user options #2390
Conversation
8bf4c91
to
b474b6a
Compare
ping |
docs/markdown/Build-options.md
Outdated
@@ -29,6 +30,8 @@ name. | |||
|
|||
These options are accessed in Meson code with the `get_option` function. | |||
|
|||
The array type is new in 0.43.0 |
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.
I think this should be 0.44.0 now, right?
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.
yes it should
b474b6a
to
9866346
Compare
the build failure is a traivs -> dockerhub issue. |
This is very useful for some 3rd package, e.g ffmpeg. there have more than 100 possible values for decoders, filters
|
This is good stuff, just a few things. What about the case when one of the values should contain a comma (for whatever reason)? Is it okay to say that in that case you should do There should be unit tests for changing the value of one of these options. First to check that changing it is persistant and second that trying to set it to an incorrect value returns an error and that the old value remains. |
How should I implement the "meson configure" portion of those tests? the standard framework doesn't have that kind of support, should I put them in manual tests or do you have something else in mind? |
See |
9866346
to
dc061c2
Compare
Added test cases and rebased on current master. |
values are passed as a comma separated list. | ||
|
||
```meson | ||
option('array_opt', type : 'array', choices : ['one', 'two', 'three'], value : 'one') |
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.
Maybe we should require value:
to always be an array type? In this case that would then be value : ['one']
. Otherwise people will constantly think that value:
can be a comma-separated list when they see a single-value value
kwarg.
I quite like this option, and I think it will also be useful in gstreamer for our GL elements. |
mesonbuild/optinterpreter.py
Outdated
value = kwargs.get('value', choices[0]) | ||
if not isinstance(value, list): | ||
if ',' in value: | ||
raise OptionException('Array choices must be passed as an array, not a comma delemited string.') |
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.
"delimited
", but I agree with @nirbheek, it's probably best to be consistent and always raise this exception (which means the bit after ,
goes away anyway)
Would it make more sense calling it list instead of array? It seems whenever you describe what it does, you say it makes it possible to pass a list of options. Also combo boxes are often used to select one item from a dropdown, and list boxes show a list of items you can select one or more from. Just a random thought. |
I also just encountered another place that could use this option type:
It supports I guess |
I thought that we had properly exposed the "no limits" array but apparently not. This is now done in #2696. That was also the reason for the string splitting mentioned above. Since we have not exposed it properly we can change the semantics to be the same as here: strings separated by commas and a properly quoted array if that is not sufficient. Does that seem like a suitable base for this? Having an option for an array both with freeform and with enforced contents seems useful. |
Or maybe we should bring these two together? Have an array type that may or may not have a limitation on the elements that are in it? |
I guess it depends on how we want to expose the difference. If we want to expose it via whether |
dc061c2
to
e9aa293
Compare
Okay, I think I addressed all of the review comment so far with this latest push. |
e9aa293
to
7d0b500
Compare
What should the default value be for this? Only the first element of the list (what this seems to have) is a bit off. It should probably be all enabled or all disabled. The former seems simpler because then you can do this to enable all:
as opposed to having to duplicate them:
But setting the value to empty is still brief:
|
That makes sense to me. |
So that the shbang is ther rist line and ./run_unittests.py works.
This exposes the already existing UserStringArrayOption class through the meson_options.txt. The intention is to provide a way for projects to take list/array type arguments and validate that all of the elements in that array are valid without using complex looping constructrs.
7d0b500
to
c9351ce
Compare
I've changed the default value to be the same as the choices, I've also updated the documentation for the option types to be (hopefully) clearer. |
Ci is fully booked for this night but I'll see how to make this work together with #2696, merge this and then do final fixups afterwards. At least winclibs and wincpplibs will be converted to this form. If people have opinions on if there should be only one array type or whether freeform arrays should be a different type from an array with permitted values, do speak up. |
Updated #2696. Please review. |
|
||
### Booleans | ||
|
||
Booleans may have values of either `true` or `false`. If not default value is |
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.
'If no default value'
|
||
### Arrays | ||
|
||
Arrays allow one or more of the values in the `choices` parameter to be selected. |
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.
Should this say 'zero or more'?
(forgot hit send to post this on friday... 🤦♂️)
I misunderstood #2696 at first, so I gave an incorrect comment which you can ignore. Looking at it all now, I think just having I would suggest renaming this type to plain One other question is: should duplicates be allowed? I would lean towards "no", so that meson can catch human errors like |
The user facing name was already |
In mesa (using autotools and scons) we take options such as
--enable-dri-drivers=i965,i915,swrast,...
. These options have a lot of possible values, so it makes sense to me to carry this pattern over to meson instead of having 30+ options to toggle each driver individually. I'm emulating it with a string type, and splitting, but it's impossible to validate that way.This option looks just like a combo in meson_options.txt, except that
value
can take a list of options.On the command line this is passed as a comma separated list of values, with white-space stripped.