615 Commits

Author SHA1 Message Date
benjamin-otte
4146c44723 Improve error messages for wrap-redirect file
While discussing error messages on IRC with xclaesse, we found 448b11cb7f which improves one of the error messages, but leaves out the others. This commit updates them, too.
2026-06-19 17:07:31 +02:00
Loïc Estève
dba79292df Make cython generated targets less nested 2026-06-19 15:43:23 +02:00
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
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
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
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
c561bd8861 build, interpreter: make project-related fields per machine
This is a first step towards making it possible to allow subprojects to
be built for both the build and host machine.  Even though the concept
of a build-machine subproject doesn't exist yet, prepare for it by
making the list of (sub)projects per machine, and storing the machine
in the interpreter's subproject stack.

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
d7bedd8cc1 build: replace SubProject with BuildProject for target
The SubProject alone will not be a unique key into build.projects.
Just store the object itself, as it allows retrieving the key.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-17 13:05:22 -07:00
Paolo Bonzini
288763a863 interpreter: introduce apply_machine_map
Introduce a decorator that applies the transformation in
self.build.machine_map to kwargs['native'].  In the future
this will also handle conversion of kwargs['native'] to
kwargs['for_machine'].

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-17 13:05:22 -07:00
Paolo Bonzini
f33474edd2 test cases: expand test for nonexisting property
Cover various combination of the native keyword argument and whether the
property is in a native or cross file.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-17 13:05:22 -07:00
Paolo Bonzini
b108299627 interpreterbase: warn on redundant Meson version checks
We might encounter a Meson version check that always evaluates to true
or to false:

    project('t', 'c', meson_version: '>=0.60.0')
    if meson.version().version_compare('>=0.55.0')
      v = 1
    endif
    if meson.version().version_compare('<0.60.0')
      v = 2
    endif

Print warnings in such cases.

Co-authored-by: Benjamin Gilbert <bgilbert@backtick.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-02 11:05:24 -07:00
Paolo Bonzini
0bfffde31b interpreter: track minimum Meson version as a Range[Version]
Parse it just once, ahead of time, and pass it to
version_compare_condition_with_min.

This gives, for free, support for multi-argument
meson.version().version_compare().

There are two changes in outputs: first, the output of version
checks now canonicalizes the minimum Meson version; second, a '!='
or '<' meson_version does not count as a "minimum Meson version" in
error messages (after all, they do not specify a minimum for the
purpose of version_compare_condition_with_min) so a few testcases
have to be adjusted.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-02 11:05:24 -07:00
Paolo Bonzini
296c555577 utils: add Range class
Add a class that can be used to encode a range of versions.  It is
useful to express the project's minimum version and to reason on it,
for example to detect redundant Meson version checks.
2026-06-02 11:05:24 -07:00
Paolo Bonzini
2f9c97d591 utils, interpreter: move special handling of .0 versions to feature decorators
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-02 11:05:24 -07:00
Paolo Bonzini
589b1488a6 utils: fix version_compare_condition_with_min with > condition
Right now specifying >1.10.0 gives warnings like

meson.build:18: WARNING: Project targets '>1.10.0' but uses feature introduced in '1.10.0': meson.version().version_compare() with multiple arguments. From 1.8.0 - 1.9.* it failed to match str.version_compare

