Skip to content

Convert BuildTarget arguments explicitly in the interpreter#15506

Draft
dcbaker wants to merge 16 commits intomesonbuild:masterfrom
dcbaker:submit/interpreter-convert-build-target-kwargs-explicitly
Draft

Convert BuildTarget arguments explicitly in the interpreter#15506
dcbaker wants to merge 16 commits intomesonbuild:masterfrom
dcbaker:submit/interpreter-convert-build-target-kwargs-explicitly

Conversation

@dcbaker
Copy link
Member

@dcbaker dcbaker commented Jan 29, 2026

This allows us to have a fully functional conversion with type checking of the kwargs dictionaries between the DSL level and and the Build level of abstractions. Apart from fixing a number of incorrect or incomplete annotations, this gets us to the point that we can (mostly) validate the type checking.

This is set as draft because I'm sure there are regressions that don't show up on my system but will light CI up like a christmas tree.

`typed_kwargs` has already taken care of that for us.
Also, move `check_sources_exist` before string -> File conversion, since
otherwise it does nothing.
Which should be `dict[str, str]`
It should be `list[str | IncludeDirs]`, not just `list[IncludeDirs]`
We set this in the interpreter for Vala related arguments, but never
pass it into the build layer.
Ironically, the VS backend already does this correctly.
We have the Interpreter layer which does DSL translation and the build
layer has type annotations.
…format

We currently sort of manipulate the dictionary in place and kinda hope
everything works. This moves the conversion to be explicit, building a
new dictionary (not requiring a copy) and getting help from static type
checkers to ensure that everything is correct.
name_suffix: T.Optional[str]
native: MachineChoice
override_options: T.Dict[OptionKey, str]
override_options: T.Dict[str, ElementaryOptionValues]
Copy link
Member

Choose a reason for hiding this comment

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

The commit message says dict[str, str] but this is dict[str, ElementaryOptionValues]

@bonzini
Copy link
Contributor

bonzini commented Feb 3, 2026

The errors seem to be always the same changes in error messages:

expected "test cases/failing/64 skip only subdir/meson.build:8:0: ERROR: File main.cpp does not exist." not found in stdout 
...
mesonbuild.interpreterbase.exceptions.InterpreterException: Tried to add non-existing source file main.cpp.

But there's also one where the old message is better:

expected "test cases/failing/133 java sources in non jar target/meson.build:3:0: ERROR: Build target of type "executable" cannot build java source: "Test.java". Use "jar" instead." not found in stdout 
...
  File "/__w/meson/meson/mesonbuild/build.py", line 1128, in process_compilers
    raise MesonException(m)
mesonbuild.utils.core.MesonException: No host machine compiler for 'Test.java'

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