diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2021-11-30 14:56:33 -0500 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2021-12-07 19:47:12 -0500 |
commit | 1e5d7f212246e967f3473a55f632f6f5eda87b65 (patch) | |
tree | e1d93ad13f61bd4a0495c76a948e034297128131 /mesonbuild | |
parent | d9c73a6a7b397d85f2efd84cdcfb82f66a94ef79 (diff) | |
download | meson-1e5d7f212246e967f3473a55f632f6f5eda87b65.zip meson-1e5d7f212246e967f3473a55f632f6f5eda87b65.tar.gz meson-1e5d7f212246e967f3473a55f632f6f5eda87b65.tar.bz2 |
custom_target: catch and reject input files that do not exist
Currently there is a try/except around the function that detects and
rejects this, which instead of rejecting it, spawns a warning and
continue.
This warning exists because of 'test cases/vala/9 gir/' which passes a
vala generated output that isn't a return value (!!!) using string
joining with the meson.current_build_dir() function (also !!!) because
we officially document this (!!! for a third time) as the only way to
make a vala shared library generate a typelib with a custom_command from
the automatically generated gir:
https://mesonbuild.com/Vala.html#gobject-introspection-and-language-bindings
In #3061 we converted strings to Files, but only if none of them were
this vala hack. Due to the precise implementation, we also failed to
convert strings to Files if any other error occurred, but since we only
want to ignore errors for generated vala outputs, tighten that check and
specifically call out generated files in the warning.
Fixes #8635
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/interpreter/interpreter.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 1a8d0ae..d4dbec9 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -1768,11 +1768,7 @@ external dependencies (including libraries) must go to "dependencies".''') name = '' kwargs['install_mode'] = self._get_kwarg_install_mode(kwargs) if 'input' in kwargs: - try: - kwargs['input'] = self.source_strings_to_files(extract_as_list(kwargs, 'input')) - except mesonlib.MesonException: - mlog.warning(f'''Custom target input '{kwargs['input']}' can't be converted to File object(s). -This will become a hard error in the future.''', location=node) + kwargs['input'] = self.source_strings_to_files(extract_as_list(kwargs, 'input'), strict=False) kwargs['env'] = self.unpack_env_kwarg(kwargs) if 'command' in kwargs and isinstance(kwargs['command'], list) and kwargs['command']: if isinstance(kwargs['command'][0], str): @@ -2610,12 +2606,15 @@ Try setting b_lundef to false instead.'''.format(self.coredata.options[OptionKey raise InterpreterException(f'Sandbox violation: Tried to grab {inputtype} {norm.name} from a nested subproject.') @T.overload - def source_strings_to_files(self, sources: T.List['mesonlib.FileOrString']) -> T.List['mesonlib.File']: ... + def source_strings_to_files(self, sources: T.List['mesonlib.FileOrString'], strict: bool = True) -> T.List['mesonlib.File']: ... + + @T.overload + def source_strings_to_files(self, sources: T.List['mesonlib.FileOrString'], strict: bool = False) -> T.List['mesonlib.FileOrString']: ... # noqa: F811 @T.overload - def source_strings_to_files(self, sources: T.List['SourceInputs']) -> T.List['SourceOutputs']: ... # noqa: F811 + def source_strings_to_files(self, sources: T.List['SourceInputs'], strict: bool = True) -> T.List['SourceOutputs']: ... # noqa: F811 - def source_strings_to_files(self, sources: T.List['SourceInputs']) -> T.List['SourceOutputs']: # noqa: F811 + def source_strings_to_files(self, sources: T.List['SourceInputs'], strict: bool = True) -> T.List['SourceOutputs']: # noqa: F811 """Lower inputs to a list of Targets and Files, replacing any strings. :param sources: A raw (Meson DSL) list of inputs (targets, files, and @@ -2629,8 +2628,13 @@ Try setting b_lundef to false instead.'''.format(self.coredata.options[OptionKey results: T.List['SourceOutputs'] = [] for s in sources: if isinstance(s, str): - self.validate_within_subproject(self.subdir, s) - results.append(mesonlib.File.from_source_file(self.environment.source_dir, self.subdir, s)) + if not strict and s.startswith(self.environment.get_build_dir()): + results.append(s) + mlog.warning(f'Source item {s!r} cannot be converted to File object, because it is a generated file. ' + 'This will become a hard error in the future.', location=self.current_node) + else: + self.validate_within_subproject(self.subdir, s) + results.append(mesonlib.File.from_source_file(self.environment.source_dir, self.subdir, s)) elif isinstance(s, mesonlib.File): results.append(s) elif isinstance(s, (build.GeneratedList, build.BuildTarget, |