Debian Codegraph @

mesonbuild/interpreter/type_checking.py

raw
1 # SPDX-License-Identifier: Apache-2.0
2 # Copyright © 2021-2025 Intel Corporation
3
4 """Helpers for strict type checking."""
5
6 from __future__ import annotations
7 import itertools, os, re
8 import typing as T
9
10 from .. import compilers
11 from ..build import (CustomTarget, BuildTarget,
12 CustomTargetIndex, ExtractedObjects, GeneratedList, IncludeDirs, LocalProgram,
13 BothLibraries, SharedLibrary, StaticLibrary, Jar, Executable, StructuredSources)
14 from ..options import OptionKey
15 from ..dependencies import Dependency, DependencyMethods, InternalDependency
16 from ..interpreterbase import Feature
17 from ..interpreterbase.decorators import KwargInfo, ContainerTypeInfo, FeatureBroken, FeatureDeprecated
18 from ..mesonlib import (File, FileMode, MachineChoice, has_path_sep, listify, stringlistify,
19 EnvironmentVariables)
20 from ..programs import Program, ExternalProgram
21
22 # Helper definition for type checks that are `Optional[T]`
23 NoneType: T.Type[None] = type(None)
24
25 if T.TYPE_CHECKING:
26 from typing_extensions import Literal
27
28 from .kwargs import CustomTargetInputs
29 from ..build import ObjectTypes, GeneratedTypes, CommandTypes, TargetSources
30 from ..interpreterbase import TYPE_var
31 from ..options import ElementaryOptionValues
32 from ..mesonlib import EnvInitValueType
33 from ..interpreterbase.decorators import FeatureCheckBase
34
35 FullEnvInitValueType = T.Union[EnvironmentVariables, T.List[str], T.List[T.List[str]], EnvInitValueType, str, None]
36 PkgConfigDefineType = T.Optional[T.Tuple[T.Tuple[str, str], ...]]
37 SourcesVarargsType = T.List[T.Union[str, File, GeneratedTypes, StructuredSources, ExtractedObjects, BuildTarget]]
38
39
40 def in_set_validator(choices: T.Set[str]) -> T.Callable[[str], T.Optional[str]]:
41 """Check that the choice given was one of the given set."""
42
43 def inner(check: str) -> T.Optional[str]:
44 if check not in choices:
45 return f"must be one of {', '.join(sorted(choices))}, not {check}"
46 return None
47
48 return inner
49
50
51 def _language_validator(l: T.List[str]) -> T.Optional[str]:
52 """Validate language keyword argument.
53
54 Particularly for functions like `add_compiler()`, and `add_*_args()`
55 """
56 diff = {a.lower() for a in l}.difference(compilers.all_languages)
57 if diff:
58 return f'unknown languages: {", ".join(diff)}'
59 return None
60
61
62 def _install_mode_validator(mode: T.List[T.Union[str, bool, int]]) -> T.Optional[str]:
63 """Validate the `install_mode` keyword argument.
64
65 This is a rather odd thing, it's a scalar, or an array of 3 values in the form:
66 [(str | False), (str | int | False) = False, (str | int | False) = False]
67 where the second and third components are not required and default to False.
68 """
69 if not mode:
70 return None
71 if True in mode:
72 return 'components can only be permission strings, numbers, or False'
73 if len(mode) > 3:
74 return 'may have at most 3 elements'
75
76 perms = mode[0]
77 if not isinstance(perms, (str, bool)):
78 return 'first component must be a permissions string or False'
79
80 if isinstance(perms, str):
81 if not len(perms) == 9:
82 return ('permissions string must be exactly 9 characters in the form rwxr-xr-x,'
83 f' got {len(perms)}')
84 for i in [0, 3, 6]:
85 if perms[i] not in {'-', 'r'}:
86 return f'permissions character {i+1} must be "-" or "r", not {perms[i]}'
87 for i in [1, 4, 7]:
88 if perms[i] not in {'-', 'w'}:
89 return f'permissions character {i+1} must be "-" or "w", not {perms[i]}'
90 for i in [2, 5]:
91 if perms[i] not in {'-', 'x', 's', 'S'}:
92 return f'permissions character {i+1} must be "-", "s", "S", or "x", not {perms[i]}'
93 if perms[8] not in {'-', 'x', 't', 'T'}:
94 return f'permission character 9 must be "-", "t", "T", or "x", not {perms[8]}'
95
96 if len(mode) >= 2 and not isinstance(mode[1], (int, str, bool)):
97 return 'second component can only be a string, number, or False'
98 if len(mode) >= 3 and not isinstance(mode[2], (int, str, bool)):
99 return 'third component can only be a string, number, or False'
100
101 return None
102
103
104 def _install_mode_convertor(mode: T.Optional[T.List[T.Union[str, bool, int]]]) -> FileMode:
105 """Convert the DSL form of the `install_mode` keyword argument to `FileMode`"""
106
107 if not mode:
108 return FileMode()
109
110 # This has already been validated by the validator. False denotes "use
111 # default". mypy is totally incapable of understanding it, because
112 # generators clobber types via homogeneous return. But also we *must*
113 # convert the first element different from the rest
114 m1 = mode[0] if isinstance(mode[0], str) else None
115 rest = (m if isinstance(m, (str, int)) else None for m in mode[1:])
116
117 return FileMode(m1, *rest)
118
119
120 def _lower_strlist(input: T.List[str]) -> T.List[str]:
121 """Lower a list of strings.
122
123 mypy (but not pyright) gets confused about using a lambda as the convertor function
124 """
125 return [i.lower() for i in input]
126
127
128 def _validate_shlib_version(val: T.Optional[str]) -> T.Optional[str]:
129 if val is not None and not re.fullmatch(r'[0-9]+(\.[0-9]+){0,2}', val):
130 return (f'Invalid Shared library version "{val}". '
131 'Must be of the form X.Y.Z where all three are numbers. Y and Z are optional.')
132 return None
133
134
135 def variables_validator(contents: T.Union[str, T.List[str], T.Dict[str, str]]) -> T.Optional[str]:
136 if isinstance(contents, str):
137 contents = [contents]
138 if isinstance(contents, dict):
139 variables = contents
140 else:
141 variables = {}
142 for v in contents:
143 try:
144 key, val = v.split('=', 1)
145 except ValueError:
146 return f'variable {v!r} must have a value separated by equals sign.'
147 variables[key.strip()] = val.strip()
148 for k, v in variables.items():
149 if not k:
150 return 'empty variable name'
151 if any(c.isspace() for c in k):
152 return f'invalid whitespace in variable name {k!r}'
153 return None
154
155
156 def variables_convertor(contents: T.Union[str, T.List[str], T.Dict[str, str]]) -> T.Dict[str, str]:
157 if isinstance(contents, str):
158 contents = [contents]
159 if isinstance(contents, dict):
160 return contents
161 variables = {}
162 for v in contents:
163 key, val = v.split('=', 1)
164 variables[key.strip()] = val.strip()
165 return variables
166
167
168 NATIVE_KW = KwargInfo(
169 'native', bool,
170 default=False,
171 convertor=lambda n: MachineChoice.BUILD if n else MachineChoice.HOST)
172
173 LANGUAGE_KW = KwargInfo(
174 'language', ContainerTypeInfo(list, str, allow_empty=False),
175 listify=True,
176 required=True,
177 validator=_language_validator,
178 convertor=_lower_strlist)
179
180 INSTALL_MODE_KW: KwargInfo[T.List[T.Union[str, bool, int]]] = KwargInfo(
181 'install_mode',
182 ContainerTypeInfo(list, (str, bool, int)),
183 listify=True,
184 default=[],
185 validator=_install_mode_validator,
186 convertor=_install_mode_convertor,
187 )
188
189 REQUIRED_KW: KwargInfo[T.Union[bool, Feature]] = KwargInfo(
190 'required',
191 (bool, Feature),
192 default=True,
193 # TODO: extract_required_kwarg could be converted to a convertor
194 )
195
196 DISABLER_KW: KwargInfo[bool] = KwargInfo('disabler', bool, default=False)
197
198 def _env_validator(value: T.Union[EnvironmentVariables, T.List['TYPE_var'], T.Dict[str, 'TYPE_var'], str, None],
199 only_dict_str: bool = True) -> T.Optional[str]:
200 def _splitter(v: str) -> T.Optional[str]:
201 split = v.split('=', 1)
202 if len(split) == 1:
203 return f'"{v}" is not two string values separated by an "="'
204 return None
205
206 if isinstance(value, str):
207 v = _splitter(value)
208 if v is not None:
209 return v
210 elif isinstance(value, list):
211 for i in listify(value):
212 if not isinstance(i, str):
213 return f"All array elements must be a string, not {i!r}"
214 v = _splitter(i)
215 if v is not None:
216 return v
217 elif isinstance(value, dict):
218 # We don't need to spilt here, just do the type checking
219 for k, dv in value.items():
220 if only_dict_str:
221 if any(i for i in listify(dv) if not isinstance(i, str)):
222 return f"Dictionary element {k} must be a string or list of strings not {dv!r}"
223 elif isinstance(dv, list):
224 if any(not isinstance(i, str) for i in dv):
225 return f"Dictionary element {k} must be a string, bool, integer or list of strings, not {dv!r}"
226 elif not isinstance(dv, (str, bool, int)):
227 return f"Dictionary element {k} must be a string, bool, integer or list of strings, not {dv!r}"
228 # We know that otherwise we have an EnvironmentVariables object or None, and
229 # we're okay at this point
230 return None
231
232 def _options_validator(value: T.Union[EnvironmentVariables, T.List['TYPE_var'], T.Dict[str, 'TYPE_var'], str, None]) -> T.Optional[str]:
233 # Reusing the env validator is a little overkill, but nicer than duplicating the code
234 return _env_validator(value, only_dict_str=False)
235
236 def split_equal_string(input: str) -> T.Tuple[str, str]:
237 """Split a string in the form `x=y`
238
239 This assumes that the string has already been validated to split properly.
240 """
241 a, b = input.split('=', 1)
242 return (a, b)
243
244 # Split _env_convertor() and env_convertor_with_method() to make mypy happy.
245 # It does not want extra arguments in KwargInfo convertor callable.
246 def env_convertor_with_method(value: FullEnvInitValueType,
247 init_method: Literal['set', 'prepend', 'append'] = 'set',
248 separator: str = os.pathsep) -> EnvironmentVariables:
249 if isinstance(value, str):
250 return EnvironmentVariables(dict([split_equal_string(value)]), init_method, separator)
251 elif isinstance(value, list):
252 return EnvironmentVariables(dict(split_equal_string(v) for v in listify(value)), init_method, separator)
253 elif isinstance(value, dict):
254 return EnvironmentVariables({k: listify(dv) for k, dv in value.items()}, init_method, separator)
255 elif value is None:
256 return EnvironmentVariables()
257 return value
258
259 def _env_convertor(value: FullEnvInitValueType) -> EnvironmentVariables:
260 return env_convertor_with_method(value)
261
262 ENV_KW: KwargInfo[T.Union[EnvironmentVariables, T.List, T.Dict, str, None]] = KwargInfo(
263 'env',
264 (EnvironmentVariables, list, dict, str, NoneType),
265 validator=_env_validator,
266 convertor=_env_convertor,
267 )
268
269 DEPFILE_KW: KwargInfo[T.Optional[str]] = KwargInfo(
270 'depfile',
271 (str, type(None)),
272 validator=lambda x: 'Depfile must be a plain filename with a subdirectory' if has_path_sep(x) else None
273 )
274
275 DEPENDS_KW: KwargInfo[T.List[T.Union[BuildTarget, CustomTarget, CustomTargetIndex, Program]]] = KwargInfo(
276 'depends',
277 ContainerTypeInfo(list, (BuildTarget, CustomTarget, CustomTargetIndex, Program)),
278 listify=True,
279 default=[],
280 since_values={CustomTargetIndex: '1.5.0', ExternalProgram: '1.12.0'},
281 )
282
283 DEPEND_FILES_KW: KwargInfo[T.List[T.Union[str, File]]] = KwargInfo(
284 'depend_files',
285 ContainerTypeInfo(list, (File, str)),
286 listify=True,
287 default=[],
288 )
289
290 COMMAND_KW: KwargInfo[T.List[T.Union[str, CommandTypes, Program, File]]] = KwargInfo(
291 'command',
292 ContainerTypeInfo(list, (str, BuildTarget, CustomTarget, CustomTargetIndex, Program, File), allow_empty=False),
293 required=True,
294 listify=True,
295 default=[],
296 )
297
298
299 def _override_options_convertor(raw: T.Union[str, T.List[str], T.Dict[str, ElementaryOptionValues]]) -> T.Dict[str, ElementaryOptionValues]:
300 if isinstance(raw, dict):
301 return raw
302 raw = stringlistify(raw)
303 output: T.Dict[str, ElementaryOptionValues] = {}
304 for each in raw:
305 k, v = split_equal_string(each)
306 output[k] = v
307 return output
308
309 OVERRIDE_OPTIONS_KW: KwargInfo[T.Union[str, T.List[str], T.Dict[str, ElementaryOptionValues]]] = KwargInfo(
310 'override_options',
311 (str, ContainerTypeInfo(list, str), ContainerTypeInfo(dict, (str, int, bool, list))),
312 default={},
313 validator=_options_validator,
314 convertor=_override_options_convertor,
315 since_values={dict: '1.2.0'},
316 )
317
318
319 def _output_validator(outputs: T.List[str]) -> T.Optional[str]:
320 output_set = set(outputs)
321 if len(output_set) != len(outputs):
322 seen = set()
323 for el in outputs:
324 if el in seen:
325 return f"contains {el!r} multiple times, but no duplicates are allowed."
326 seen.add(el)
327 for i in outputs:
328 if i == '':
329 return 'Output must not be empty.'
330 elif i.strip() == '':
331 return 'Output must not consist only of whitespace.'
332 elif has_path_sep(i):
333 return f'Output {i!r} must not contain a path segment.'
334 elif '@INPUT' in i:
335 return f'output {i!r} contains "@INPUT", which is invalid. Did you mean "@PLAINNAME@" or "@BASENAME@?'
336
337 return None
338
339 MULTI_OUTPUT_KW: KwargInfo[T.List[str]] = KwargInfo(
340 'output',
341 ContainerTypeInfo(list, str, allow_empty=False),
342 listify=True,
343 required=True,
344 default=[],
345 validator=_output_validator,
346 )
347
348 OUTPUT_KW: KwargInfo[str] = KwargInfo(
349 'output',
350 str,
351 required=True,
352 validator=lambda x: _output_validator([x])
353 )
354
355 def _local_program_convertor(raw: T.List[T.Union[str, File, BuildTarget, GeneratedTypes, ExtractedObjects, Program]]) -> T.List[CustomTargetInputs]:
356 result: T.List[CustomTargetInputs] = []
357 for i in raw:
358 if isinstance(i, LocalProgram):
359 result.append(i.get_target())
360 else:
361 result.append(i)
362 return result
363
364 CT_INPUT_KW: KwargInfo[T.List[T.Union[str, File, BuildTarget, GeneratedTypes, ExtractedObjects, Program]]] = KwargInfo(
365 'input',
366 ContainerTypeInfo(list, (str, File, BuildTarget, CustomTarget, CustomTargetIndex, ExtractedObjects, GeneratedList, Program)),
367 listify=True,
368 default=[],
369 convertor=_local_program_convertor,
370 since_values={ExternalProgram: '1.12.0'},
371 )
372
373 CT_INSTALL_TAG_KW: KwargInfo[T.List[T.Union[str, bool]]] = KwargInfo(
374 'install_tag',
375 ContainerTypeInfo(list, (str, bool)),
376 listify=True,
377 default=[],
378 since='0.60.0',
379 convertor=lambda x: [y if isinstance(y, str) else None for y in x],
380 )
381
382 INSTALL_TAG_KW: KwargInfo[T.Optional[str]] = KwargInfo('install_tag', (str, NoneType))
383
384 INSTALL_FOLLOW_SYMLINKS: KwargInfo[T.Optional[bool]] = KwargInfo(
385 'follow_symlinks',
386 (bool, NoneType),
387 since='1.3.0',
388 )
389
390 INSTALL_KW = KwargInfo('install', bool, default=False)
391
392 CT_INSTALL_DIR_KW: KwargInfo[T.List[T.Union[str, Literal[False]]]] = KwargInfo(
393 'install_dir',
394 ContainerTypeInfo(list, (str, bool)),
395 listify=True,
396 default=[],
397 validator=lambda x: 'must be `false` if boolean' if True in x else None,
398 )
399
400 CT_BUILD_BY_DEFAULT: KwargInfo[T.Optional[bool]] = KwargInfo('build_by_default', (bool, type(None)), since='0.40.0')
401
402 CT_BUILD_ALWAYS: KwargInfo[T.Optional[bool]] = KwargInfo(
403 'build_always', (bool, NoneType),
404 deprecated='0.47.0',
405 deprecated_message='combine build_by_default and build_always_stale instead.',
406 )
407
408 CT_BUILD_ALWAYS_STALE: KwargInfo[T.Optional[bool]] = KwargInfo(
409 'build_always_stale', (bool, NoneType),
410 since='0.47.0',
411 )
412
413 INSTALL_DIR_KW: KwargInfo[T.Optional[str]] = KwargInfo('install_dir', (str, NoneType))
414
415 INCLUDE_DIRECTORIES: KwargInfo[T.List[T.Union[str, IncludeDirs]]] = KwargInfo(
416 'include_directories',
417 ContainerTypeInfo(list, (str, IncludeDirs)),
418 listify=True,
419 default=[],
420 )
421
422 def _default_options_convertor(raw: T.Union[str, T.List[str], T.Dict[str, ElementaryOptionValues]]) -> T.Dict[OptionKey, ElementaryOptionValues]:
423 d = _override_options_convertor(raw)
424 return {OptionKey.from_string(k): v for k, v in d.items()}
425
426 DEFAULT_OPTIONS = OVERRIDE_OPTIONS_KW.evolve(
427 name='default_options',
428 convertor=_default_options_convertor)
429
430 ENV_METHOD_KW = KwargInfo('method', str, default='set', since='0.62.0',
431 validator=in_set_validator({'set', 'prepend', 'append'}))
432
433 ENV_SEPARATOR_KW = KwargInfo('separator', str, default=os.pathsep)
434
435 DEPENDENCIES_KW: KwargInfo[T.List[Dependency]] = KwargInfo(
436 'dependencies',
437 # InternalDependency is a subclass of Dependency, but we want to
438 # print it in error messages
439 ContainerTypeInfo(list, (Dependency, InternalDependency)),
440 listify=True,
441 default=[],
442 extra_types={
443 BuildTarget: lambda arg: f'Tried to use a build_target "{T.cast("BuildTarget", arg).name}" as a dependency. This should be in `link_with` or `link_whole` instead.',
444 },
445 as_default=[('', ('1.11.1', "Replace an empty string with an empty array: `dependencies : ''` -> `dependencies : []`"))],
446 )
447
448 D_MODULE_VERSIONS_KW: KwargInfo[T.List[T.Union[str, int]]] = KwargInfo(
449 'd_module_versions',
450 ContainerTypeInfo(list, (str, int)),
451 listify=True,
452 default=[],
453 )
454
455 _LINK_WITH_ERROR = 'Dependency and external_library objects must go in the "dependencies" keyword argument'
456
457 def _link_with_validator(values: T.List[T.Union[BothLibraries, SharedLibrary, StaticLibrary,
458 CustomTarget, CustomTargetIndex, Jar, Executable,
459 ]]
460 ) -> T.Optional[str]:
461 for value in values:
462 if not value.is_linkable_target():
463 return f'Link target "{value!s}" is not linkable'
464 return None
465
466 # Allow Dependency for the better error message? But then in other cases it will list this as one of the allowed types!
467 LINK_WITH_KW: KwargInfo[T.List[T.Union[BothLibraries, SharedLibrary, StaticLibrary, CustomTarget, CustomTargetIndex, Jar, Executable]]] = KwargInfo(
468 'link_with',
469 ContainerTypeInfo(list, (BothLibraries, SharedLibrary, StaticLibrary, CustomTarget, CustomTargetIndex, Jar, Executable)),
470 listify=True,
471 default=[],
472 extra_types={Dependency: lambda _: _LINK_WITH_ERROR},
473 validator=_link_with_validator,
474 )
475
476 def link_whole_validator(values: T.List[T.Union[StaticLibrary, CustomTarget, CustomTargetIndex]]) -> T.Optional[str]:
477 for l in values:
478 if isinstance(l, (CustomTarget, CustomTargetIndex)) and l.links_dynamically():
479 return f'{type(l).__name__} returning a shared library is not allowed'
480 if not l.is_linkable_target():
481 return f'Link target "{l!s}" is not linkable'
482 return None
483
484 LINK_WHOLE_KW: KwargInfo[T.List[T.Union[BothLibraries, StaticLibrary, CustomTarget, CustomTargetIndex]]] = KwargInfo(
485 'link_whole',
486 ContainerTypeInfo(list, (BothLibraries, StaticLibrary, CustomTarget, CustomTargetIndex)),
487 listify=True,
488 default=[],
489 validator=link_whole_validator,
490 extra_types={Dependency: lambda _: _LINK_WITH_ERROR}
491 )
492
493 DEPENDENCY_SOURCES_KW: KwargInfo[T.List[str | TargetSources]] = KwargInfo(
494 'sources',
495 ContainerTypeInfo(list, (str, File, CustomTarget, CustomTargetIndex, GeneratedList)),
496 listify=True,
497 default=[],
498 )
499
500 SOURCES_VARARGS = (str, File, CustomTarget, CustomTargetIndex, GeneratedList, StructuredSources, ExtractedObjects, BuildTarget)
501
502 BT_SOURCES_KW: KwargInfo[SourcesVarargsType] = KwargInfo(
503 'sources',
504 (NoneType, ContainerTypeInfo(list, SOURCES_VARARGS)),
505 listify=True,
506 default=[],
507 )
508
509 VARIABLES_KW: KwargInfo[T.Dict[str, str]] = KwargInfo(
510 'variables',
511 # str is listified by validator/convertor, cannot use listify=True here because
512 # that would listify dict too.
513 (str, ContainerTypeInfo(list, str), ContainerTypeInfo(dict, str)), # type: ignore
514 validator=variables_validator,
515 convertor=variables_convertor,
516 default={},
517 )
518
519 PRESERVE_PATH_KW: KwargInfo[bool] = KwargInfo('preserve_path', bool, default=False, since='0.63.0')
520
521 def suite_convertor(suite: T.List[str]) -> T.List[str]:
522 # Ensure we always have at least one suite.
523 if not suite:
524 return ['']
525 return suite
526
527 TEST_KWS_NO_ARGS: T.List[KwargInfo] = [
528 KwargInfo('should_fail', (bool, NoneType), deprecated='1.11.0', deprecated_message='Use expected_fail instead of should_fail'),
529 KwargInfo('expected_fail', (bool, NoneType), since='1.11.0'),
530 KwargInfo('expected_exitcode', (int, NoneType), since='1.11.0'),
531 KwargInfo('timeout', int, default=30),
532 KwargInfo('workdir', (str, NoneType), default=None,
533 validator=lambda x: 'must be an absolute path' if not os.path.isabs(x) else None),
534 KwargInfo('protocol', str,
535 default='exitcode',
536 validator=in_set_validator({'exitcode', 'tap', 'gtest', 'rust'}),
537 since_values={'gtest': '0.55.0', 'rust': '0.57.0'}),
538 KwargInfo('priority', int, default=0, since='0.52.0'),
539 # TODO: env needs reworks of the way the environment variable holder itself works probably
540 ENV_KW,
541 DEPENDS_KW.evolve(since='0.46.0'),
542 KwargInfo('suite', ContainerTypeInfo(list, str), listify=True, default=[], convertor=suite_convertor),
543 KwargInfo('verbose', bool, default=False, since='0.62.0'),
544 ]
545
546 TEST_KWS: T.List[KwargInfo] = TEST_KWS_NO_ARGS + [
547 KwargInfo('args', ContainerTypeInfo(list, (str, File, BuildTarget, CustomTarget, CustomTargetIndex, Program)),
548 listify=True, default=[]),
549 ]
550
551 # Cannot have a default value because we need to check that rust_crate_type and
552 # rust_abi are mutually exclusive.
553 RUST_CRATE_TYPE_KW: KwargInfo[T.Union[str, None]] = KwargInfo(
554 'rust_crate_type', (str, NoneType),
555 since='0.42.0',
556 since_values={'proc-macro': '0.62.0'},
557 deprecated='1.3.0',
558 deprecated_message='Use rust_abi or rust.proc_macro() instead.',
559 validator=in_set_validator({'bin', 'lib', 'rlib', 'dylib', 'cdylib', 'staticlib', 'proc-macro'}))
560
561 RUST_ABI_KW: KwargInfo[T.Union[str, None]] = KwargInfo(
562 'rust_abi', (str, NoneType),
563 since='1.3.0',
564 validator=in_set_validator({'rust', 'c'}))
565
566 # this is implicitly an extra link_depends and thus shares the same type
567 _VS_MODULE_DEFS_KW: KwargInfo[T.Optional[T.Union[str, File, CustomTarget, CustomTargetIndex]]] = KwargInfo(
568 'vs_module_defs',
569 (str, File, CustomTarget, CustomTargetIndex, NoneType),
570 since_values={CustomTargetIndex: '1.3.0'}
571 )
572
573 _BASE_LANG_KW: KwargInfo[T.List[T.Union[str, File]]] = KwargInfo(
574 'UNKNOWN',
575 ContainerTypeInfo(list, (str, File)),
576 listify=True,
577 default=[],
578 )
579
580 _LANGUAGE_KWS: T.List[KwargInfo[T.List[str | File]]] = [
581 _BASE_LANG_KW.evolve(name=f'{lang}_args')
582 for lang in compilers.all_languages - {'rust', 'vala', 'java'}
583 ]
584 # Cannot use _BASE_LANG_KW here because Vala is special for types
585 _LANGUAGE_KWS.append(KwargInfo(
586 'vala_args', ContainerTypeInfo(list, (str, File)), listify=True, default=[]))
587 _LANGUAGE_KWS.append(_BASE_LANG_KW.evolve(name='rust_args', since='0.41.0'))
588
589 # We need this deprecated values more than the non-deprecated values. So we'll evolve them out elsewhere.
590 _JAVA_LANG_KW: KwargInfo[T.List[str | File]] = _BASE_LANG_KW.evolve(
591 name='java_args',
592 deprecated='1.3.0',
593 deprecated_message='This does not, and never has, done anything. It should be removed'
594 )
595
596 BUILD_SUBDIR_KW: KwargInfo[str] = KwargInfo(
597 'build_subdir',
598 str,
599 default='',
600 since='1.10.0'
601 )
602
603 def _objects_validator(vals: T.List[ObjectTypes]) -> T.Optional[str]:
604 non_objects: T.List[str] = []
605
606 for val in vals:
607 if isinstance(val, (str, File, ExtractedObjects)):
608 continue
609 else:
610 non_objects.extend(o for o in val.get_outputs() if not compilers.is_object(o))
611
612 if non_objects:
613 return f'{", ".join(non_objects)!r} are not objects'
614
615 return None
616
617
618 def _target_install_feature_validator(val: object) -> T.Iterable[FeatureCheckBase]:
619 # due to lack of type checking, these are "allowed" for legacy reasons
620 if not isinstance(val, bool):
621 yield FeatureBroken('install kwarg with non-boolean value', '1.3.0',
622 'This was never intended to work, and is essentially the same as using `install: true` regardless of value.')
623
624
625 def _target_install_convertor(val: object) -> bool:
626 return bool(val)
627
628
629 def _extra_files_validator(args: T.List[T.Union[File, str]]) -> T.Optional[str]:
630 generated = [a for a in args if isinstance(a, File) and a.is_built]
631 if generated:
632 return 'extra_files contains generated files: {}'.format(', '.join(f"{f.fname}" for f in generated))
633 return None
634
635
636 def _bt_install_dir_deprecated(args: T.List[T.Union[str, bool]]) -> T.Iterator[FeatureCheckBase]:
637 if len(args) > 1:
638 yield FeatureDeprecated('passing more than one argument to install_dir', '1.11.0',
639 'use the install_vala_* arguments instead')
640
641
642 # Applies to all build_target like classes
643 _ALL_TARGET_KWS: T.List[KwargInfo] = [
644 OVERRIDE_OPTIONS_KW,
645 KwargInfo('build_by_default', bool, default=True, since='0.38.0'),
646 DEPENDENCIES_KW,
647 KwargInfo(
648 'extra_files',
649 ContainerTypeInfo(list, (str, File)),
650 default=[],
651 listify=True,
652 validator=_extra_files_validator,
653 ),
654 INCLUDE_DIRECTORIES.evolve(since_values={ContainerTypeInfo(list, str): '0.50.0'}),
655 KwargInfo(
656 'install',
657 object,
658 default=False,
659 convertor=_target_install_convertor,
660 feature_validator=_target_install_feature_validator,
661 ),
662 INSTALL_MODE_KW,
663 INSTALL_TAG_KW,
664 KwargInfo(
665 'install_dir',
666 ContainerTypeInfo(list, (str, bool)),
667 default=[],
668 listify=True,
669 feature_validator=_bt_install_dir_deprecated,
670 ),
671 KwargInfo('implicit_include_directories', bool, default=True, since='0.42.0'),
672 LINK_WITH_KW.evolve(
673 as_default=[('', ('1.11.0', "Replace an empty string with an empty array: `link_with : ''` -> `link_with : []`"))],
674 ),
675 NATIVE_KW,
676 KwargInfo('resources', ContainerTypeInfo(list, str), default=[], listify=True),
677 KwargInfo(
678 'objects',
679 ContainerTypeInfo(list, (str, File, CustomTarget, CustomTargetIndex, GeneratedList, ExtractedObjects)),
680 listify=True,
681 default=[],
682 validator=_objects_validator,
683 since_values={
684 ContainerTypeInfo(list, (GeneratedList, CustomTarget, CustomTargetIndex)):
685 ('1.1.0', 'generated sources as positional "objects" arguments')
686 },
687 ),
688 BUILD_SUBDIR_KW,
689 ]
690
691
692 def _name_validator(arg: T.Optional[T.Union[str, T.List]]) -> T.Optional[str]:
693 if isinstance(arg, list) and arg:
694 return 'must be empty when passed as an array to signify the default value.'
695 return None
696
697
698 def _name_suffix_validator(arg: T.Optional[T.Union[str, T.List]]) -> T.Optional[str]:
699 if arg == '':
700 return 'must not be a empty string. An empty array may be passed if you want Meson to use the default behavior.'
701 return _name_validator(arg)
702
703
704 _NAME_PREFIX_KW: KwargInfo[T.Optional[T.Union[str, T.List]]] = KwargInfo(
705 'name_prefix',
706 (str, NoneType, list),
707 validator=_name_validator,
708 convertor=lambda x: None if isinstance(x, list) else x,
709 deprecated_values={list: ('1.12.0', 'use the `default()` function instead')},
710 )
711
712
713 def _pch_validator(args: T.List[str]) -> T.Optional[str]:
714 num_args = len(args)
715 if num_args == 1:
716 if not compilers.is_header(args[0]):
717 return f'PCH argument {args[0]} is not a header.'
718 elif num_args == 2:
719 if compilers.is_header(args[0]):
720 if not compilers.is_source(args[1]):
721 return 'PCH definition must contain one header and at most one source.'
722 elif compilers.is_source(args[0]):
723 if not compilers.is_header(args[1]):
724 return 'PCH definition must contain one header and at most one source.'
725 else:
726 return f'PCH argument {args[0]} has neither a known header or code extension.'
727
728 if os.path.dirname(args[0]) != os.path.dirname(args[1]):
729 return 'PCH files must be stored in the same folder.'
730 elif num_args > 2:
731 return 'A maximum of two elements are allowed for PCH arguments'
732 if num_args >= 1 and not has_path_sep(args[0]):
733 return f'PCH header {args[0]} must not be in the same directory as source files'
734 if num_args == 2 and not has_path_sep(args[1]):
735 return f'PCH source {args[0]} must not be in the same directory as source files'
736 return None
737
738
739 def _pch_feature_validator(args: T.List[str]) -> T.Iterable[FeatureCheckBase]:
740 if len(args) > 1:
741 yield FeatureDeprecated('PCH source files', '0.50.0', 'Only a single header file should be used.')
742
743
744 def _pch_convertor(args: T.List[str]) -> T.Optional[T.Tuple[str, T.Optional[str]]]:
745 num_args = len(args)
746
747 if num_args == 1:
748 return (args[0], None)
749
750 if num_args == 2:
751 if compilers.is_source(args[0]):
752 # Flip so that we always have [header, src]
753 return (args[1], args[0])
754 return (args[0], args[1])
755
756 return None
757
758
759 _PCH_ARGS: KwargInfo[T.List[str]] = KwargInfo(
760 'pch',
761 ContainerTypeInfo(list, str),
762 listify=True,
763 default=[],
764 validator=_pch_validator,
765 feature_validator=_pch_feature_validator,
766 convertor=_pch_convertor,
767 )
768
769
770 LINK_ARGS_KW: KwargInfo[T.List[str]] = KwargInfo(
771 'link_args',
772 ContainerTypeInfo(list, str),
773 default=[],
774 listify=True,
775 as_default=[('', ('1.10.1', "Replace an empty string with an empty array: `link_args : ''` -> `link_args : []`"))],
776 )
777
778
779 # Applies to all build_target classes except jar
780 _BUILD_TARGET_KWS: T.List[KwargInfo] = [
781 *_ALL_TARGET_KWS,
782 *_LANGUAGE_KWS,
783 BT_SOURCES_KW,
784 INCLUDE_DIRECTORIES.evolve(name='d_import_dirs'),
785 LINK_ARGS_KW,
786 LINK_WHOLE_KW.evolve(
787 as_default=[('', ('1.11.0', "Replace an empty string with an empty array: `link_whole : ''` -> `link_whole : []`"))],
788 ),
789 _NAME_PREFIX_KW,
790 _NAME_PREFIX_KW.evolve(name='name_suffix', validator=_name_suffix_validator),
791 RUST_CRATE_TYPE_KW,
792 _PCH_ARGS.evolve(name='c_pch'),
793 _PCH_ARGS.evolve(name='cpp_pch'),
794 KwargInfo('d_debug', ContainerTypeInfo(list, (str, int)), default=[], listify=True),
795 D_MODULE_VERSIONS_KW,
796 KwargInfo('d_unittest', bool, default=False),
797 KwargInfo(
798 'rust_dependency_map',
799 ContainerTypeInfo(dict, str),
800 default={},
801 since='1.2.0',
802 ),
803 KwargInfo('swift_interoperability_mode', str, default='c', validator=in_set_validator({'c', 'cpp'}), since='1.9.0'),
804 KwargInfo('swift_module_name', str, default='', since='1.9.0'),
805 KwargInfo('build_rpath', str, default='', since='0.42.0'),
806 KwargInfo(
807 'gnu_symbol_visibility',
808 str,
809 default='',
810 validator=in_set_validator({'', 'default', 'internal', 'hidden', 'protected', 'inlineshidden'}),
811 since='0.48.0',
812 ),
813 KwargInfo('install_rpath', str, default=''),
814 # FIXME: an old comment said that link_depends "doesn't handle generator()
815 # returned objects, since adding them as a link depends would inherently
816 # cause them to be generated twice, since the output needs to be passed
817 # to the ld_args and link_depends". Is this still true?
818 KwargInfo(
819 'link_depends',
820 ContainerTypeInfo(list, (str, File, CustomTarget, CustomTargetIndex, BuildTarget)),
821 default=[],
822 listify=True,
823 ),
824 KwargInfo(
825 'link_language',
826 (str, NoneType),
827 # Yes, neither mypy no pyright can figure out that `set[literal[str]]``
828 # is a subset of `set[str]`
829 validator=in_set_validator(T.cast('T.Set[str]', compilers.all_languages)),
830 since='0.51.0',
831 ),
832 KwargInfo('vala_gir', (str, NoneType)),
833 KwargInfo('install_vala_gir', (str, bool, NoneType), since='1.11.0'),
834 KwargInfo('vala_header', (str, NoneType)),
835 KwargInfo('install_vala_header', (str, bool, NoneType), since='1.11.0'),
836 KwargInfo('vala_vapi', (str, NoneType)),
837 KwargInfo(
838 'link_early_args',
839 (ContainerTypeInfo(list, str), NoneType),
840 listify=True,
841 default=[],
842 since='1.11.0',
843 ),
844 KwargInfo('install_vala_vapi', (str, bool, NoneType), since='1.11.0'),
845 ]
846
847 def _validate_win_subsystem(value: T.Optional[str]) -> T.Optional[str]:
848 if value is not None:
849 if re.fullmatch(r'(boot_application|console|efi_application|efi_boot_service_driver|efi_rom|efi_runtime_driver|native|posix|windows)(,\d+(\.\d+)?)?', value) is None:
850 return f'Invalid value for win_subsystem: {value}.'
851 return None
852
853 _WIN_SUBSYSTEM_KW: KwargInfo[T.Optional[str]] = KwargInfo(
854 'win_subsystem',
855 (str, NoneType),
856 convertor=lambda x: x.lower() if isinstance(x, str) else None,
857 validator=_validate_win_subsystem,
858 )
859
860
861 def _validate_darwin_versions(darwin_versions: T.List[T.Union[str, int]]) -> T.Optional[str]:
862 if len(darwin_versions) > 2:
863 return f"Must contain between 0 and 2 elements, not {len(darwin_versions)}"
864 if len(darwin_versions) == 1:
865 darwin_versions = 2 * darwin_versions
866 for v in darwin_versions:
867 if isinstance(v, int):
868 v = str(v)
869 if not re.fullmatch(r'[0-9]+(\.[0-9]+){0,2}', v):
870 return 'must be X.Y.Z where X, Y, Z are numbers, and Y and Z are optional'
871 try:
872 parts = v.split('.')
873 except ValueError:
874 return f'badly formed value: "{v}, not in X.Y.Z form'
875 if len(parts) in {1, 2, 3} and int(parts[0]) > 65535:
876 return 'must be X.Y.Z where X is [0, 65535] and Y, Z are optional'
877 if len(parts) in {2, 3} and int(parts[1]) > 255:
878 return 'must be X.Y.Z where Y is [0, 255] and Y, Z are optional'
879 if len(parts) == 3 and int(parts[2]) > 255:
880 return 'must be X.Y.Z where Z is [0, 255] and Y, Z are optional'
881 return None
882
883
884 def _convert_darwin_versions(val: T.List[T.Union[str, int]]) -> T.Optional[T.Tuple[str, str]]:
885 if not val:
886 return None
887 elif len(val) == 1:
888 v = str(val[0])
889 return (v, v)
890 return (str(val[0]), str(val[1]))
891
892
893 _DARWIN_VERSIONS_KW: KwargInfo[T.List[T.Union[str, int]]] = KwargInfo(
894 'darwin_versions',
895 ContainerTypeInfo(list, (str, int)),
896 default=[],
897 listify=True,
898 validator=_validate_darwin_versions,
899 convertor=_convert_darwin_versions,
900 since='0.48.0',
901 )
902
903 # Arguments exclusive to Executable. These are separated to make integrating
904 # them into build_target easier
905 EXCLUSIVE_EXECUTABLE_KWS: T.List[KwargInfo] = [
906 KwargInfo('export_dynamic', (bool, NoneType), since='0.45.0'),
907 KwargInfo('gui_app', (bool, NoneType), deprecated='0.56.0', deprecated_message="Use 'win_subsystem' instead"),
908 KwargInfo(
909 'implib',
910 (bool, str, NoneType),
911 since='0.42.0',
912 deprecated_values={
913 bool: ('1.10.0', 'Use "export_dynamic" keyword instead'),
914 },
915 ),
916 KwargInfo('pie', (bool, NoneType)),
917 KwargInfo(
918 'android_exe_type',
919 (str, NoneType),
920 validator=in_set_validator({'application', 'executable'}),
921 since='1.8.0'
922 ),
923 ]
924
925 # The total list of arguments used by Executable
926 EXECUTABLE_KWS = [
927 *_BUILD_TARGET_KWS,
928 *EXCLUSIVE_EXECUTABLE_KWS,
929 _VS_MODULE_DEFS_KW.evolve(since='1.3.0', since_values=None),
930 _WIN_SUBSYSTEM_KW,
931 _JAVA_LANG_KW,
932 ]
933
934 # Arguments exclusive to library types
935 _EXCLUSIVE_LIB_KWS: T.List[KwargInfo] = [
936 RUST_ABI_KW,
937 ]
938
939 # Arguments exclusive to StaticLibrary. These are separated to make integrating
940 # them into build_target easier
941 _EXCLUSIVE_STATIC_LIB_KWS: T.List[KwargInfo] = [
942 KwargInfo('prelink', bool, default=False, since='0.57.0'),
943 KwargInfo('pic', (bool, NoneType), since='0.36.0'),
944 ]
945
946 # The total list of arguments used by StaticLibrary
947 STATIC_LIB_KWS = [
948 *_BUILD_TARGET_KWS,
949 *_EXCLUSIVE_STATIC_LIB_KWS,
950 *_EXCLUSIVE_LIB_KWS,
951 _JAVA_LANG_KW,
952 ]
953
954 def _shortname_validator(shortname: T.Optional[str]) -> T.Optional[str]:
955 if shortname is not None and len(shortname) > 8:
956 return 'must have a maximum of 8 characters'
957 return None
958
959 # Arguments exclusive to SharedLibrary. These are separated to make integrating
960 # them into build_target easier
961 _EXCLUSIVE_SHARED_LIB_KWS: T.List[KwargInfo] = [
962 _DARWIN_VERSIONS_KW,
963 KwargInfo('soversion', (str, int, NoneType), convertor=lambda x: str(x) if x is not None else None),
964 KwargInfo('version', (str, NoneType), validator=_validate_shlib_version),
965 KwargInfo('shortname', (str, NoneType), since='1.10.0', validator=_shortname_validator),
966 ]
967
968 # The total list of arguments used by SharedLibrary
969 SHARED_LIB_KWS: T.List[KwargInfo] = [
970 *_BUILD_TARGET_KWS,
971 *_EXCLUSIVE_SHARED_LIB_KWS,
972 *_EXCLUSIVE_LIB_KWS,
973 _VS_MODULE_DEFS_KW,
974 _WIN_SUBSYSTEM_KW.evolve(since='1.12.0'),
975 _JAVA_LANG_KW,
976 ]
977
978 # Arguments exclusive to SharedModule. These are separated to make integrating
979 # them into build_target easier
980 _EXCLUSIVE_SHARED_MOD_KWS: T.List[KwargInfo] = []
981
982 # The total list of arguments used by SharedModule
983 SHARED_MOD_KWS = [
984 *_BUILD_TARGET_KWS,
985 *_EXCLUSIVE_SHARED_MOD_KWS,
986 *_EXCLUSIVE_LIB_KWS,
987 _VS_MODULE_DEFS_KW,
988 _WIN_SUBSYSTEM_KW.evolve(since='1.12.0'),
989 _JAVA_LANG_KW,
990 ]
991
992 # Arguments exclusive to JAR. These are separated to make integrating
993 # them into build_target easier
994 _EXCLUSIVE_JAR_KWS: T.List[KwargInfo] = [
995 KwargInfo('main_class', str, default=''),
996 KwargInfo('java_resources', (StructuredSources, NoneType), since='0.62.0'),
997 _JAVA_LANG_KW.evolve(deprecated=None, deprecated_message=None),
998 ]
999
1000 # The total list of arguments used by JAR
1001 JAR_KWS = [
1002 *_ALL_TARGET_KWS,
1003 *_EXCLUSIVE_JAR_KWS,
1004 KwargInfo(
1005 'sources',
1006 ContainerTypeInfo(list, (str, File, CustomTarget, CustomTargetIndex, GeneratedList, ExtractedObjects, BuildTarget)),
1007 listify=True,
1008 default=[],
1009 ),
1010 *[a.evolve(deprecated='1.3.0', deprecated_message='This argument has never done anything in jar(), and should be removed')
1011 for a in _LANGUAGE_KWS],
1012 ]
1013
1014 _SHARED_STATIC_ARGS: T.List[KwargInfo[T.List[str | File]]] = [
1015 *[l.evolve(name=l.name.replace('_', '_static_'), since='1.3.0')
1016 for l in _LANGUAGE_KWS],
1017 *[l.evolve(name=l.name.replace('_', '_shared_'), since='1.3.0')
1018 for l in _LANGUAGE_KWS],
1019 ]
1020
1021 # Arguments used by both_library and library
1022 LIBRARY_KWS = [
1023 *_BUILD_TARGET_KWS,
1024 *_EXCLUSIVE_LIB_KWS,
1025 *_EXCLUSIVE_SHARED_LIB_KWS,
1026 *_EXCLUSIVE_SHARED_MOD_KWS,
1027 *_EXCLUSIVE_STATIC_LIB_KWS,
1028 *_SHARED_STATIC_ARGS,
1029 _VS_MODULE_DEFS_KW,
1030 _WIN_SUBSYSTEM_KW,
1031 _JAVA_LANG_KW,
1032 ]
1033
1034 # Arguments used by build_target
1035 BUILD_TARGET_KWS = [
1036 *_BUILD_TARGET_KWS,
1037 *_EXCLUSIVE_SHARED_LIB_KWS,
1038 *_EXCLUSIVE_SHARED_MOD_KWS,
1039 *_EXCLUSIVE_STATIC_LIB_KWS,
1040 *EXCLUSIVE_EXECUTABLE_KWS,
1041 *_SHARED_STATIC_ARGS,
1042 _VS_MODULE_DEFS_KW.evolve(since='1.12.0'),
1043 _WIN_SUBSYSTEM_KW.evolve(since='1.12.0'),
1044 RUST_ABI_KW.evolve(since='1.10.0'),
1045 *[a.evolve(deprecated='1.3.0', deprecated_message='The use of "jar" in "build_target()" is deprecated, and this argument is only used by jar()')
1046 for a in _EXCLUSIVE_JAR_KWS],
1047 KwargInfo(
1048 'target_type',
1049 str,
1050 required=True,
1051 validator=in_set_validator({
1052 'executable', 'shared_library', 'static_library', 'shared_module',
1053 'both_libraries', 'library', 'jar'
1054 }),
1055 since_values={
1056 'shared_module': '0.51.0',
1057 },
1058 deprecated_values={
1059 'jar': ('1.3.0', 'use the "jar()" function directly'),
1060 }
1061 )
1062 ]
1063
1064 def _pkgconfig_define_convertor(x: T.List[str]) -> PkgConfigDefineType:
1065 if x:
1066 keys = itertools.islice(x, 0, None, 2)
1067 vals = itertools.islice(x, 1, None, 2)
1068 return tuple(zip(keys, vals))
1069 return None
1070
1071 PKGCONFIG_DEFINE_KW: KwargInfo = KwargInfo(
1072 'pkgconfig_define',
1073 ContainerTypeInfo(list, str, pairs=True),
1074 default=[],
1075 convertor=_pkgconfig_define_convertor,
1076 )
1077
1078 INCLUDE_TYPE = KwargInfo(
1079 'include_type',
1080 str,
1081 default='preserve',
1082 since='0.52.0',
1083 validator=in_set_validator({'system', 'non-system', 'preserve'})
1084 )
1085
1086
1087 _DEPRECATED_DEPENDENCY_METHODS = frozenset(
1088 {'sdlconfig', 'cups-config', 'pcap-config', 'libwmf-config', 'qmake'})
1089
1090
1091 def _dependency_method_convertor(value: str) -> DependencyMethods:
1092 if value in _DEPRECATED_DEPENDENCY_METHODS:
1093 return DependencyMethods.CONFIG_TOOL
1094 return DependencyMethods(value)
1095
1096
1097 DEPENDENCY_METHOD_KW = KwargInfo(
1098 'method',
1099 str,
1100 default='auto',
1101 since='0.40.0',
1102 validator=in_set_validator(
1103 {m.value for m in DependencyMethods} | _DEPRECATED_DEPENDENCY_METHODS),
1104 convertor=_dependency_method_convertor,
1105 deprecated_values={
1106 'sdlconfig': ('0.44.0', 'use config-tool instead'),
1107 'cups-config': ('0.44.0', 'use config-tool instead'),
1108 'pcap-config': ('0.44.0', 'use config-tool instead'),
1109 'libwmf-config': ('0.44.0', 'use config-tool instead'),
1110 'qmake': ('0.58.0', 'use config-tool instead'),
1111 },
1112 )
1113
1114
1115 DEPENDENCY_KWS: T.List[KwargInfo] = [
1116 DEFAULT_OPTIONS.evolve(since='0.38.0'),
1117 DEPENDENCY_METHOD_KW,
1118 DISABLER_KW.evolve(since='0.49.0'),
1119 INCLUDE_TYPE,
1120 NATIVE_KW,
1121 REQUIRED_KW,
1122 KwargInfo('allow_fallback', (bool, NoneType), since='0.56.0'),
1123 KwargInfo('cmake_args', ContainerTypeInfo(list, str), listify=True, default=[], since='0.50.0'),
1124 KwargInfo('cmake_module_path', ContainerTypeInfo(list, str), listify=True, default=[], since='0.50.0'),
1125 KwargInfo('cmake_package_version', str, default='', since='0.57.0'),
1126 KwargInfo('components', ContainerTypeInfo(list, str), listify=True, default=[], since='0.54.0'),
1127 KwargInfo('fallback', (ContainerTypeInfo(list, str), str, NoneType), since='0.54.0'),
1128 KwargInfo('language', (str, NoneType), convertor=lambda x: x.lower() if x is not None else x,
1129 validator=lambda x: 'Must be a valid language if set' if (x is not None and x not in compilers.all_languages) else None),
1130 KwargInfo('main', bool, default=False),
1131 KwargInfo('modules', ContainerTypeInfo(list, str), listify=True, default=[]),
1132 KwargInfo('not_found_message', str, default='', since='0.50.0'),
1133 KwargInfo('optional_modules', ContainerTypeInfo(list, str), listify=True, default=[]),
1134 KwargInfo('private_headers', bool, default=False),
1135 KwargInfo('static', (bool, NoneType)),
1136 KwargInfo('version', ContainerTypeInfo(list, str), listify=True, default=[]),
1137 ]