mirror of
https://github.com/mesonbuild/meson.git
synced 2026-11-06 05:16:42 +00:00
interpreter: Move validation of BuildTarget(extra_files) to Interpreter
This gets us to the point that the build layer can assume it's getting valid inputs. This does two checks, an initial cheap check for generated sources, and then an I/O check via `source_strings_to_files`.
This commit is contained in:
1 parent
9f9481224a
commit
97a1c567c9
3 files changed
+17
-13
No files matched your search
+1
-11
@@ -1294,17 +1294,7 @@ class BuildTarget(Target):
|
||||
(str, bool))
|
||||
self.install_mode = kwargs.get('install_mode', None)
|
||||
self.install_tag = stringlistify(kwargs.get('install_tag', [None]))
|
||||
extra_files = kwargs.get('extra_files', [])
|
||||
for i in extra_files:
|
||||
# TODO: use an OrderedSet instead of a list?
|
||||
if i in self.extra_files:
|
||||
continue
|
||||
# TODO: this prevents built `File` objects from being used as
|
||||
# extra_files.
|
||||
trial = os.path.join(self.environment.get_source_dir(), i.subdir, i.fname)
|
||||
if not os.path.isfile(trial):
|
||||
raise InvalidArguments(f'Tried to add non-existing extra file {i}.')
|
||||
self.extra_files.append(i)
|
||||
self.extra_files = kwargs.get('extra_files', [])
|
||||
self.install_rpath: str = kwargs.get('install_rpath', '')
|
||||
self.build_rpath = kwargs.get('build_rpath', '')
|
||||
self.resources = kwargs.get('resources', [])
|
||||
|
||||
@@ -3445,7 +3445,8 @@ class Interpreter(InterpreterBase, HoldableObject):
|
||||
sources = self.source_strings_to_files(sources)
|
||||
objs = kwargs['objects']
|
||||
kwargs['dependencies'] = extract_as_list(kwargs, 'dependencies')
|
||||
kwargs['extra_files'] = self.source_strings_to_files(kwargs['extra_files'])
|
||||
# TODO: When we can do strings -> Files in the typed_kwargs validator, do this there too
|
||||
kwargs['extra_files'] = mesonlib.unique_list(self.source_strings_to_files(kwargs['extra_files']))
|
||||
self.check_sources_exist(os.path.join(self.source_root, self.subdir), sources)
|
||||
self.__process_language_args(kwargs)
|
||||
if targetclass is build.StaticLibrary:
|
||||
|
||||
@@ -588,11 +588,24 @@ def _target_install_convertor(val: object) -> bool:
|
||||
return bool(val)
|
||||
|
||||
|
||||
def _extra_files_validator(args: T.List[T.Union[File, str]]) -> T.Optional[str]:
|
||||
generated = [a for a in args if isinstance(a, File) and a.is_built]
|
||||
if generated:
|
||||
return 'extra_files contains generated files: {}'.format(', '.join(f"{f.fname}" for f in generated))
|
||||
return None
|
||||
|
||||
|
||||
# Applies to all build_target like classes
|
||||
_ALL_TARGET_KWS: T.List[KwargInfo] = [
|
||||
OVERRIDE_OPTIONS_KW,
|
||||
KwargInfo('build_by_default', bool, default=True, since='0.38.0'),
|
||||
KwargInfo('extra_files', ContainerTypeInfo(list, (str, File)), default=[], listify=True),
|
||||
KwargInfo(
|
||||
'extra_files',
|
||||
ContainerTypeInfo(list, (str, File)),
|
||||
default=[],
|
||||
listify=True,
|
||||
validator=_extra_files_validator,
|
||||
),
|
||||
KwargInfo(
|
||||
'install',
|
||||
object,
|
||||
|
||||
Reference in new issue
Block a user