3833 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
Courtney Richard Pitcher 1030586678 A unit test that runs on the Meson CI logs the entire os.environ, potentially leaking secrets. Consumers may also run these test suits on their CI, exposing their own secrets. 2026-11-03 06:12:58 -08: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
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 83fba12da2 interpreter, modules: add current_build_dir and use it for joining to environment.get_build_dir()
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-30 19:32:29 +01:00
Paolo Bonzini 7d165d9640 backend: move RSP file syntax and quoting to rspfile.py
Move functions to handle RSP files out of linkers/base.py and ninjabackend.py,
so that backends.py can use them when it writes response files for custom
targets.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-30 19:30:07 +01:00
Dylan Baker 95cc93bbac tests: Delete temporary files being written into source dir (again)
They were accidentally committed in 67d7ddb36
Then deleted in 45bfeba38
And were accidentally committed again in e6c4e8d04

So let's not just delete them, let's add a gitignore so they don't
get re-added
2026-10-30 14:53:05 +01:00
Paolo Bonzini 9684d6b922 override_find_program: allow overriding multiple times with the same executable
override_find_program collapses `native: true` to `native: false` when
not cross compiling.  When wishing to add an override for both machines,
for example because a program has machine-independent output, this
causes the same (name, machine) pair to be overridden twice.  As a
special exception allow repeated override_find_program when the
executable is the same.

Add documentation about how to call override_find_program properly
for such a program.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-30 14:52:37 +01: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
Paolo Bonzini d763cf1070 interpreter: fix inconsistent machine between do_subproject() and _do_subproject_*()
In order to check for recursive inclusion, do_subproject() looks up the
subproject using `self.build.machine_map[kwargs['for_machine']]`.
However, _do_subproject_meson() registered the holder and
pushed the subproject stack using just `kwargs['for_machine']`.
The two differ when build-machine subprojects request a subproject
with `native: false`, causing two bugs that are now fixed:

- first, a second request for the same sub-subproject did not find the first
  one, and configured it again causing a "Second call to project()" error.

- second, the host machine was incorrectly passed to the CMakeInterpreter
  for subprojects of build-machine subprojects.  CMakeInterpreter
  uses it directly to look up env.coredata, without going through the
  machine map, so the mapping must be done in the interpreter.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-27 18:34:02 +01:00
Paolo Bonzini c469bd779c interpreter: fix inconsistent machine between do_subproject() and calls to self.disabled_subproject()
In order to correctly check for failing subprojects inclusion,
calls to self.disabled_subproject() need to use the correct
machine.  Ensure this is the case by making for_machine a
non-optional parameter.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-27 18:34:02 +01:00
Paolo Bonzini d275d164b5 ninjabackend: allow build- and host-machine subprojects to define same-named RunTargets
Building glib as both a build- and a host-machine subproject causes
a failure in the ninja backend due to "Multiple producers for Ninja
target 'glib@@glib20-pot'".  Fix it by adding the "build." prefix to the
build-side subproject; while this does not necessarily make much sense
for the specific case of the POT update, it is the right thing to do in
general for run_target and alias_target.

The other backends do not have the same problem because they name
run targets after target.get_id().

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-27 18:34:02 +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 f552a759b7 format: fix indentation of continuation lines 2026-10-26 11:59:20 -07:00
Charles Brunet 8215a380e9 format: fix formatting of nested parentheses 2026-10-26 11:59:20 -07:00
Charles Brunet b3825b7f72 format: fix indentation after comments
Fix some cases where lines were not correctly indented after a comment.
2026-10-26 11:59:20 -07:00
Charles Brunet 27ab762eee format: fix off-by-one error when splitting fct
There was a bug because closing parenthesis of functions and methods was
not counted when computing line length for splitting long lines.
2026-10-26 11:59:20 -07:00
Charles Brunet d017fb87ae format: fix long lines splitting
A subtle bug in the line splitting algorithm was causing some lines to
be splitted when this was unnecessary. The algorithm now splits only the
outermost element that isn't splitted yes. We also increased the number
of possible iterations, but it should have no effets on most cases
because of the early exist in the loop.
2026-10-26 11:59:20 -07:00
Charles Brunet 2f015552f2 format: indent inside multilines parens
Simplify indentation code and fix a bug causing arguments of a call
inside multiline parentheses to be not indented correctly.
2026-10-26 11:59:20 -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
Dylan Baker dad37cddba ruff: Fix automatically fixable PyFlakes issues
Generated with: `ruff check --select F --fix`
2026-10-24 08:13:14 +02:00
Paolo Bonzini d8b968fa10 interpreter: store separate project arguments for native: true/false
add_project_arguments() in a subproject built for the build machine
maps "native" through machine_map before choosing the slot of the
BuildProject, so the arguments are stored in the BUILD slot.  This
makes build-side subprojects clump together "native: true" and
"native: false" arguments, resulting in duplicate arguments.  Worse,
the backends read the slot of the original machine of the target,
which is HOST for a target without "native: true", so the arguments
were not used.

Do not apply the machine map when writing the arguments, so that both
the writer and the reader then use the requested machine, as in a host
project.  Only add_project_dependencies() still needs the resolved
machine, but only to find the compiler.
2026-10-24 08:10:08 +02:00
Paolo Bonzini e73c026c6d tests: add simple test for add_global_arguments in build-machine subprojects
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-24 08:10:08 +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
Paolo Bonzini c72b5f2461 test cases: rust: do not use rustup anymore
It is not needed - the CI run now adds explicitly the libdir to PATH.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-22 09:15:38 +02:00
Charles Brunet 14cd82080f qt: fix compile_moc with empty sources or headers
In qtmodule.compile_moc(), sources and headers arguments were wrongly
marked as `allow_empty=False`, causing the default `[]` value to raise
an exception. While having both arguments empty is not allowed (which is
verified in the _compile_moc_impl() function), having one or the other
is absolutely possible.

