723 Commits
Author SHA1 Message Date
Charles Brunet fb511f0ab1 Fix missing build project prefixes
A build project prefix ("build.") was introduced in 499f73da1 to separate build
files from host and build targets when cross compiling subprojects.
Additional work was done in 83fba12da. However, this prefix was missing from
some places:
- for generated files, with or without `build_subdir`: those files were
  generated at the same place for both host and build targets.
- for include dirs: was erroring if it was only available in the build
  tree.
- for subdirs
- for generated ast
Additionally, extra_build_dirs were double-prefixed.
2026-11-04 18:58:43 +01:00
GeorgiaPreda 9a685a84fa qt: register existing .qrc to fix build dependencies 2026-11-02 11:32:42 -08:00
Dylan Baker c523578ab1 ruff: Enable PERF401: Use list-comprehensions when possible
This not only creates less LOC, but also improves performance
2026-10-30 20:04:49 -07:00
Dylan Baker 6933aaf2e5 ruff: enable PERF102
Which replaces uses of mapping.items() with mapping or mapping.values()
when the key or value is not used.
2026-10-30 20:04:49 -07:00
Paolo Bonzini f5e4bb9bf7 cmake: do not use exe wrapper for build-side subprojects
Fixes: #16314
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-30 19:32:29 +01:00
Paolo Bonzini 94aee3a0c8 build: add subdir and builddir to BuildProject
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-30 19:32:29 +01:00
Paolo Bonzini 9150bb8004 unittests: mark tests that break with MESON_RSP_THRESHOLD 2026-10-30 19:30:07 +01:00
GeorgiaPreda a16910ba49 compilers: Fix ifx standard arguments
ifx ignores the joined argument -stand=f08. What needs to change here is that we need to emit separate arguments.

Fixes #16304
2026-10-30 07:39:42 -07:00
Paolo Bonzini e323ad224b build: keep extra_files from internal dependencies
BuildTarget.__init__ assigned self.extra_files after add_deps().
The assignment discarded files that add_deps() had appended from
declare_dependency(extra_files: ...); prior to commit 97a1c567c,
files from the interpreter were added with self.extra_files.append,
instead now it has to be assigned before add_deps().

Fixes: 97a1c567c ("interpreter: Move validation of BuildTarget(extra_files) to Interpreter", 2025-11-05)
Fixes: #15863
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-28 21:06:37 +01:00
Paolo Bonzini 2b45961e1e interpreter: roll back sub-subprojects when a subproject fails
When a subproject failed, sub-subprojects were left in self.subprojects
but rolled back from the Build object.  This caused different issues
in previous versions of Meson.

Until 1.10, and specifically until commit 1eac5a5, the rollback was partly
ineffective because Build instances shared the content of PerMachine fields
(e.g. dependency_overrides) by reference.  Thus, the content of the
fields propagated to the superproject even without a merge()!
Subprojects-of-failed-subprojects were still included in the build,
because process_target_dependencies() saved the day while still leaving
behind tests, installed files and targets other than used libraries.

Since 1eac5a5 (and 1.11) the sharing bug was fixed, but on the other hand
the overrides were lost, causing warnings such as:

 glib| WARNING: Subproject 'pcre2' did not override 'libpcre2-8' dependency and no variable name specified

Rolling back sub-subprojects ensures that Meson tries them again and
that their expceted overrides are recorded in Build.

The attached test covers both failure modes.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-27 18:34:02 +01:00
Paolo Bonzini b46369e807 build, interpreter: move Summary to BuildProject
This has two effects.  First, it makes it possible to track summaries
separately for host- and build-machine subprojects, which was a bug
in the 1.12 implementation of build-machine subprojects.

Second, it rolls back summaries on failed subprojects, instead of having
to skip them at the end of the run.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-27 18:34:02 +01:00
hassan 7608a50522 detect: support target-prefixed clang-cl and share sibling tool computation
Signed-off-by: hassan <144530465+h55n@users.noreply.github.com>
2026-10-27 11:49:57 +01:00
Charles Brunet 9a4f830790 msvc: use right arguments for compiling std module
With the `cpp_importstd` option and the MSVC compiler, meson now builds the
module with the arguments of the targets that matter to the compiler when it
imports the module: the C runtime, the character set, the C++ standard, the
exception and floating point options, the macros read by the standard library,
and so on. This prevents reporting a C5050 warning, which would become an error
if using `werror`. Arguments that do not matter, such as warnings, optimization
and include directories, are ignored. A module is built for each different set
of arguments, and shared by the targets that have the same one, so the files in
the build directory are named `std.<id>.ifc`.

The module is no longer built through a compiler cache, which cannot restore it.
2026-10-26 12:04:40 -07:00
Charles Brunet 32806289ec format: add sticky_parens option
A new `sticky_parens` option for the `meson format` command now sticks the
parentheses to the outer expression instead of putting them on their own line,
and double-indents continuation lines of the expression.

