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.
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>
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
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>
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>
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>
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>
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>
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>
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>
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.
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.
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.
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.
`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.
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)
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
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
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>
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.
@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
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>
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.
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.
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>
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>
'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>
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.