diff options
author | Marvin Scholz <epirat07@gmail.com> | 2022-11-22 23:20:05 +0100 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2022-12-06 10:59:00 -0500 |
commit | 85a58f12f09795078b8bd2a26fce0465d46c36a2 (patch) | |
tree | fe30c914ae0160851d951a35b700136e815146cb | |
parent | cee7ecde3de4a338081d6856b4127f5dc268fb40 (diff) | |
download | meson-85a58f12f09795078b8bd2a26fce0465d46c36a2.zip meson-85a58f12f09795078b8bd2a26fce0465d46c36a2.tar.gz meson-85a58f12f09795078b8bd2a26fce0465d46c36a2.tar.bz2 |
interpreter: compiler: Allow array for the prefix kwarg
-rw-r--r-- | docs/markdown/snippets/compiler_prefix_property_array.md | 18 | ||||
-rw-r--r-- | docs/yaml/objects/compiler.yaml | 12 | ||||
-rw-r--r-- | mesonbuild/interpreter/compiler.py | 8 |
3 files changed, 32 insertions, 6 deletions
diff --git a/docs/markdown/snippets/compiler_prefix_property_array.md b/docs/markdown/snippets/compiler_prefix_property_array.md new file mode 100644 index 0000000..75b7156 --- /dev/null +++ b/docs/markdown/snippets/compiler_prefix_property_array.md @@ -0,0 +1,18 @@ +## Compiler check functions `prefix` kwargs accepts arrays + +The `prefix` kwarg that most compiler check functions support +now accepts an array in addition to a string. The elements of the +array will be concatenated separated by a newline. + +This makes it more readable to write checks that need multiple headers +to be included: + +```meson +cc.check_header('GL/wglew.h', prefix : ['#include <windows.h>', '#include <GL/glew.h>']) +``` + +instead of + +```meson +cc.check_header('GL/wglew.h', prefix : '#include <windows.h>\n#include <GL/glew.h>']) +``` diff --git a/docs/yaml/objects/compiler.yaml b/docs/yaml/objects/compiler.yaml index e10e8fe..01283cd 100644 --- a/docs/yaml/objects/compiler.yaml +++ b/docs/yaml/objects/compiler.yaml @@ -78,13 +78,15 @@ methods: description: You have found a bug if you can see this! kwargs: prefix: - type: str + type: str | list[str] description: | Used to add `#include`s and other things that are required - for the symbol to be declared. System definitions should be - passed via compiler args (eg: `_GNU_SOURCE` is often required for - some symbols to be exposed on Linux, and it should be passed via - `args` keyword argument). + for the symbol to be declared. Since 1.0.0 an array is accepted + too. When an array is passed, the items are concatenated together + separated by a newline. + System definitions should be passed via compiler args + (eg: `_GNU_SOURCE` is often required for some symbols to be exposed + on Linux, and it should be passed via `args` keyword argument). - name: _no_builtin_args returns: void diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py index 7397321..8b6efd2 100644 --- a/mesonbuild/interpreter/compiler.py +++ b/mesonbuild/interpreter/compiler.py @@ -142,7 +142,13 @@ _INCLUDE_DIRS_KW: KwargInfo[T.List[build.IncludeDirs]] = KwargInfo( default=[], listify=True, ) -_PREFIX_KW = KwargInfo('prefix', str, default='') +_PREFIX_KW: KwargInfo[str] = KwargInfo( + 'prefix', + (str, ContainerTypeInfo(list, str)), + default='', + since_values={list: '1.0.0'}, + convertor=lambda x: '\n'.join(x) if isinstance(x, list) else x) + _NO_BUILTIN_ARGS_KW = KwargInfo('no_builtin_args', bool, default=False) _NAME_KW = KwargInfo('name', str, default='') |