interpreter: compiler: Allow array for the prefix kwarg

pull/11146/head
Marvin Scholz 2 years ago committed by Xavier Claessens
parent cee7ecde3d
commit 85a58f12f0
  1. 18
      docs/markdown/snippets/compiler_prefix_property_array.md
  2. 12
      docs/yaml/objects/compiler.yaml
  3. 8
      mesonbuild/interpreter/compiler.py

@ -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>'])
```

@ -78,13 +78,15 @@ methods:
description: You have found a bug if you can see this! description: You have found a bug if you can see this!
kwargs: kwargs:
prefix: prefix:
type: str type: str | list[str]
description: | description: |
Used to add `#include`s and other things that are required Used to add `#include`s and other things that are required
for the symbol to be declared. System definitions should be for the symbol to be declared. Since 1.0.0 an array is accepted
passed via compiler args (eg: `_GNU_SOURCE` is often required for too. When an array is passed, the items are concatenated together
some symbols to be exposed on Linux, and it should be passed via separated by a newline.
`args` keyword argument). 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 - name: _no_builtin_args
returns: void returns: void

@ -142,7 +142,13 @@ _INCLUDE_DIRS_KW: KwargInfo[T.List[build.IncludeDirs]] = KwargInfo(
default=[], default=[],
listify=True, 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) _NO_BUILTIN_ARGS_KW = KwargInfo('no_builtin_args', bool, default=False)
_NAME_KW = KwargInfo('name', str, default='') _NAME_KW = KwargInfo('name', str, default='')

Loading…
Cancel
Save