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

De-duplicate argument validation in the build module #14133

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

dcbaker
Copy link
Member

@dcbaker dcbaker commented Jan 13, 2025

This series adds TypedDicts for the various BuildTarget derived classes, and then rips out all of the validation in the build layer that is already done in the Interpreter layer. This does not attempt to mess with any validation that is not done at the interpreter layer, however.

There is also a bit of fixing of the types in a few places, namely the explicit conversion of install to bool, rather than doing the same conversion implicitly later.

@dcbaker dcbaker force-pushed the submit/build-cleanup-argument-validation branch 2 times, most recently from 0886be4 to 241d433 Compare January 13, 2025 23:02
@dcbaker dcbaker force-pushed the submit/build-cleanup-argument-validation branch from 241d433 to 0aa85a8 Compare January 31, 2025 16:18
The Interpreter has been merging gui_app and win_subsystem for a while,
but now with the typed kwargs we can feel more comfortable that gui_app
wont get passed through beneath us
…used"

This reverts commit 93c11f2.

We're going to use it again in the next commit
This just does what would happen later, but with the potential to fail
in obscure way.
This includes cleaning up some of the type handling to account for
cleanups that are done at the DSL level.
mesonbuild/build.py Outdated Show resolved Hide resolved
Comment on lines +68 to +69
# The use of Sequence[str] here is intentional to get the generally
# undesirable behavior of Sequence[str]
Copy link
Member

Choose a reason for hiding this comment

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

What undesirable behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

That plain str is a valid Sequence[str]. What Meson almost always actually want is more like list[str] | tuple[str, ...] | ... but not plain str

Copy link
Member

Choose a reason for hiding this comment

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

I see... It seems it could technically be possible to have as SequenceNotStr protocol: https://stackoverflow.com/a/79310749

Copy link
Member Author

Choose a reason for hiding this comment

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

I have another project to work on now. lol

Copy link
Member

Choose a reason for hiding this comment

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

I tried this at one point and I recall that it completely didn't work, but I forget the details. Hopefully you can figure it out but I'm not optimistic.

Copy link
Member Author

@dcbaker dcbaker Feb 1, 2025

Choose a reason for hiding this comment

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

I also tried it several times as well and couldn't make it work either. But if someone else has actually figured it out, I'm interested to try. There's some places in Build specifically that would really benefit from it if we can make it work.

mesonbuild/build.py Show resolved Hide resolved
We have type checking, we also have interpreter level validation from
the DSL, we don't need this.
There's really no reason to not do ths in the `_extract_pic_pie` helper,
it only increases the chance of us not doing this when we should.
It's only valid to use `b_staticpic` with `pic`, and `b_pie` with `pie`,
so just key it off the argument
This logic is specific to StaticLibrary and to Executable, so put the
logic there. While we're at it, make the type checking more rigid.
@dcbaker dcbaker force-pushed the submit/build-cleanup-argument-validation branch from 0aa85a8 to 0fc397b Compare January 31, 2025 19:48
I've left the workaround for the install/build_by_default interaction
for later, that's a more complicated issue to prove, since the
Interpreter does that automatically, so we need to audit non-Interpreter
interactions
There is some validation going on here that cannot (currently) be done
the KwargInfo validators, namely that the files exist. Additionally,
BuildTarget.extra_files is doing some membership checking for dups,
which means it should probably be an OrderedSet instead of a list.
@dcbaker dcbaker force-pushed the submit/build-cleanup-argument-validation branch from 0fc397b to d537f00 Compare January 31, 2025 19:56
@dcbaker
Copy link
Member Author

dcbaker commented Jan 31, 2025

Also in the latest version split an accidental squash of export_dynamic and vs_module_defs

@bruchar1
Copy link
Member

Validation for build_rpath and validation for install_rpath could probably be squashed in one commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants