diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index e3830cc51..690ae0b3d 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -1786,6 +1786,10 @@ the following methods. returns the "cross" compiler if we're currently cross-compiling and the "native" compiler if we're not. +- `get_native_property(propname, fallback_value)` returns the given + property from a native file, the optional second argument is returned + if the given property is not found. + - `has_exe_wrapper()` returns true when doing a cross build if there is a wrapper command that can be used to execute cross built binaries (for example when cross compiling from Linux to Windows, diff --git a/test cases/common/192 args flattening/meson.build b/test cases/common/192 args flattening/meson.build index 6da2e8f25..42eb6d536 100644 --- a/test cases/common/192 args flattening/meson.build +++ b/test cases/common/192 args flattening/meson.build @@ -1,29 +1,25 @@ 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_native_property('does-not-exist', ['bar', 'baz']) +assert(arr == ['bar', 'baz'], 'meson.get_native_property with array fallback is broken') + # Test deprecated behaviour conf.set(['foo', 'bar']) - message(conf.get('foo')) diff --git a/test cases/common/228 native prop/meson.build b/test cases/common/228 native prop/meson.build new file mode 100644 index 000000000..5cffcad52 --- /dev/null +++ b/test cases/common/228 native prop/meson.build @@ -0,0 +1,10 @@ +project('get native prop') + +x = meson.get_native_property('astring') +assert(x=='mystring', 'did not get native property string. did you use "meson setup --native-file native.txt"') + +x = meson.get_native_property('notexist', 'fallback') +assert(x=='fallback', 'fallback did not work') + +x = meson.get_native_property('anarray') +assert(x==['one', 'two'], 'array did not work') \ No newline at end of file diff --git a/test cases/common/228 native prop/nativefile.ini b/test cases/common/228 native prop/nativefile.ini new file mode 100644 index 000000000..03c1e0397 --- /dev/null +++ b/test cases/common/228 native prop/nativefile.ini @@ -0,0 +1,3 @@ +[properties] +astring = 'mystring' +anarray = ['one', 'two'] \ No newline at end of file diff --git a/test cases/failing/97 no native prop/meson.build b/test cases/failing/97 no native prop/meson.build new file mode 100644 index 000000000..2b7b46e5b --- /dev/null +++ b/test cases/failing/97 no native prop/meson.build @@ -0,0 +1,3 @@ +project('missing native property') + +message(meson.get_native_property('nonexisting'))