`outfilelist` is the output list of the target, while `outfiles` is the output
list of the individual commands
Bug: mesonbuild/meson/pull/13304#issuecomment-2226398671
The clang-tidy-fix target uses run-clang-tidy to do the fixing, however
this script itself spawns `os.cpu_count()` threads as part of its
internal parallelism. When combined with Meson's parallelism this
results in the creation of potentially thousands of unecessary threads.
This commit rewrites the clang-tidy-fix to perform the same task
run-clang-tidy does but exclusively on Meson's thread pool. "Fix-it"
snippets are saved to `meson-private/clang-tidy-fix/` by a parallel
clang-tidy phase, afterwards (to avoid races) all collected fixes are
applied with a single call to clang-apply-replacements.
Rust-analyzer relies on sysroot to discover its proc-macro server [1] which is
typically installed at <sysroot>/libexec/rust-analyzer-proc-macro-srv. When
used with rust-project.json, rust-analyzer expects the json file to specify
sysroot and fails to launch the proc-macro server otherwise.
So add sysroot to the meson-generated rust-project.json and point it to the
sysroot of the detected rustc compiler.
[1] https://github.com/rust-lang/rust-analyzer/blob/2024-09-16/crates/project-model/src/sysroot.rs#L175
Signed-off-by: Junjie Mao <junjie.mao@hotmail.com>
create_target_linker_introspection is only ever called from one place,
which passes in CompilerArgs. This was implemented in commit
5eb55075ba which performed this conversion
as a preventative measure, since its type was not obvious (and thereby
modified the *type* of the variable in place).
We have a function that wraps two others because it first checks whether
the input is static or shared. By the same token, it has to return types
valid for either. We already *know* that we are a shared library, so we
can and should use the real function directly, which is both a
micro-optimization of function call overhead, and fixes a mypy
"union-attr" error.
This is a bit of a hack, since the rule is added outside of the
`__init__` method, and that's probably bad. But at least we can get some
additional help by telling type checkers what it will be
At an OS level, Unix-like OSes usually have very large or even
unlimited sized command line limits. In practice, however, many
applications do not handle this (intentionally or otherwise). Notably
Wine has the same limits Windows does, 32,768 characters. Because we
previously double counted most characters, we papered over most
situations that we would need an RSP file on Unix-like OSes with Wine.
To fix this issue I have set the command line limit to 32k, this is
still a massive command line to pass without an RSP file, and will only
cause the use of an RSP file where it is not strictly necessary in a
small number of cases, but will fix Wine applications. Projects who wish
to not use an RSP file can still set the MESON_RSP_THRESHOLD environment
variable to a very large number instead.
Fixes: #13414
Fixes: cf0fecfce ("backend/ninja: Fix bug in NinjaRule.length_estimate")
This causes us to not count the spaces between arguments, thereby
undercounting the number of elements. This is extra important because we
previously double counted all actual characters, covering this issue up.
Fixes: cf0fecfce ("backend/ninja: Fix bug in NinjaRule.length_estimate")
* Ensure private directory exists for custom targets
Some custom target commands will expect the `@PRIVATE_DIR@` to already exist, such as with `make -C @PRIVATE_DIR@ ...`
* Prefer `exist_ok` over catching exception
Instead of invoking javac for every .java file, pass all of the sources
for a jar target to a single javac invocation. This massively improves
first compilation time and doesn't meaningfully affect incremental builds
(it can even be faster in some cases).
The old approach also had issues where files would not always get recompiled
even though they should, necessitating a clean rebuild in order to see changes
reflected in the build output.
Multiple invocations seem to only make sense if:
- issues with files not getting flagged for rebuild are investigated and fixed
- something like the javaserver buildtool from openjdk sources is used
instead of directly spawning javac processes
- the amount of java files per jar is so large that it is faster to compile
several files one by one than to compile all the files at once (batching may
still make sense to get a reasonable balance)
C#, Java, and Swift targets were manually collecting compiler arguments
rather than using the helper function for this purpose. This caused each
target type to add arguments in a different order, and to forget to add
some arguments respectively:
C#: /nologo, -warnaserror
Java: warning level (-nowarn, -Xlint:all, -Xdoclint:all), debug arguments
(-g, -g:none), -Werror
Swift: -warnings-as-errors
Fix this. Also fix up some no-longer-unused argument processing in the
Compiler implementations.
The code would create a dictionary that was of type `str : list[str] |
str | None`. Then would later try to call `len(' '.join(dict[key]))`.
This would result in two different bugs:
1. If the value is `None` it would except, since None isn't iterable
and cannot be converted to a string
2. If the value was a string, then it would double the length of the
actual string and return that, by adding a space between each
character
When getting debug file arguments we can sometimes pass None, where a
None is unexpected. This becomes a particular problem in the Cuda
compiler, where the output will unconditionally be concatenated with a
static string, resulting in an uncaught exception. This is really easy
to spot once we annotate the functions in question, where a static type
checker like mypy easily spots the issue.
This commit adds those annotations, and then fixes the resulting error.
Fixes: #12997
There's a known ninja bug
(https://github.com/ninja-build/ninja/issues/1952) that running this
with dyndeps will result in Ninja deleting implicit outputs from the
dyndeps, leading to pointless rebuilds. For reference, this is what
CMake does as well.
We already have to decide whether to scan a file at configure time, so
we don't want to have to do it again at compile time, every time the
depscan rule is run. We can do this by saving and passing the language
to use in the pickle, so depscan doesn't have to re-calculate it. As an
added bonus, this removes an import from depscan
We don't need to write and pass two separate files to the depscanner,
I've used the pickle because the pickle serializer/deserializer should
be faster than JSON, thought I haven't tested.
We'll need it in a moment for get_base_compile_args -> get_assert_args.
Bug: https://github.com/mesonbuild/meson/issues/12962
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
When linking with a Rust rlib, we should also link with its external
system dependencies. This was currently done only for C ABI crates, do
it for both rlib and staticlib now.
Using scan-build gives the following warning:
"Running the setup command as `meson [options]` instead of
`meson setup [options]` is ambiguous and deprecated."
This commit fixes this issue by adding the setup keyword to the meson command.
This patch adds 'depends' keyword to compiler.preprocess().
It allows to execute other targets before doing the preprocessing.
Test-case is added to demonstrate that functionality: it
generates the header before preprocessing the C source that
uses that generated header.
Thanks to @bruchar1 for getting this patch to work.
* Vala: depend on gresources
Valac uses gresource at compile time to look up .ui files
* Automatically pass `--gresourcesdir` to valac
* gnome.compile_resources: clean up duplicate paths better
* Add a test for improved gresouce handling
Nvcc doesn't support `-MQ` flag, so we have to manually escape cuda
target name.
This commit escape `$out` to `$CUDA_ESCAPED_TARGET`, so now we can just
use `-MT` flag in nvcc to generate header dependencies.
This replaces all of the Apache blurbs at the start of each file with an
`# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing
uses to be consistent in capitalization, and to be placed above any
copyright notices.
This removes nearly 3000 lines of boilerplate from the project (only
python files), which no developer cares to look at.
SPDX is in common use, particularly in the Linux kernel, and is the
recommended format for Meson's own `project(license: )` field