Commit Graph

14558 Commits

Author SHA1 Message Date
Dylan Baker 47acce8ec9 Provide a better error message when mixing host and build machines
Since we don't get a location for these errors, we can at least tell you
which targets you happen to be mixing together that produce this
problem.

Ran into while trying to debug a target mixing bug.
2024-02-20 09:50:44 -08:00
Charles Brunet b290a82541 Fix KeyError in Python module
0e7fb07 introduced a subtile bug in the Python module.
If a python version is found, but is missing a required module,
it is added to the list of python installations, but the
`run_bytecompile` attribute for that version was not initialized.
Therefore, if any other python version added something to install, it
was raising a KeyError when trying to read the `run_bytecompile`
attribute for the python version with missing module.
2024-02-19 21:52:09 +02:00
Stephan Lachnit 43fe006190 Fix warning when using scan-build
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.
2024-02-19 09:12:12 -05:00
Eisuke Kawashima c46d0e733e doc: fix descriptions of dependency and find_program
They accept list as documented
2024-02-18 16:29:30 -05:00
Daan De Meyer 163d703a18 macros: Allow disabling verbose mode
This allows using "--undefine __meson_verbose" to disable the verbose
mode. This is useful when running rpmbuild in an interactive terminal
and you don't want to be flooded with compilation outputs.

We also add --quiet to the meson install macro if __meson_verbose is
undefined to reduce the output generated by meson install.

The default output stays the same, the output is only affected if
__meson_verbose is explicitly undefined.
2024-02-16 07:43:16 -05:00
Esther Dalhuisen abdb3afd73 coverage: pass .lcovrc config file to genhtml
The .lcovrc file can contain several directives for genhtml, mostly
pertaining the visualisation of the generated HTML report. Passing the
config file to genhtml allows the user to customize their report.

Fixes #12863
2024-02-16 01:32:26 -05:00
Andrew McNulty c80ece2410 workflows: Trigger on all test harness changes
The following workflows have been updated so that they are
triggered when the any of the test harnesses are updated:

  macos,
  os-comp,
  msys2

Previously only changes to `run_unittests.py` caused these
workflows to be executed.
2024-02-14 22:58:40 -05:00
Andrew McNulty c0bf597715 run_project_tests: Fix Cython compiler detection
On Debian systems the cython compiler binary is installed as
`cython3`. The current logic for detecting whether to run the Cython
unit tests instead checks for `cython` or the value of the `CYTHON`
environment variable, which leads to cases where the underlying Meson
can correctly compile Cython code but the test harness excludes these
tests from execution because it cannot find `cython3`.

This commit makes the test harness use the same detection method as
Meson itself. It also takes the opportunity to refactor some existing
code which does the same job for Objective C and Objective C++ tests
to avoid repetition.
2024-02-14 22:58:40 -05:00
Jouke Witteveen efad4ba9c5 docs: Remove outdated HDF5 dependency pkg-config statement
A config-tool method has been supported since c02593f and it says so
just a few lines below the outdated statement.
2024-02-14 19:53:37 +02:00
Eli Schwartz 65ee397f34
cuda module: fully type annotate
Special notes:
- _nvcc_arch_flags is always called with exact arguments, no need for
  default values
- min_driver_version has its args annotation loosened because it has to
  fit the constraints of the module interface?
2024-02-12 23:51:35 -05:00
Eli Schwartz 5899daf25b
cuda module: use typed_pos_args for most methods
The min_driver_version function has an extensive, informative custom
error message, so leave that in place.

The other two functions didn't have much information there, and it's
fairly evident that the cuda compiler itself is the best thing to have
here. Moreover, there was some fairly gnarly code to validate the
allowed values, which we can greatly simplify by uplifting the
typechecking parts to the dedicated decorators that are both really good
at it, and have nicely formatted error messages complete with reference
to the problematic functions.
2024-02-12 23:35:39 -05:00
Eli Schwartz 1b15176168
cuda module: inline single-shot function to get compiler version
It is pretty trivial and more confusing when standalone, especially the
use of a sentinel "unknown" string as a standin for "this isn't one of
the allowed object types". Much easier to directly raise an error in the
fallthrough/else.
2024-02-12 23:13:59 -05:00
Eli Schwartz 8ff25c0bca
cuda module: fix type signature for oneshot function
It is only ever invoked once. It has a statically known signature based
on how it's used, so there's no good reason to allow it to accept any
defaults -- and defaulting to None messes with type safety.

