Skip to content

Commit cddf2e9

Browse files
eli-schwartzjpakkane
authored andcommitted
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.
1 parent 2da53e9 commit cddf2e9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

mesonbuild/build.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,16 +854,22 @@ def check_unknown_kwargs_int(self, kwargs, known_kwargs):
854854

855855
def process_objectlist(self, objects):
856856
assert isinstance(objects, list)
857+
deprecated_non_objects = []
857858
for s in objects:
858859
if isinstance(s, (str, File, ExtractedObjects)):
859860
self.objects.append(s)
861+
if not isinstance(s, ExtractedObjects) and not is_object(s):
862+
deprecated_non_objects.append(s)
860863
elif isinstance(s, (CustomTarget, CustomTargetIndex, GeneratedList)):
861864
non_objects = [o for o in s.get_outputs() if not is_object(o)]
862865
if non_objects:
863866
raise InvalidArguments(f'Generated file {non_objects[0]} in the \'objects\' kwarg is not an object.')
864867
self.generated.append(s)
865868
else:
866869
raise InvalidArguments(f'Bad object of type {type(s).__name__!r} in target {self.name!r}.')
870+
if deprecated_non_objects:
871+
FeatureDeprecated.single_use(f'Source file {deprecated_non_objects[0]} in the \'objects\' kwarg is not an object.',
872+
'1.3.0', self.subproject)
867873

868874
def process_sourcelist(self, sources: T.List['SourceOutputs']) -> None:
869875
"""Split sources into generated and static sources.

mesonbuild/interpreter/type_checking.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,8 @@ def _objects_validator(vals: T.List[ObjectTypes]) -> T.Optional[str]:
554554
non_objects: T.List[str] = []
555555

556556
for val in vals:
557-
if isinstance(val, ExtractedObjects):
557+
if isinstance(val, (str, File, ExtractedObjects)):
558558
continue
559-
elif isinstance(val, (str, File)):
560-
if not compilers.is_object(val):
561-
non_objects.append(str(val))
562559
else:
563560
non_objects.extend(o for o in val.get_outputs() if not compilers.is_object(o))
564561

0 commit comments

Comments
 (0)