Commit Graph

17552 Commits

Author SHA1 Message Date
Florian "sp1rit"​
5461ecf31e find_program: Respect --force-fallback-for
Previously, find_program only used the subproject fallback if it didn't
find the tool the normal way or global forcefallback was activated. Now
it should also fall back if the subproject that provides the fallback is
part of force-fallback-for.
2026-06-19 14:39:52 +02:00
L. E. Segovia
739e86f3e4 nasm: use the correct flag for response file support, try 2
This commit reenables and implements correct response file support for
Nasm.

Fortified with the knowledge of #15867 and #15872, and with a quick chat
with @nirbheek, I realised that the easiest way to fix this (since Ninja
does not support custom argument spacing) is to do it the obvious way,
with Meson's custom command support.

This commit implements an abridged version of that: when a non-standard
RspFileSyntax value is detected, the active NinjaBuildRule is temporarily
resolved to the corresponding NinjaRule on the fly and if the latter says
that a response file will be used, the NinjaBuildRule is immediately
converted into a CUSTOM_COMMAND, completing the arguments with
the bits for infile and outfile and triggering the executable
serialization. That serializes the response file and pickles the command.

Fixes building mpv with MSVC 2022+ and fdk-aac enabled.
2026-06-19 14:11:50 +02:00
Paolo Bonzini
d23570a90b ninjabackend: extract NinjaBuild object
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-19 14:11:50 +02:00
Paolo Bonzini
e4c7e61ab9 ninjabackend: add should_use_rspfile() method to NinjaRule
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-19 14:11:50 +02:00
Dylan Baker
8cd27e2ed4 programs: Fix strict-null issues
ExternalProgram has as weird way of setting self.command to `list[str |
None]`, but it should only be `list[None]` if `self.command = [None]`.
Instead, just set self.command to `list[str]`, and use an empty list as
the sentinel value.

This also fixes a few issues where we use Any or reduce to Any.
2026-06-18 17:37:02 +02:00
Dylan Baker
e52dafea4e minstall: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
de69a6ebe8 backend/backends: Make TargetInstallData.install_mode non-optional 2026-06-18 17:37:02 +02:00
Dylan Baker
feee3a3546 minit: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
7b6de79f06 mesonmain: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
0c106b2b8a mesondata: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
6f956acb5f mdist: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
b4588460dd mdevenv: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
4e272176e6 mconf: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
a4492c2710 mcompile: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
e3b1eca625 environment: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
91fd982c7f envconfig: Turn on mypy strict optional
We might want to go the otherway on the MachineInfo, not allowing the
cpu_fmaily and cpu to be None. Unsure yet
2026-06-18 17:37:02 +02:00
Dylan Baker
da834ea82a cmdline: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
7cd66d39f4 coredata: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
73bb614328 mlog: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
4098ece0db machinefile: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
cc21ae35df depfile: Turn on mypy strict optional 2026-06-18 17:37:02 +02:00
Dylan Baker
9e31ba0cb2 tooldetect: use strict optional
This makes use of mypy.ini to enable stricter checking.
2026-06-18 17:37:02 +02:00
Dylan Baker
7498aa1553 make use of the unwrap function 2026-06-18 17:37:02 +02:00
Dylan Baker
d075ba33ca utils/universal: Add unwrap functions for removing None values from unions 2026-06-18 17:37:02 +02:00
Dylan Baker
55321d5cd7 compilers/compilers: Use wallrus operator for exe_wrapper
less code, tighter typing
2026-06-18 17:37:02 +02:00
Dylan Baker
777981033f interpreter: Use the late_property for Interpreter.backend 2026-06-18 17:37:02 +02:00
Dylan Baker
ba834349b0 utils/universal: Add a late_property
This is a decorator that allows declaring a property as initialized
late. This allows for more ergonomic typing than using a union of `T |
None` for late initialized variables.
2026-06-18 17:37:02 +02:00
Dylan Baker
f22f674855 utils/universal: Use ParamSpec for decorators
Sot that they have correct typing.
2026-06-18 17:37:02 +02:00
Dylan Baker
43b301f3ee utils/universal: Fix typing of PerThreeMachine.miss_defaulting
It doesn't return a `_T | None`, the type Defaultable type already has
`_T | None` baked in, so it just needs a
`PerThreeMachineDefaultable[_T]`
2026-06-18 17:37:02 +02:00
Dylan Baker
28f3dbbbac interpreter: Project(version) cannot be None
We have a default value of `'undefined'`, so it can't actually be None.
Remove the annotations that would let None pass.
2026-06-18 17:37:02 +02:00
Dylan Baker
4ed8dedd57 cmake/interpreter: ConverterCustomTarget.get_ref cannot return None
In every case where None is returned we'd either hit an assertion
failure, or an uncaught exception. So instead, raise if we don't find an
output.
2026-06-18 17:37:02 +02:00
Dylan Baker
f302ad477d backends/ninja: refactor RustrCrate to remove is_proc_macro
It's always derived from the value of proc_macro_dylib_path anyway, so
move that into the function itself. This also resolves some strict null
issues.
2026-06-18 17:37:02 +02:00
Dylan Baker
9151be0088 backend: Don't return none from backend getters
Instead raise an exception. There is never a case where we don't error
if we get a None, so stop returning it.
2026-06-18 17:37:02 +02:00
Dylan Baker
6f52381199 utils: make get_meson_command return a list[str] or error
We have one, and only one case where we use the fact it can return None,
and otherwise assert (or should assert) that the value is not None.
Instead, raise if the command is None, and in the one case catch the
exception.
2026-06-18 17:37:02 +02:00
Dylan Baker
f3877152b4 compilers/rust: Use get_linker_id() instead of .linker.id
Which never returns None.