Saturate is always given, so don't claim it is only sometimes.
2024-02-12 23:13:59 -05:00
Eli Schwartz cf35d9b4ce
cuda module: use typed_kwargs
This officially only ever accepted string or array of strings.
2024-02-12 23:12:10 -05:00
Eli Schwartz 6f7e745052
Remove implicit-optional assignment in `__init__` that cannot ever be true
IfClauseNode is only ever initialized in such a way that this attribute
is immediately set to something valid. And attempting to access its
value when the value is None would be a pretty broken error anyway. The
assignment served no purpose, but did perform a frivolous runtime op in
addition to angering mypy's checks for implicit None.
2024-02-12 18:52:43 -05:00
Eli Schwartz fc41fd3542
add type annotations to mesonmain
An oddity: sys.stdout is statically defined as type TextIO instead of
TextIOWrapper, and thus doesn't have a .reconfigure method. This is
because they expect people to override sys.stdout with other objects,
which we do not do. Instead, assume it is always correct.

There are two final errors due to metaprogramming:
```
mesonbuild/mesonmain.py:196:13: error: Returning Any from function declared to return "int"  [no-any-return]
mesonbuild/mesonmain.py:225:9: error: Returning Any from function declared to return "int"  [no-any-return]
```
2024-02-12 18:52:43 -05:00
Eli Schwartz 4e83675bf8
rewriter: remove never-used default None when parsing arguments
The add_arguments function is always called with a formatter in
mesonmain.py, and if it were not, then it would be incorrect when
calling argparse itself -- because formatter_class cannot be None, and
defaults to its own builtin one. This violates None-safety.
2024-02-12 18:52:43 -05:00
Eli Schwartz 6e1556028c
python dependency: use exceptions to pass failure state around
Instead of returning Optional, a state that is only possible during
`__init__` and which prevents mypy from knowing what it is safe to
assume it will get.
2024-02-12 18:52:43 -05:00
Eli Schwartz 546fe0f92b
correct type signature of Popen_safe to follow stdlib subprocess
The standard library accepts None defaults for some kwargs and we should
too.
2024-02-12 18:52:43 -05:00
Eli Schwartz e184ef71e5
cmake dependency: avoid setting property to None as a workaround
It's an improper object model, but was used to signal to a subclass that
self.traceparser did not exist. However, since it is always initialized
from self.cmakebin, we can just check that instead.
2024-02-12 18:52:43 -05:00
Eli Schwartz 07c051ed27
defer setting values until after we know it cannot be None 2024-02-12 18:52:43 -05:00
Eli Schwartz dabe7b16d9
override subclass attribute type when we know it is not None 2024-02-12 18:52:43 -05:00
Eli Schwartz 6be1262cc9
compilers: fix inconsistent None-breaking return value for compile()
Since commit abc7e6af01 it is not possible
for this set of methods to return None, which was an odd thing to return
to begin with. Cease to annotate it as such.
2024-02-12 18:52:43 -05:00
Eli Schwartz dbfc9d0908
dlang module: simplify dependency handling with DRY
It can be a list or a single dependency, but the same logic happens
either way. Instead of manually expanding the logic for both cases, just
convert it to a list as needed.
2024-02-12 18:52:42 -05:00
Charles Brunet f4f50db441 qt: add preserve_paths keyword to functions
This allow to generate ui and moc under subdirectories,
as this is allowed with generic generators.
2024-02-12 15:49:55 -08:00
Sam James 6c2c4612cc Fix comment typo
Oops.

Fixes: 7b7d2e060b
Signed-off-by: Sam James <sam@gentoo.org>
2024-02-13 00:18:38 +02:00
Jouke Witteveen 524a66116b Add MESONREWRITE to `meson dist` scripts
Fixes #688
2024-02-12 22:19:59 +01:00
taz-007 152a45a360 doc: benchmark: correct usage on unix 2024-02-12 12:16:32 -08:00
Akihiko Odaki adf09b8316 Raise if a postconf script fails
Raise MesonException if a postconf script fails to let the user know
about the failure.
2024-02-11 18:28:53 +05:30
Akihiko Odaki ed1a1d567a Print a proper sentence when reporting script failure 2024-02-11 18:28:53 +05:30
Jouke Witteveen 10e269271d backends: restore shlex quoting of MESONINTROSPECT
The type of quoting was changed in 522392e to one that is suitable for
use with cmd.exe on Windows. However, the documentation states that the
type of quoting in MESONINTROSPECT is compatible with shlex.split() and
elsewhere in the code, the same variable is still quoted with
shlex.quote(). As mostly identified in #12148, there are a few choices:
1. Use shlex.quote() consistently and support Python but not cmd.exe.
2. Use join_args and support cmd.exe but not Python.
3. Use join_args and support splitting through the mesonbuild Python library.

