summaryrefslogtreecommitdiff
path: root/eclass/out-of-source-utils.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2023-01-07 18:14:11 +0000
committerV3n3RiX <venerix@koprulu.sector>2023-01-07 18:14:11 +0000
commit7a027cd18c60d9abad83a60c98ccf27db26be067 (patch)
tree905c5e3c3ec66d8d756a71db384bdd7abf7a50f9 /eclass/out-of-source-utils.eclass
parentd4d70691ab58dfcbd58e0863f3e64d59765533e3 (diff)
gentoo auto-resync : 07:01:2023 - 18:14:11
Diffstat (limited to 'eclass/out-of-source-utils.eclass')
-rw-r--r--eclass/out-of-source-utils.eclass43
1 files changed, 43 insertions, 0 deletions
diff --git a/eclass/out-of-source-utils.eclass b/eclass/out-of-source-utils.eclass
new file mode 100644
index 000000000000..d68b21088995
--- /dev/null
+++ b/eclass/out-of-source-utils.eclass
@@ -0,0 +1,43 @@
+# Copyright 2022-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: out-of-source-utils.eclass
+# @MAINTAINER:
+# Michał Górny <mgorny@gentoo.org>
+# @AUTHOR:
+# Michał Górny <mgorny@gentoo.org>
+# @SUPPORTED_EAPIS: 6 7 8
+# @BLURB: Utility functions for building packages out-of-source
+# @DESCRIPTION:
+# This eclass provides a run_in_build_dir() helper that can be used
+# to execute specified command inside BUILD_DIR.
+
+case ${EAPI} in
+ 6|7|8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+if [[ ! ${_OUT_OF_SOURCE_UTILS_ECLASS} ]]; then
+_OUT_OF_SOURCE_UTILS_ECLASS=1
+
+# @FUNCTION: run_in_build_dir
+# @USAGE: <argv>...
+# @DESCRIPTION:
+# Run the given command in the directory pointed by BUILD_DIR.
+run_in_build_dir() {
+ debug-print-function ${FUNCNAME} "${@}"
+ local ret
+
+ [[ ${#} -eq 0 ]] && die "${FUNCNAME}: no command specified."
+ [[ -z ${BUILD_DIR} ]] && die "${FUNCNAME}: BUILD_DIR not set."
+
+ mkdir -p "${BUILD_DIR}" || die
+ pushd "${BUILD_DIR}" >/dev/null || die
+ "${@}"
+ ret=${?}
+ popd >/dev/null || die
+
+ return ${ret}
+}
+
+fi