The result will be the same either way, but this fixes strict null
issues.
2026-06-18 17:37:02 +02:00
Dylan Baker
46c4034df3 compilers: Add a method to get a static linker or error
Sometimes we just need a static_linker, and not having one is an error.
This removes a use of `assert` to help mypy, and makes the code clearer.
2026-06-18 17:37:02 +02:00
Dylan Baker
b6f1863c09 internaltests: Fix test_program_version type (and use subtests)
This was passing a `list[list[str] | str]` to
`ExternalProgram(command)`, which is invalid.
2026-06-18 17:37:02 +02:00
Paolo Bonzini
142f44a3c4 cargo: vary crate names per machine
When a crate name is compiled for both the build and the host machine,
give it two different names to avoid conflicts.  This is not needed
for subprojects, but it is still necessary for packages that are part
of the toplevel workspace.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-18 10:47:44 +02:00
Paolo Bonzini
891f276550 cargo: assert that proc-macro crates are built once
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-18 10:47:44 +02:00
Paolo Bonzini
e6bb057839 cargo: implement machine-specific dependency tracking
Change the dependency resolution code to take a MachineChoice as an
argument.  Create build- and/or host-side configurations
through the machines_from() method in Manifest.
2026-06-18 10:47:44 +02:00
Paolo Bonzini
65ffb1d07b cargo: store machine-specific configuration
Make the PackageConfiguration a PerMachine object.  This makes it
possible to do dependency resolution separately for build- and/or host-side
libraries.

For now, all users only fill in or consume the host side, but that will change.
2026-06-18 10:47:44 +02:00
Paolo Bonzini
dc559de85a interpreter, rust: add native argument to workspace object
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-17 13:05:22 -07:00
Paolo Bonzini
192ac47bd4 interpreter, cmake: add native argument to subproject()
Extracted from a patch by Dylan Baker <dylan@pnwbakers.com>

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-17 13:05:22 -07:00
Paolo Bonzini
26e4e7d4ca tests: add test that native subprojects have different introspection ids 2026-06-17 13:05:22 -07:00
Dylan Baker
bff2e5831a tests for native subprojects 2026-06-17 13:05:22 -07:00
Paolo Bonzini
2631a5efc4 interpreter: allow subprojects to be requested for the build machine
The current situation in Meson is that subprojects are always built for
the host machine. This means that while cross compiling, a tool that
must be run on the build machine must have all of its dependencies met
by the system (pkg-config, cmake, config-tool, etc); but dependencies
for the host machine can be built. With this patch subprojects may also
be built for the build machine.

Nothing should ever be installed from a subproject for the build
machine, while cross compiling. However, if we are not cross compiling
they are installed, since Meson can't really tell the difference between
a host and build dependency in that case.

Extracted from a patch by Dylan Baker <dylan@pnwbakers.com>

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-17 13:05:22 -07:00
Paolo Bonzini
a75c360c24 build: keep host/build separate when merging from a build-only subproject
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-17 13:05:22 -07:00
Paolo Bonzini
499f73da17 build: differentiate build directory according to a subproject's build machine
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-17 13:05:22 -07:00
Paolo Bonzini
3cba9ee127 interpreter: add native argument to override_find_program()
Co-authored-by: Dylan Baker <dylan@pnwbakers.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-17 13:05:22 -07:00
Paolo Bonzini
b74736b160 interpreter: block install_* commands for build subprojects
The object however has to be returned anyway.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-17 13:05:22 -07:00