commit:     0814334901bc20945e98eacebed6f44a53d91713
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 30 16:30:28 2020 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Tue Sep  1 18:50:49 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=08143349

cmake.eclass: cmake_run_in: New function

Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 eclass/cmake.eclass | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
index f43d5af0f7a..5ea1bd125c7 100644
--- a/eclass/cmake.eclass
+++ b/eclass/cmake.eclass
@@ -147,6 +147,22 @@ _cmake_check_build_dir() {
        einfo "Working in BUILD_DIR: \"$BUILD_DIR\""
 }
 
+# @FUNCTION: cmake_run_in
+# @USAGE: <working dir> <run command>
+# @DESCRIPTION:
+# Set the desired working dir for a function or command.
+cmake_run_in() {
+       if [[ -z ${2} ]]; then
+               die "${FUNCNAME[0]} must be passed at least two arguments"
+       fi
+
+       [[ -e ${1} ]] || die "${FUNCNAME[0]}: Nonexistent path: ${1}"
+
+       pushd ${1} > /dev/null || die
+               "${@:2}"
+       popd > /dev/null || die
+}
+
 # @FUNCTION: cmake_comment_add_subdirectory
 # @USAGE: <subdirectory>
 # @DESCRIPTION:

Reply via email to