Fixes: 249a14a62 ("modules/qt: Use KWargInfo.since_values", 2026-08-17)
2026-10-21 12:59:02 +02:00
Eli Schwartz 9abb11cf6d interpreter: do not evaluate "kwargs: xxx" when assigning dicts
This causes the following goofy behavior:
```
17:53 <Arsen> foreach t : [{'kwargs': {'env': {'CFLAGS': '-DFOO -DBAR'}}}]
17:53 <Arsen>   debug('funky', t)
17:53 <Arsen> endforeach
17:53 <Arsen> Debug: funky {'env' : {'CFLAGS' : '-DFOO -DBAR'}}
```

... because the value of the dict at "t", is expanded from "kwargs".

The docs say it applies to function calls, not primitive ops. And in
principle, there's no reason not to support evaluating

```
blah = ...

func(kwargs: blah['kwargs'])
```

regardless of how subjectively useful packing them into a nested
dictionary might be.

While at it, add a testcase for the "bonus for thinking meta"
case of a dictionary with 'kwargs' as a key.

Fixes: https://github.com/mesonbuild/meson/issues/15093
2026-10-20 18:14:45 +02:00
Christoph Reiter 7a4cf8ddc8 CI/MSYS2: remove gccx86ninja job
MINGW32/32bit is long deprecated in MSYS2 and they have already dropped
most packages from their repos, so there are likely not many users left.

Stop wasting CI/maintenance time and remove the job.

Since this removes the only job testing ncurses move that to one of the
other remaining ones.

This change was suggested in https://github.com/mesonbuild/meson/pull/16270#issuecomment-6273438225
2026-10-20 06:28:29 -07:00
Paolo Bonzini 19985ff4f2 modules: gnome: check that one of main_sgml and main_xml is provided
Found while retesting #3317.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-13 17:07:04 +02:00
Jonathon Anderson 213b273552 cuda: add tests for new modules
Includes CUPTI (main, checkpoint, and pcsamplingutil APIs) and NVVM.

Signed-off-by: Jonathon Anderson <anderson.jonathonm@gmail.com>
2026-10-13 06:09:39 -07:00
Paolo Bonzini 3f5709dda9 test cases: fix depfile produced by configure_file test
Since the generator program is run from the build directory, the path
is relative to that directory, but the "depfile" source is in the source
tree.  Fix to include the relative path from build to source directory.

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 14c09fe3e4 build: print an error if linking with Rust is requested but no .rs file is present
Fixes: #15435
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-10-01 16:59:12 +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
Paolo Bonzini ce332fe6e9 cargo: add tests for Cargo dependency patching
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-09-28 14:30:48 +02:00
Paolo Bonzini f198b7198d cargo: allow extra_members to include disabled path dependencies
Allow force-including dependencies that would normally be compiled out.
These would not be built by default by cargo, but they would still be
accessible via `-p`.

Allow doing the same in Meson, which will be even more useful when it
will allow including a build-side package too, via build-dependencies.
2026-09-28 14:30:48 +02:00
Frank Richter 41d62c9cab Add a test case triggering warning after adding nasm language 2026-09-24 13:18:59 +02:00
Paolo Bonzini 245448ad8f external-project: Test env kwarg 2026-09-23 21:36:43 +02: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
Paolo Bonzini f29e21ccd3 add regression test 2026-09-22 08:59:01 -07:00
Dylan Baker bf078d152d optinterpreter: set current_node when reducing 2026-09-22 17:02:23 +02:00
Paolo Bonzini ee24d3e9df structured_sources: forbid grabbing structured_sources from outside the current project 2026-09-22 09:15:57 +02:00
Paolo Bonzini fb92e2f304 test cases: cover structured_sources layouts that need a copy
StructuredSources.needs_copy() only checks whether any of the sources is
generated; it never checks that the layout requested through the dictionary
keys matches the layout in the source tree.  Add two cases that failed
to compile before Meson 1.13.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-09-22 09:15:57 +02:00
Paolo Bonzini 0ce0b3a02c build: canonicalize paths in StructuredSources, detect ../
The same directory within the structure can be spelled in several ways,
and so far the dictionary keys were used verbatim.  Ensure that both
the constructor and __add__ canonicalize paths, which prepares for fixing
needs_copy() and also makes it easier to detect paths that leave the root.

While at it, stop sharing the source lists between the operands of __add__
and the result, which happened due to shallow copying of self.sources.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-09-22 09:15:57 +02:00
Paolo Bonzini 59c52a6299 test cases: use a separate file for nocopy tests
'copy-no-gen-with-non-rs' (which mixes '../empty.file' with
'main-unique.rs') should actually copy its sources.  Give the no-copy
targets a file of their own so that no_copy_test.py is not confused when
that is fixed.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-09-22 09:15:57 +02:00
Paolo Bonzini 7e641d1b24 test cases: fix cbindgen test case
structured_sources('lib2.rs', {'sub' : 'sub.rs'}) declares the file at sub/sub.rs, but lib2.rs says mod sub;, which rustc resolves to
sub.rs or sub/mod.rs. It only worked because needs_copy() incorrectly
returns False.
2026-09-22 09:15:57 +02:00