Merge pull request #2390 from dcbaker/submit/options-list
Add an array type to user optionspull/2730/head
commit
793fc002fa
11 changed files with 208 additions and 20 deletions
@ -0,0 +1,17 @@ |
||||
# An array type for user options |
||||
|
||||
Previously to have an option that took more than one value a string value would |
||||
have to be created and split, but validating this was difficult. A new array type |
||||
has been added to the meson_options.txt for this case. It works like a 'combo', but |
||||
allows more than one option to be passed. When used on the command line (with -D), |
||||
values are passed as a comma separated list. |
||||
|
||||
```meson |
||||
option('array_opt', type : 'array', choices : ['one', 'two', 'three'], value : ['one']) |
||||
``` |
||||
|
||||
These can be overwritten on the command line, |
||||
|
||||
```meson |
||||
meson _build -Darray_opt=two,three |
||||
``` |
@ -0,0 +1,17 @@ |
||||
# Copyright © 2017 Intel Corporation |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
project('stringarray default options') |
||||
|
||||
assert(get_option('array') == ['foo', 'bar'], 'Default value for array is not equal to choices') |
@ -0,0 +1,19 @@ |
||||
# Copyright © 2017 Intel Corporation |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
option( |
||||
'array', |
||||
type : 'array', |
||||
choices : ['foo', 'bar'], |
||||
) |
@ -1,3 +1,4 @@ |
||||
option('testoption', type : 'string', value : 'optval', description : 'An option to do something') |
||||
option('other_one', type : 'boolean', value : false) |
||||
option('combo_opt', type : 'combo', choices : ['one', 'two', 'combo'], value : 'combo') |
||||
option('array_opt', type : 'array', choices : ['one', 'two', 'three'], value : ['one', 'two']) |
||||
|
@ -0,0 +1,15 @@ |
||||
# Copyright © 2017 Intel Corporation |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
project('array option test') |
@ -0,0 +1,20 @@ |
||||
# Copyright © 2017 Intel Corporation |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
|
||||
option( |
||||
'list', |
||||
type : 'array', |
||||
value : ['foo', 'bar'], |
||||
choices : ['foo', 'bar', 'oink', 'boink'], |
||||
) |
Loading…
Reference in new issue