meson.setupHook: build test targets

In Meson 1.7, these will no longer be built by default [1], so because
we're running meson test with --no-rebuild, we need to build them
before running the test.  Doing this in checkPhase makes more sense
than in buildPhase, because allows buildPhase to work without
test-only dependencies, something we've had to work around in the past
by adding options to packages to disable building the tests.

The meson-test-prereq target has been available since Meson 0.63.0
according to the documentation, so we can do this ahead of actually
upgrading to Meson 1.7.0.

Link: https://mesonbuild.com/Release-notes-for-1-7-0.html#test-targets-no-longer-built-by-default [1]
This commit is contained in:
Alyssa Ross
2025-01-30 10:22:56 +01:00
parent f3ef7bf9f9
commit 4745969cb3
+8
View File
@@ -58,6 +58,14 @@ mesonCheckPhase() {
flagsArray+=("--timeout-multiplier=0")
fi
# Parallel building is enabled by default.
local buildCores=1
if [ "${enableParallelBuilding-1}" ]; then
buildCores="$NIX_BUILD_CORES"
fi
TERM=dumb ninja -j"$buildCores" $ninjaFlags "${ninjaFlagsArray[@]}" meson-test-prereq
echoCmd 'mesonCheckPhase flags' "${flagsArray[@]}"
meson test --no-rebuild --print-errorlogs "${flagsArray[@]}"