Fixes #13570.
2026-10-26 11:59:20 -07:00
Rawat Saniya Sohan a11094a941 minstall: raise a clear error when a file blocks directory creation
When bindir and libexecdir are set to the same path, a binary named
(e.g.) 'p11-kit' can be installed first, and then a helper directory
also named 'p11-kit/' is attempted by DirMaker.makedirs().  Because
os.makedirs exist_ok=True only suppresses errors for existing
directories, not files, a cryptic FileExistsError was raised with no
hint about the root cause.

Check each path component inside DirMaker.makedirs() and raise a
MesonException with an actionable message when a component exists but
is not a directory, pointing to the likely cause of mismatched
install-dir options.

Fixes #6254
2026-10-26 19:26:03 +01:00
Dylan Baker 485650c1ef ruff: fix unsafe linter rules for PyFlakes
There is only one fix here, and it's safe in this case, as it's just
removing an unused variable.

Generated with: `ruff check --select F --unsafe-fixes --fix`
2026-10-24 08:13:14 +02:00
Dylan Baker dad37cddba ruff: Fix automatically fixable PyFlakes issues
Generated with: `ruff check --select F --fix`
2026-10-24 08:13:14 +02:00
Charles Brunet 99fe4fef47 format: add suppression directives
`meson format` now leaves untouched the lines between
`# meson-format off` and `# meson-format on` comments. When
`# meson-format off` is not followed by `# meson-format on`, formatting
is disabled until the end of the file.

```meson
sources = files(
  'a.c',      'b.c',
  'c.c',      'd.c',
)
```

Fixes #15922.
2026-10-23 13:55:51 +02:00
Jonathon Anderson 70659de447 search_version: make version regex accept more after hyphen
This change allows the found version number to include additional
hyphens and periods after the first hyphen. This is needed to understand
`clang --version` in some older Ubuntu versions, which prints:

Ubuntu clang version 14.0.0-1ubuntu1.1

This logic also accepts any pre-release version following SemVer 2.0.0
syntax, bullet 9.

Fixes: https://github.com/mesonbuild/meson/issues/16286
Signed-off-by: Jonathon Anderson <anderson.jonathonm@gmail.com>
2026-10-22 15:19:13 +02:00
2025sl93041-gkb 0dc920ffc0 only preserve timestamps for configure_file(copy: true)
shutil.copy2 copies not only the contents of the file but also its metadata, including the permissions; if the source file is read-only (with mode 0444) the destination file becomes read-only as well and this causes the next reconfigure to fail with a PermissionError when Meson attempts to overwrite the output file.

Use shutil.copyfile rather than shutil.copy2 when in copy mode, and preserve timestamps separately. The output file ends up with its default writable permissions, because shutil.copyfile only copies the contents of the file and does not preserve the source permissions, and restoring the modification time ensures that dependents are not rebuilt unnecessarily after each reconfigure. The existing test case 14 already checks that this is the case.
2026-10-22 15:14:14 +02:00
Paolo Bonzini a22689749b unittests: test backend options from the machine file
A backend option from the machine file that the backend does not have
must be an error.  This is currently detected by OptionStore.set_option().

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-19 18:50:26 +02:00
Paolo Bonzini f221904d2c unittests: check that "meson configure" catches unknown backend options
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-19 18:50:26 +02:00
Paolo Bonzini d38ac59709 unittests: improve coverage of $CFLAGS
Add a test that covers the intersection of $CFLAGS and command line
arguments, and rewrite the old test so that it can check both
cl.exe and gcc on all systems.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-19 18:50:26 +02:00
Paolo Bonzini 3a400da686 unittests: test directories that depend on the prefix
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-19 18:50:26 +02:00
hassan 027118e9f1 interpreter: only warn about multiple pkgconfig_define pairs for more than one pair
The validator ran on the flat key/value list, so a single pair (two items) already triggered the FeatureNew warning for 'more than one pair' and a project targeting meson < 1.3.0 got a false warning. Compare against 2 items instead, and add a unit test.
2026-10-19 13:16:07 +02:00
M001N 4621dcb706 msubprojects: fix ValueError due to cross-drive/UNC relpath
Avoid errors like the following when invoking subprojects with a build directory that is on a different drive than the source:

    G:\tmp\meson-test>python \repos\meson\meson.py subprojects update
    Traceback (most recent call last):
      File "\\server\share\repos\meson\mesonbuild\mesonmain.py", line 193, in run
        return options.run_func(options)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "\\server\share\repos\meson\mesonbuild\msubprojects.py", line 723, in run
        source_dir = os.path.relpath(os.path.realpath(options.sourcedir))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen ntpath>", line 783, in relpath
    ValueError: path is on mount '\\\\server\\share', start on mount 'G:'
    
    ERROR: Unhandled python exception

        This is a Meson bug and should be reported!

