commit:     dbeb507f468dcc75095d54b59c165dcc70ef558d
Author:     Eli Schwartz <eschwartz93 <AT> gmail <DOT> com>
AuthorDate: Wed Apr  3 04:24:23 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Apr  4 01:06:39 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dbeb507f

meson.eclass: set working directory to BUILD_DIR

In phases where the build directory has been configured and we are
operating on it, it is better to change directories instead of passing
-C options. This allows portage to know where we are, and in the case of
errors it will then print:

 * Working directory: 
'/var/tmp/portage/www-client/elinks-0.16.1.1-r2/work/elinks-0.16.1.1-build'
 * S: '/var/tmp/portage/www-client/elinks-0.16.1.1-r2/work/elinks-0.16.1.1'

instead of simply listing both as the same directory. This is much more
convenient to copy/paste for the sake of entering the failed build and
examining it.

Signed-off-by: Eli Schwartz <eschwartz93 <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/meson.eclass | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/eclass/meson.eclass b/eclass/meson.eclass
index 3074fcb09fb0..9d7f830e58b0 100644
--- a/eclass/meson.eclass
+++ b/eclass/meson.eclass
@@ -435,8 +435,9 @@ meson_src_configure() {
 meson_src_compile() {
        debug-print-function ${FUNCNAME} "$@"
 
+       pushd "${BUILD_DIR}" > /dev/null || die
+
        local mesoncompileargs=(
-               -C "${BUILD_DIR}"
                --jobs "$(get_makeopts_jobs 0)"
                --load-average "$(get_makeopts_loadavg 0)"
        )
@@ -451,6 +452,8 @@ meson_src_compile() {
        set -- meson compile "${mesoncompileargs[@]}"
        echo "$@" >&2
        "$@" || die -n "compile failed"
+
+       popd > /dev/null || die
 }
 
 # @FUNCTION: meson_src_test
@@ -460,9 +463,10 @@ meson_src_compile() {
 meson_src_test() {
        debug-print-function ${FUNCNAME} "$@"
 
+       pushd "${BUILD_DIR}" > /dev/null || die
+
        local mesontestargs=(
                --print-errorlogs
-               -C "${BUILD_DIR}"
                --num-processes "$(makeopts_jobs "${MAKEOPTS}")"
                "$@"
        )
@@ -470,6 +474,8 @@ meson_src_test() {
        set -- meson test "${mesontestargs[@]}"
        echo "$@" >&2
        "$@" || die -n "tests failed"
+
+       popd > /dev/null || die
 }
 
 # @FUNCTION: meson_install
@@ -479,8 +485,9 @@ meson_src_test() {
 meson_install() {
        debug-print-function ${FUNCNAME} "$@"
 
+       pushd "${BUILD_DIR}" > /dev/null || die
+
        local mesoninstallargs=(
-               -C "${BUILD_DIR}"
                --destdir "${D}"
                --no-rebuild
                "$@"
@@ -489,6 +496,8 @@ meson_install() {
        set -- meson install "${mesoninstallargs[@]}"
        echo "$@" >&2
        "$@" || die -n "install failed"
+
+       popd > /dev/null || die
 }
 
 # @FUNCTION: meson_src_install

Reply via email to