Skip to content

Commit

Permalink
fix another regression in converting build_target kwargs to typed_kwargs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eli-schwartz committed Nov 13, 2023
1 parent 0bc01e8 commit ba06eff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 6 additions & 0 deletions mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,16 +854,22 @@ def check_unknown_kwargs_int(self, kwargs, known_kwargs):

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:
raise InvalidArguments(f'Generated file {non_objects[0]} in the \'objects\' kwarg is not an object.')
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.
Expand Down
5 changes: 1 addition & 4 deletions mesonbuild/interpreter/type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit ba06eff

Please sign in to comment.