Fixes: #13814
2026-10-13 14:31:33 +02:00
hassan 4bca17e347 configure_file: don't skip a variable right after an empty replacement 2026-10-13 14:23:10 +02:00
Christian Häggström b3efc56536 cmake: tolerate an unreadable $HOME when probing the user package registry
CMakeDependency._preliminary_find_check looks for ~/.cmake/packages/<Name>
with Path.exists(), which only swallows ENOENT/ENOTDIR/EBADF/ELOOP. On a
host where the build user's home directory exists but is not traversable
(CI service accounts, a root-owned 0700 $HOME, HOME pointing at another
user's directory) the probe raises PermissionError and meson setup dies
with "Unhandled python OSError" on the first dependency() that reaches the
CMake finder.

CMake itself silently ignores an unreadable user package registry. Do the
same: route the check through the existing _cached_isdir helper, which
already turns OSError into "not found".

The path is built with os.path.expanduser() rather than Path.home().
Path.home() raises RuntimeError when the home directory cannot be
determined (HOME unset and no passwd entry for the uid, as in containers
running under an arbitrary uid), so it would have needed its own handler
for a case that should also just mean "not registered".
os.path.expanduser() returns the string unchanged in that case, and a
path starting with '~' is never an existing directory, so no extra
handling is needed.
2026-10-13 12:38:20 +02:00
Paolo Bonzini 3e1c487172 interpreter: parse depfile for configure_file relative to the working directory
Paths in a depfile are relative to the working directory, not the target directory or
even less so the source directory. If the depfile that is produced by the configure_file's
command includes relative paths, make them relative to the build directory.

Fixes: #9851
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-04 20:21:32 +02:00
Zhenyu Liu db12230ef8 find_program: fall through alternate names on version mismatch
When find_program is given multiple names and a version constraint,
continue trying later names if an earlier match fails the version
check. For each name, a machine-file entry is authoritative and
blocks PATH lookup for that name.
2026-10-02 13:05:08 +02:00
Paolo Bonzini 8347a9b449 type_checking: convert false to None for install_mode
False was left alone and later changed to 0 due to bool returning
true for isinstance(x, int).  As a result, using "false" for the uid
and gid caused an error starting with Meson 1.2.0:

 Unable to set owner False and group 'mygroup': Operation not permitted, ignoring...

Similarly, the validator was blocking "1" because it is equal to True.
Fix by checking for bool specifically when turning it into none, and
using "is True" in the validator.

Fixes: #16225
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-01 16:57:44 +02:00
Zhaoqi Xu 078db80a47 backend: substitute @OUTPUT@ in custom_target depfile
@OUTPUT@ in depfile is the output filename, not the full path.
Joining the target directory with an unexpanded @OUTPUT@ token, then
substituting the full output path, doubled the subdirectory in both
@DEPFILE@ and ninja's depfile (include/include/foo.d).

Fixes #14140
2026-10-01 12:20:22 +02:00
Paul Meyer a7ce13c354 mtest: print failed/skipped subtests in summary
Summary now prints failed/skipped subtests in case
--print-errorlogs/--verbose is specified.
With --verbose on the console, all subtests are
listed, including passed ones.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-10-01 12:14:18 +02:00
Paul Meyer 47163040b8 mtest: print skipped TAP subtests count
Previously skipped subtests weren't visible. Print
the count of skipped subtest so we get a better
impression on the coverage of the result.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-10-01 12:14:18 +02:00
Paolo Bonzini af0d75c2c2 cargo: drop patch validation
Patches are now generally supported, at least for crates.io, so
no need to do validation.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-09-28 14:30:48 +02:00
Paolo Bonzini de8aa318ec cargo: parse [patch] table
While at it, run patch validation after building the set of dependencies.
Otherwise, it is not able to match patches against dependencies and will
incorrectly warn.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-09-28 14:30:48 +02:00
Paolo Bonzini 4b3ceff48c cargo: flatten [target] into the unconditional tables
This simplifies the parsing and makes it possible to handle correctly
dependency-named features, which apply equally to all dependencies,
even those that are disabled.  In other words, even if a "win"
dependency is only declared under [target.'cfg(windows)'.dependencies],
"cargo build --features win" succeeds on non-Windows platforms as well.

Due to the new representation, move the merged table into
PackageConfiguration.  This is cleaner, because it doesn't modify the
manifest, and it makes it possible to fully separate dependencies for
the host and build machines.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-09-28 14:30:48 +02:00
Paolo Bonzini b94ec08de5 cargo: canonicalize all paths with as_posix()
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-09-28 14:30:48 +02:00
Paolo Bonzini 7fdfe0eb47 mesonlib: introduce as_posix
Introduce a new function that can be used to join and normalize paths,
and canonicalize them to forward slashes.  It avoids (or rather
hides) use of pathlib for string->string operations.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-09-28 14:30:48 +02:00
GhostCoder6969 9f2e885820 Honor cpp_rtti for Objective-C++ sources
Setting cpp_rtti=false had no effect on .mm files: only C++ compilations got -fno-rtti.
I mapped the rtti compiler option to cpp_rtti for Objective-C++ (the same way cpp_std
is already shared) and added get_option_compile_args so the flag is emitted.

I also registered the option for projects that only enable objcpp.

Fixes #16189.
2026-09-27 11:28:34 +02:00
Paolo Bonzini 9478b2cebe extend nostdlib test to more machines
Some builds of Python leave platform.processor() to an empty string.
Check platform.machine() as well.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-09-24 18:57:16 +02:00
Marcin Sochacki 6fd84127a6 add QNX qcc/q++ support (#16018)
QNX is a commercial POSIX real-time operating system built for safety-critical embedded use (automotive, medical, industrial) and certified to standards like ISO 26262 and IEC 61508.
qcc/q++ are its compiler driver frontends that wrap an underlying toolchain to produce binaries for QNX Neutrino targets.
Adding qcc support to Meson lets projects targeting QNX use Meson as their build system directly,
which is necessary for building components of a safety-certified OS and the safety-critical software that runs on it.
2026-09-24 09:15:04 -07:00
Maxandre Ogeret e6c4e8d040 mintro: include per-subproject options in buildoptions
The configured-builddir path called the option listing without the set
of subprojects, so the per-subproject replication of non-yielding
builtin options only happened for source-only introspection and no
sub: rows were emitted at all. Augments (per-subproject values such as
-Dsub:c_args=...) were additionally never consulted, so even the
source-only rows reported the parent project's value.

Pass coredata.initialized_subprojects on the configured path, add
per-subproject rows for base and compiler options that have an augment
set, and resolve replicated keys through the option store so augments
and yielding are reflected in the reported value. Project options keep
their stored value as before.

Fixes #15993.
2026-09-23 19:31:56 +02:00
Tristan Partin f72fd3f059 Remove unnecessary test
bonzini asked for this to be removed in
https://github.com/mesonbuild/meson/pull/15714#issuecomment-5460886147.

Signed-off-by: Tristan Partin <tristan@partin.io>
2026-09-22 07:18:50 +02:00
Dylan Baker 5d24bc4a61 optinterpreter: typed_pos_args -> TypedArgs 2026-09-21 10:31:12 +02:00
Dylan Baker 5687580d82 interpreter: typed_pos_args -> TypedArgs 2026-09-21 10:31:12 +02:00
Dylan Baker e31a5b78f7 interpreterbase: Add support for positional arguments to TypedArgs 2026-09-21 10:31:12 +02:00
m 84cc9f5d42 envconfig: Autodetect and support BuildCache
Add BuildCache as a supported compiler cache. Also autodetect
the presence of BuildCache as part of detect_compiler_cache().

The order of preference is:

  1. sccache
  2. ccache
  3. buildcache

Thus, when either sccache or ccache is present in the PATH the
compiler cache selection is unaffected by this change.
2026-09-21 10:17:20 +02:00
Tristan Partin 626d1e2632 Filter extra_paths on Windows to only include SharedLibrary targets
determine_windows_extra_paths() on non-Windows is not used for too much.
It is used in two instances. In those two instances, extra_paths has very
narrow use cases.

- Backend::get_devenv(): we add to extra_paths for every
  build.Executable. This also happens on Windows.
- Backend::get_executable_serialisation(): extra_paths is empty on
  non-Windows.

It is important to remember that Windows has no equivalent to
{DY,}LD_LIBRARY_PATH. Instead it looks up DLLs on PATH. Performing this
filter will have an adverse effect on adding build outputs from
build.CustomTarget to PATH. However, when setting {DY,}LD_LIBRARY_PATH,
we filter for build.SharedLibrary explicitly, so it was an oversight in
the original patch[0] to include this additional behavior.

Link: https://github.com/mesonbuild/meson/pull/14649 [0]
Fixes: https://github.com/mesonbuild/meson/issues/16010
Supersedes: https://github.com/mesonbuild/meson/pull/16011
Signed-off-by: Tristan Partin <tristan@partin.io>
2026-09-16 13:26:06 +02:00
Dylan Baker cdbdd59682 interpreterbase: implement a TypedArgs class
This will eventually take over for both typed_kwargs and typed_pos_args,
but for now it implements just the typed_kwarg info.
2026-09-14 10:30:06 -07:00