Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix regression in converting build_target kwargs to typed_kwargs #12505

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mesonbuild/interpreter/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3318,6 +3318,13 @@ def build_target(self, node: mparser.BaseNode, args: T.Tuple[str, SourcesVarargs
# backwards compatibility anyway
sources = [s for s in sources
if not isinstance(s, (build.BuildTarget, build.ExtractedObjects))]

# due to lack of type checking, these are "allowed" for legacy reasons
if not isinstance(kwargs['install'], bool):
FeatureBroken.single_use('install kwarg with non-boolean value', '1.3.0', self.subproject,
'This was never intended to work, and is essentially the same as using `install: true` regardless of value.',
node)

sources = self.source_strings_to_files(sources)
objs = kwargs['objects']
kwargs['dependencies'] = extract_as_list(kwargs, 'dependencies')
Expand Down
3 changes: 2 additions & 1 deletion mesonbuild/interpreter/type_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ def _objects_validator(vals: T.List[ObjectTypes]) -> T.Optional[str]:
OVERRIDE_OPTIONS_KW,
KwargInfo('build_by_default', bool, default=True, since='0.38.0'),
KwargInfo('extra_files', ContainerTypeInfo(list, (str, File)), default=[], listify=True),
INSTALL_KW,
# Accursed. We allow this for backwards compat and warn in the interpreter.
KwargInfo('install', object, default=False),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think INSTALL_KW = KwargInfo('install', bool, default=False) is generally wrong. We always allowed that kwarg to be a list of boolean for the case it has multiple outputs. That's especially useful for CustomTarget, but also for any BuildTarget that could have extra vala outputs IIRC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, maybe that was only for install_dir?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it is install_dir that allows a list, maybe the warning should hint at doing that, because it very likely was the intention when doing install: [true, false, get_option('foobar')].

I'm wondering why this suddenly happens, the PR that changed this is 2 years old.

Copy link
Member Author

@eli-schwartz eli-schwartz Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR that what'd this? We do no form of type checking on this kwarg at all. That's why I've written object here. It's entirely possible for people to have been using this kwarg with install: executable('foo', 'foo.c') which is total nonsense but also a valid object.

One of the reports I got was for someone confusing it for install_dir (despite the fact that they use install_dir correctly below). The other report I got was someone doing install: 'true' which makes me wonder if people are also doing install': 'false' and getting... bool('false') == True. Perhaps they were more used to JavaScript....

INSTALL_MODE_KW,
KwargInfo('implicit_include_directories', bool, default=True, since='0.42.0'),
NATIVE_KW,
Expand Down
Loading