From 1ceba9367c27ec3586766df242081ef55ba56f66 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Wed, 18 Sep 2024 21:54:02 +0200 Subject: [PATCH] meson/setup-hook.sh: make build directory configurable --- doc/hooks/meson.section.md | 10 ++++++++++ pkgs/by-name/me/meson/setup-hook.sh | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/hooks/meson.section.md b/doc/hooks/meson.section.md index 3a7fb5032082..c3cd89b12e89 100644 --- a/doc/hooks/meson.section.md +++ b/doc/hooks/meson.section.md @@ -18,6 +18,16 @@ setup hook registering ninja-based build and install phases. Controls the flags passed to `meson setup` during configure phase. +#### `mesonBuildDir` {#meson-build-dir} + +Directory where Meson will put intermediate files. + +Setting this can be useful for debugging multiple Meson builds while in the same source directory, for example, when building for different platforms. +Different values for each build will prevent build artefacts from interefering with each other. +This setting has no tangible effect when running the build in a sandboxed derivation. + +The default value is `build`. + #### `mesonWrapMode` {#meson-wrap-mode} Which value is passed as diff --git a/pkgs/by-name/me/meson/setup-hook.sh b/pkgs/by-name/me/meson/setup-hook.sh index 55ea8b5c1d97..a88a276f09a8 100644 --- a/pkgs/by-name/me/meson/setup-hook.sh +++ b/pkgs/by-name/me/meson/setup-hook.sh @@ -3,6 +3,8 @@ mesonConfigurePhase() { runHook preConfigure + : ${mesonBuildDir:=build} + local flagsArray=() if [ -z "${dontAddPrefix-}" ]; then @@ -28,8 +30,8 @@ mesonConfigurePhase() { echoCmd 'mesonConfigurePhase flags' "${flagsArray[@]}" - meson setup build "${flagsArray[@]}" - cd build || { echoCmd 'mesonConfigurePhase' "could not cd to build"; exit 1; } + meson setup "$mesonBuildDir" "${flagsArray[@]}" + cd "$mesonBuildDir" || { echoCmd 'mesonConfigurePhase' "could not cd to $mesonBuildDir"; exit 1; } if ! [[ -v enableParallelBuilding ]]; then enableParallelBuilding=1