This commit implements the first option and reverts part of 522392e.

Regression testing is implemented in #12115.

Fixes #12148
2024-02-10 20:04:18 -05:00
Eli Schwartz 3c7bc8cac3
CI image builder: fix profile loading for gentoo
We need to load various environment variables from /etc/profile. We
cannot unconditionally load it, because opensuse sources env_vars and
their /etc/profile has a fatal bug in it that causes it to return
nonzero and abort under `set -e` (which is *amazing* as a thing to have
in /etc/profile specifically -- just saying).

Alas, even /etc/profile.env is not enough since Java support depends on
profile.d logic. Re-conditionalize this check to only be added to
env_vars.sh for the image named "gentoo".
2024-02-09 16:19:27 -05:00
Eli Schwartz c166b136a6
Suppress LLVM static test on Arch
It is properly detected as unavailable, ever since commit
d1b783fc69
2024-02-09 13:54:58 -05:00
Sam James 7e8b7454f5
test cases: use C++17 for protobuf because of abseil-cpp
On the openSUSE builder, we got a horrifying CI failure like:
```
FAILED: asubdir/subdir-prog.p/main.cpp.o
c++ -Iasubdir/subdir-prog.p -Iasubdir '-I../test cases/frameworks/5 protocol buffers/asubdir' -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++14 -O0 -g -DPROTOBUF_USE_DLLS -DNOMINMAX -MD -MQ asubdir/subdir-prog.p/main.cpp.o -MF asubdir/subdir-prog.p/main.cpp.o.d -o asubdir/subdir-prog.p/main.cpp.o -c '../test cases/frameworks/5 protocol buffers/asubdir/main.cpp'
In file included from /usr/include/google/protobuf/stubs/common.h:20,
                 from /usr/include/google/protobuf/io/coded_stream.h:107,
                 from asubdir/subdir-prog.p/defs.pb.h:26,
                 from ../test cases/frameworks/5 protocol buffers/asubdir/main.cpp:1:
/usr/include/absl/strings/string_view.h:52:26: error: ‘string_view’ in namespace ‘std’ does not name a type
   52 | using string_view = std::string_view;
      |                          ^~~~~~~~~~~
[...]
```

