interpreter: add an implementation for structured_sources
This commit is contained in:
parent
fd55ff6a72
commit
cbc62e892a
|
@ -116,6 +116,7 @@ syn keyword mesonBuiltin
|
|||
\ shared_library
|
||||
\ shared_module
|
||||
\ static_library
|
||||
\ structured_sources
|
||||
\ subdir
|
||||
\ subdir_done
|
||||
\ subproject
|
||||
|
|
|
@ -154,6 +154,7 @@ class AstInterpreter(InterpreterBase):
|
|||
'alias_target': self.func_do_nothing,
|
||||
'summary': self.func_do_nothing,
|
||||
'range': self.func_do_nothing,
|
||||
'structured_sources': self.func_do_nothing,
|
||||
})
|
||||
|
||||
def _unholder_args(self, args: _T, kwargs: _V) -> T.Tuple[_T, _V]:
|
||||
|
|
|
@ -385,6 +385,7 @@ class Interpreter(InterpreterBase, HoldableObject):
|
|||
'run_command': self.func_run_command,
|
||||
'run_target': self.func_run_target,
|
||||
'set_variable': self.func_set_variable,
|
||||
'structured_sources': self.func_structured_sources,
|
||||
'subdir': self.func_subdir,
|
||||
'shared_library': self.func_shared_lib,
|
||||
'shared_module': self.func_shared_module,
|
||||
|
@ -2107,6 +2108,31 @@ external dependencies (including libraries) must go to "dependencies".''')
|
|||
self.build.symlinks.append(l)
|
||||
return l
|
||||
|
||||
@FeatureNew('structured_sources', '0.62.0')
|
||||
@typed_pos_args('structured_sources', object, optargs=[dict])
|
||||
@noKwargs
|
||||
@noArgsFlattening
|
||||
def func_structured_sources(
|
||||
self, node: mparser.BaseNode,
|
||||
args: T.Tuple[object, T.Optional[T.Dict[str, object]]],
|
||||
kwargs: 'TYPE_kwargs') -> build.StructuredSources:
|
||||
valid_types = (str, mesonlib.File, build.GeneratedList, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList)
|
||||
sources: T.Dict[str, T.List[T.Union['mesonlib.FileOrString', 'build.GeneratedTypes']]] = collections.defaultdict(list)
|
||||
|
||||
for arg in mesonlib.listify(args[0]):
|
||||
if not isinstance(arg, valid_types):
|
||||
raise InvalidArguments(f'structured_sources: type "{type(arg)}" is not valid')
|
||||
sources[''].append(arg)
|
||||
if args[1]:
|
||||
if '' in args[1]:
|
||||
raise InvalidArguments('structured_sources: keys to dictionary argument may not be an empty string.')
|
||||
for k, v in args[1].items():
|
||||
for arg in mesonlib.listify(v):
|
||||
if not isinstance(arg, valid_types):
|
||||
raise InvalidArguments(f'structured_sources: type "{type(arg)}" is not valid')
|
||||
sources[k].append(arg)
|
||||
return build.StructuredSources(sources)
|
||||
|
||||
@typed_pos_args('subdir', str)
|
||||
@typed_kwargs(
|
||||
'subdir',
|
||||
|
|
Loading…
Reference in New Issue