fix another regression in converting build_target kwargs to typed_kwargs

This time we have a case where people are passing non-objects by using
them as str | File, which we never warned about and silently accepted.
If it was passed via custom_target outputs we *would* error out,
interestingly enough. At the backend layer, we just pass them directly
to the linker... which is valid, if we misdetected what's a valid linker
input or people just used funny names. In particular, the mingw
toolchain allows passing a *.def file directly, and some people are
doing that.

If we do want to allow this, we should do it consistently. For now, just
follow the current theme of what's expected, but do so by warning
instead of fatally erroring, for cases where users were able to do it in
the past.
pull/12507/head
Eli Schwartz 1 year ago committed by Jussi Pakkanen
parent 2da53e943a
commit cddf2e9d87
  1. 6
      mesonbuild/build.py
  2. 5
      mesonbuild/interpreter/type_checking.py

@ -854,9 +854,12 @@ class BuildTarget(Target):
def process_objectlist(self, objects):
assert isinstance(objects, list)
deprecated_non_objects = []
for s in objects:
if isinstance(s, (str, File, ExtractedObjects)):
self.objects.append(s)
if not isinstance(s, ExtractedObjects) and not is_object(s):
deprecated_non_objects.append(s)
elif isinstance(s, (CustomTarget, CustomTargetIndex, GeneratedList)):
non_objects = [o for o in s.get_outputs() if not is_object(o)]
if non_objects:
@ -864,6 +867,9 @@ class BuildTarget(Target):
self.generated.append(s)
else:
raise InvalidArguments(f'Bad object of type {type(s).__name__!r} in target {self.name!r}.')
if deprecated_non_objects:
FeatureDeprecated.single_use(f'Source file {deprecated_non_objects[0]} in the \'objects\' kwarg is not an object.',
'1.3.0', self.subproject)
def process_sourcelist(self, sources: T.List['SourceOutputs']) -> None:
"""Split sources into generated and static sources.

@ -554,11 +554,8 @@ def _objects_validator(vals: T.List[ObjectTypes]) -> T.Optional[str]:
non_objects: T.List[str] = []
for val in vals:
if isinstance(val, ExtractedObjects):
if isinstance(val, (str, File, ExtractedObjects)):
continue
elif isinstance(val, (str, File)):
if not compilers.is_object(val):
non_objects.append(str(val))
else:
non_objects.extend(o for o in val.get_outputs() if not compilers.is_object(o))

Loading…
Cancel
Save