Merge pull request #6161 from scivision/native_property
add meson.get_external_property()pull/6600/head
commit
8978717b6b
10 changed files with 111 additions and 15 deletions
@ -0,0 +1,18 @@ |
||||
## Native file properties |
||||
|
||||
As of Meson 0.54.0, the `--native-file nativefile.ini` can contain: |
||||
|
||||
* binaries |
||||
* paths |
||||
* properties |
||||
|
||||
which are defined and used the same way as in cross files. |
||||
The `properties` are new for Meson 0.54.0, and are read like: |
||||
|
||||
```meson |
||||
x = meson.get_external_property('foobar', 'foo') |
||||
``` |
||||
|
||||
where `foobar` is the property name, and the optional `foo` is the fallback string value. |
||||
|
||||
For cross-compiled projects, `get_external_property()` reads the cross-file unless `native: true` is specified. |
@ -1,29 +1,31 @@ |
||||
project('args flattening') |
||||
|
||||
arr = get_variable('does-not-exist', ['bar', 'baz']) |
||||
|
||||
assert(arr == ['bar', 'baz'], 'get_variable with array fallback is broken') |
||||
|
||||
set_variable('arr', ['bar', 'baz']) |
||||
|
||||
assert(arr == ['bar', 'baz'], 'set_variable(array) is broken') |
||||
|
||||
conf = configuration_data() |
||||
|
||||
conf.set('foo', ['bar', 'baz']) |
||||
|
||||
assert(conf.get('foo') == ['bar', 'baz'], 'configuration_data.set(array) is broken') |
||||
|
||||
arr = conf.get('does-not-exist', ['bar', 'baz']) |
||||
|
||||
assert(arr == ['bar', 'baz'], 'configuration_data.get with array fallback is broken') |
||||
|
||||
arr = meson.get_cross_property('does-not-exist', ['bar', 'baz']) |
||||
|
||||
assert(arr == ['bar', 'baz'], 'meson.get_cross_property with array fallback is broken') |
||||
|
||||
arr = meson.get_external_property('does-not-exist', ['bar', 'baz']) |
||||
assert(arr == ['bar', 'baz'], 'meson.get_external_property with array fallback is broken') |
||||
|
||||
arr = meson.get_external_property('does-not-exist', ['bar', 'baz'], native: true) |
||||
assert(arr == ['bar', 'baz'], 'meson.get_external_property native:true with array fallback is broken') |
||||
|
||||
arr = meson.get_external_property('does-not-exist', ['bar', 'baz'], native: false) |
||||
assert(arr == ['bar', 'baz'], 'meson.get_external_property native:false with array fallback is broken') |
||||
|
||||
# Test deprecated behaviour |
||||
|
||||
conf.set(['foo', 'bar']) |
||||
|
||||
message(conf.get('foo')) |
||||
|
@ -0,0 +1,3 @@ |
||||
[properties] |
||||
astring = 'cross' |
||||
anarray = ['one', 'two'] |
@ -0,0 +1,25 @@ |
||||
project('get prop') |
||||
|
||||
x = meson.get_external_property('astring') |
||||
ref = meson.is_cross_build() ? 'cross' : 'mystring' |
||||
assert(x==ref, 'did not get native property string. did you use "meson setup --native-file native.txt"') |
||||
|
||||
x = meson.get_external_property('astring', native: true) |
||||
assert(x=='mystring', 'did not get native property with native:true and non-cross build.') |
||||
|
||||
x = meson.get_external_property('astring', 'fallback', native: false) |
||||
assert(x==ref, 'did not get get native property with native:false and non-cross build.') |
||||
|
||||
|
||||
x = meson.get_external_property('notexist', 'fallback') |
||||
assert(x=='fallback', 'fallback did not work') |
||||
|
||||
x = meson.get_external_property('notexist', 'fallback', native: true) |
||||
assert(x=='fallback', 'fallback native:true did not work') |
||||
|
||||
x = meson.get_external_property('notexist', 'fallback', native: false) |
||||
assert(x=='fallback', 'fallback native:false did not work') |
||||
|
||||
|
||||
x = meson.get_external_property('anarray') |
||||
assert(x==['one', 'two'], 'array did not work') |
@ -0,0 +1,3 @@ |
||||
[properties] |
||||
astring = 'mystring' |
||||
anarray = ['one', 'two'] |
@ -0,0 +1,3 @@ |
||||
project('missing property') |
||||
|
||||
message(meson.get_external_property('nonexisting')) |
Loading…
Reference in new issue