This is incorrect.  A project targeting 1.10.1 or later can use features
introduced by 1.10.0.  Fix the bug in version_compare_condition_with_min
and adjust the testcases.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-06-02 11:05:24 -07:00
Paolo Bonzini
a7e124d43d add unit tests for version checks 2026-06-02 11:05:24 -07:00
Gleb Popov
3b4402217a linuxliketests: Skip -fuse-ld tests for lcc 2026-06-02 08:38:00 -07:00
Gleb Popov
1b915c31c5 allplatformtests: Fix test_compiler_detection for the elbrus/lcc case 2026-06-02 08:38:00 -07:00
Paolo Bonzini
f516566a55 cargo: implement prerelease filtering
This worked by chance at the edges ('<2.0' did not match '<2.0-pre')
just because RPM sorting order placed '2.0-pre' *after* '2.0'.  With
SemVer it has to be implemented fully.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-28 11:53:47 +02:00
Paolo Bonzini
855dd901d2 cargo: change version comparisons to use semver
Fixes: #15636
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-28 11:53:47 +02:00
Paolo Bonzini
9fb5c6b466 cargo: add a SemVer class
Semantic versions are quite different from RPM versions implemented in
Meson's Version class.  Just implement them with a completely
different class.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-28 11:53:47 +02:00
Paolo Bonzini
83e038303f cargo: "compile" version checks to a callable
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-28 11:53:47 +02:00
Paolo Bonzini
4a63956e20 cargo: add a "tokenizer" for version requirement strings
Eliminate duplicate code for x.y.* and ~x.y, and generally
speaking simplify version.convert(), by canonicalizing each
of the requirements.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-28 11:53:47 +02:00
Paolo Bonzini
8a360f9fe0 unittests: do not assume cargo versions are parsed into meson versions
Check the acceptance directly against a set of versions, instead
of checking the result of the conversion.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-28 11:53:47 +02:00
Paolo Bonzini
ec51939c92 unittests: add some currently-failing tests
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-28 11:53:47 +02:00
Paolo Bonzini
7bc4b718f7 unittests: add test for updating version of a cargo package
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-28 11:53:47 +02:00
Paolo Bonzini
1af53710cb unittests: add test for cargo.version.api
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-28 11:53:47 +02:00
Aleksandr Mezin
ba92b25271 mtest: fix handling of empty lines in TAP YAML block
YAML blocks can contain lines that consist of whitespace only.
`.rstrip()` makes such lines empty. Move `.rstrip()` past YAML
block handling.
2026-05-18 08:14:22 +02:00
Marcel Telka
8b3d11f4b4 test cases: illumos does not support -fsanitize=address 2026-05-10 21:24:12 +02:00
Sam James
ea995d748c unittests: add another test for mtest --exclude
Test the 'main:name' case.
2026-05-03 10:16:01 +01:00
Katalin Rebhan
56a4cefa0b More robust handling of linker argument wrapping
Not all compilers (swiftc in case of #14261) concatenate linker
arguments with ','. This removes that assumption and instead always
passes the arguments in a list where applicable, and reworks the
linker argument wrapper syntaxes for the compilers to more accurately
represent the three different option styles.

Some Apple ld options, notably -install_name, are also not exposed
directly on the compiler options interface, hence add the linker
prefix here.
2026-05-03 10:56:36 +02:00
Paolo Bonzini
41c8235557 utils: introduce a faster variant of ABCMeta
The virtual superclass feature of ABCMeta is never used by Meson.  Replace
with a simpler version that only checks for abstract methods, so that
isinstance() against any of Meson's concrete subclasses now goes
through the CPython C fast path.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-05-01 06:39:46 +02:00
Sam James
16a7472802 mtest: support --exclude
Support `--exclude name` where `name` is a full test name, optionally
including the subproject name. Wildcards are not currently supported.

Accept both `name` for the main project and `subproject:name`. We want `name`
for convenience so users don't have to write out their project name when
no subprojects are involved.

Extended matching could be added in future, but the primary usecase for
this is where distributions want to skip known-buggy or irrelevant tests,
rather than developers working on their own project.

The test changes are a bit noisy because needed to add a test with
the same name in the main project and a subproject to check that --exclude
w/ an unqualified name only affected the main parent, but adding 2 new failing
tests required all the numbers to be adjusted.

Closes: https://github.com/mesonbuild/meson/pull/11502
Closes: https://github.com/mesonbuild/meson/issues/6999
Signed-off-by: Sam James <sam@gentoo.org>
2026-04-27 13:34:07 +01:00
Mohamed Akram
dd2c4203e9 build: fix install name when using link_whole 2026-04-27 13:07:19 +02:00
Mohamed Akram
ee89525b91 build: fix install name when linking with static library
A static library can specify a dynamic library in `link_with`.
2026-04-25 13:07:25 +02:00
Dylan Baker
20a2ebaf39 uninttests: Skip python2 tests if the python2 binary isn't installed
This provides faster skipping on macos and on Linux before bother to
call into pkg-config. This is needed on macOS to keep things running
after the next patch that is forced to take a heavy handed approach to
prevent the wrong python from being used.
2026-04-23 14:01:23 -07:00
Sam James
d124ce5342 Spell 'DragonFly BSD' correctly
They style it with a capital F and a space.

Signed-off-by: Sam James <sam@gentoo.org>
2026-04-18 13:21:18 +01:00
Paolo Bonzini
af120502fa interpreter: remove use of UserFeatureOption
Introduce a dataclass to wrap the result of get_option() for features.
This removes a layering violation, where UserFeatureOptions are created
outside options.py just to apply modifiers like disable_if().

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-13 17:57:16 +02:00
Jussi Pakkanen
0fe25e31f8 Fix Debian regression #1132495. 2026-04-02 13:59:58 +03:00
Jussi Pakkanen
2ab022841f Condense test directories for rc. 2026-03-29 21:44:17 +03:00
Michał Górny
27c90630fb Replace the two other continues with SkipTests
Signed-off-by: Michał Górny <mgorny@quansight.com>
2026-03-27 12:35:38 +01:00
Michał Górny
f0b13b3aa7 Skip pkgconfig+sysroot test without pkgconf
Signed-off-by: Michał Górny <mgorny@quansight.com>
2026-03-27 12:35:38 +01:00
Michał Górny
c35a26cddf Fix prepending duplicate sys_root to python build configs
Fix the logic responsible for handling python build configs to check
if paths from `build-details.json` start with sys_root, and do not
prepend it if they do. This matches the pkg-config behavior (of
`PKG_CONFIG_SYSROOT_DIR`). It permits using it both with sysroots that
are a regular system mounted in a subdirectory, and that are dedicated
prefixes (e.g. created via conda).

Signed-off-by: Michał Górny <mgorny@quansight.com>
2026-03-27 12:35:38 +01:00
Paolo Bonzini
92a3a01e78 unittests: add unittests for MSVC include path arguments
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-03-23 09:18:19 +01:00
tytan652
fb12c9ce99 cargo: Fix less than equal version conversion 2026-03-18 12:09:38 +01:00
Paolo Bonzini
db62de2c40 compilers: rename INVOKES_LINKER
Use a name that can be applied to rustc as well (because
RUSTFLAGS need not be added to rust_link_args and in fact
it breaks).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-03-18 12:09:25 +01:00
Paolo Bonzini
1cb3030527 allplatformtests: reactivate test_env_flags_to_linker
Instead of monkeypatching the compiler, just check that the
compiler (whichever it is) does the right thing for its
INVOKES_LINKER setting.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-03-18 12:09:25 +01:00
Paolo Bonzini
56f1cbbe1c unittests: add test for string source to i18n.merge_file
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-03-11 09:29:03 +01:00