This turns out to be because of a *huge* mess with abseil-cpp and protobuf. We're
still trying to handle it in Gentoo, even (see bgo#912819) and https://github.com/gentoo/gentoo/pull/32281.

In summary, abseil-cpp started to require C++17 (unless built with a special option
which causes ABI problems). Let's switch the protobuf test case to use C++17
accordingly. There's some precedence for Just Doing This, like in cb54f0d707
recently for Boost, and 792a84199b previously for
protobuf itself.

Bug: https://bugs.gentoo.org/912819
See also: https://github.com/gentoo/gentoo/pull/32281
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-02-09 13:54:16 -05:00
Sam James 7d8b925144
ci: fedora; add file package
FAILED unittests/linuxliketests.py::LinuxlikeTests::test_install_strip - FileNotFoundError: [Errno 2] No such file or directory: 'file'

Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-02-09 13:54:15 -05:00
Sam James fe8123b484
ci: add Gentoo
We may want to consider our own binpkg cache for future to speed things up,
in addition to the ones provided by Gentoo's own binhost.

Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-02-09 13:54:01 -05:00
Tristan Partin 87ba248404 Mark the bash completion files for bash and zsh as Shell files
This will add highlighting when viewing on GitHub.
2024-02-09 22:26:46 +05:30
Tristan Partin 4ea51e1b25 Continue fleshing out bash completion script
This adds bash completion to everything that I could think of except for
the rewriter.
2024-02-09 22:26:46 +05:30
Tristan Partin b08d531c02 Document that alias_target accepts run_tgts since 0.60.0
This was implemented in dc51740e2c,
but was not added to the documentation or marked as a new feature.
2024-02-09 11:56:13 -05:00
Nirbheek Chauhan 09c0803077 wraps: Ignore whitespace when applying diff_file
Fixes https://github.com/mesonbuild/meson/issues/12092
2024-02-09 21:04:31 +05:30
Nirbheek Chauhan 348c2e93d2 Revert "Wrap: Use git instead of patch by default"
This reverts commit 718c86a7d5.

We can't always use git to apply patches because they might actually
apply to a git submodule inside a git subproject, and git will not be
able to apply the patch in that case.
2024-02-09 21:04:31 +05:30
Ole André Vadla Ravnås e0d83359aa find_tool: fix error message interpolation 2024-02-08 15:28:18 -08:00
Sam James d1b783fc69
cmake: improve heuristics for static LLVM detection
In 89146e84c9, a heuristic was introduced where
if libLLVMSupport is available as a static library, LLVM itself is assumed
to be availble as a static library as a whole.

This is unfortunately not the case at least on Gentoo and Arch Linux, where
a subsequent llvm-config call yields:
```
$ /usr/lib/llvm/17/bin/llvm-config --libfiles --link-static
llvm-config: error: missing: /usr/lib/llvm/17/lib64/libLLVMTargetParser.a
llvm-config: error: missing: /usr/lib/llvm/17/lib64/libLLVMBinaryFormat.a
llvm-config: error: missing: /usr/lib/llvm/17/lib64/libLLVMBitstreamReader.a
llvm-config: error: missing: /usr/lib/llvm/17/lib64/libLLVMRemarks.a
[...]
```

On Gentoo, where LLVM's static libraries are not included, we still have:
```
$ equery f llvm:17 | grep -i lib64/.*.a$
/usr/lib/llvm/17/lib64/libLLVMDemangle.a
/usr/lib/llvm/17/lib64/libLLVMSupport.a
/usr/lib/llvm/17/lib64/libLLVMTableGen.a
/usr/lib/llvm/17/lib64/libLLVMTestingAnnotations.a
/usr/lib/llvm/17/lib64/libLLVMTestingSupport.a
/usr/lib/llvm/17/lib64/libllvm_gtest.a
/usr/lib/llvm/17/lib64/libllvm_gtest_main.a
```

Therefore, testing for libLLVMSupport is insufficient. We now try libLLVMCore
instead, as that appears to only be installed when LLVM truly has static libraries
available. libLLVMCore is handled as a LLVM component which gives us some guarantee
this is supposed to be happening and not a fluke.

(Specifically, LLVM's llvm/lib/Support/CMakeLists.txt pays 0 attention to
-DLLVM_BUILD_LLVM_DYLIB and -DLLVM_LINK_LLVM_DYLIB, and is hence only affected
by -DBUILD_SHARED_LIBS, which LLVM upstream say is only to be used for development.

Therefore, with -DBUILD_SHARED_LIBS=OFF (as is recommended/the default) and
-DLLVM_BUILD_LLVM_DYLIB=ON, you will get a static libLLVMSupport, without it
indicating anything about the rest of your configuration.)

Closes: https://github.com/mesonbuild/meson/issues/12323
Fixes: 89146e84c9
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-02-07 23:41:37 -05:00
Sam James 369cc28e59
Fix comment typos
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-02-07 23:41:36 -05:00
Sam James 99ea390af8
cmake: canonicalise -DSTATIC value
CMake really prefers ON/OFF and in some cases, depending on how the condition
is written, ON/OFF vs other "truthy" (as far as CMake's lang supports) values
work differently. Just be safe and use ON/OFF.

Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Eli Schwartz <eschwartz93@gmail.com>
2024-02-07 23:41:35 -05:00
Charles Brunet 9659a8e6cf Fix minsize optimization for vs backend
Fixes #12265
2024-02-07 02:40:51 +05:30
Ralf Gommers 80ed1dfa7f Add a numpy dependency with pkg-config and configtool methods
These are being added for NumPy 2.0 The implementation closely follows
the one for the pybind11 dependency.
2024-02-06 12:54:35 -08:00
Jouke Witteveen db51dcfa47 mdist: Hoist leftover late import
From 23d3b98, the meson command is exposed through a function.
Therefore, the caveat no longer applies.
2024-02-03 16:40:00 +01:00
H. Vetinari 6fcf8632c6 fix UnboundLocalError if guess_win_linker fails in detect_fortran_compiler 2024-02-02 09:24:41 -08:00
Eli Schwartz cb54f0d707
test cases: pass the c++11 std to boost-using code
Apple Clang defaults to C++03 or earlier, and boost 1.84 has started
requiring C++11 as a minimum. Fixes test failures on the macOS builders.

Unneeded for GCC systems since GCC defaults to a more recent std -- but
also semantically correct there too.
2024-02-01 10:25:27 -05:00