public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass
@ 2023-01-01 15:59 Michał Górny
  2023-01-01 15:59 ` [gentoo-dev] [PATCH 2/5] multibuild.eclass: Provide run_in_build_dir from out-of-source-utils Michał Górny
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Michał Górny @ 2023-01-01 15:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Introduce a new out-of-source-utils.eclass to carry run_in_build_dir()
helper function.  This function used to be defined in multibuild.eclass
and indirectly exposed through the eclasses using it.  However, it is
used rather rarely and it is technically also useful for
out-of-source.eclass, so it makes more sense for it to be standalone.
In the end, eclasses are cheap.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/out-of-source-utils.eclass | 43 +++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 eclass/out-of-source-utils.eclass

diff --git a/eclass/out-of-source-utils.eclass b/eclass/out-of-source-utils.eclass
new file mode 100644
index 000000000000..450237b224b3
--- /dev/null
+++ b/eclass/out-of-source-utils.eclass
@@ -0,0 +1,43 @@
+# Copyright 2022 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} unsupported."
+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
-- 
2.39.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-dev] [PATCH 2/5] multibuild.eclass: Provide run_in_build_dir from out-of-source-utils
  2023-01-01 15:59 [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass Michał Górny
@ 2023-01-01 15:59 ` Michał Górny
  2023-01-01 15:59 ` [gentoo-dev] [PATCH 3/5] multilib-build.eclass: Stop providing multibuild.eclass Michał Górny
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2023-01-01 15:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Remove the duplicate definition of run_in_build_dir() function
and inherit out-of-source-utils to retain it for compatibility with
the existing ebuilds in EAPIs 6, 7 and 8.  In future EAPIs, the ebuilds
needing it will inherit out-of-source-utils directly.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/multibuild.eclass | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/eclass/multibuild.eclass b/eclass/multibuild.eclass
index 7ae03adbe18c..37d6ff104f2e 100644
--- a/eclass/multibuild.eclass
+++ b/eclass/multibuild.eclass
@@ -14,7 +14,10 @@
 # implementations).
 
 case ${EAPI} in
-	6|7|8) ;;
+	6|7|8)
+		# backwards compatibility for run_in_build_dir
+		inherit out-of-source-utils
+		;;
 	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
@@ -175,26 +178,6 @@ multibuild_copy_sources() {
 	multibuild_foreach_variant _multibuild_create_source_copy
 }
 
-# @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
-
-	[[ ${#} -ne 0 ]] || die "${FUNCNAME}: no command specified."
-	[[ ${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}
-}
-
 # @FUNCTION: multibuild_merge_root
 # @USAGE: <src-root> <dest-root>
 # @DESCRIPTION:
-- 
2.39.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-dev] [PATCH 3/5] multilib-build.eclass: Stop providing multibuild.eclass
  2023-01-01 15:59 [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass Michał Górny
  2023-01-01 15:59 ` [gentoo-dev] [PATCH 2/5] multibuild.eclass: Provide run_in_build_dir from out-of-source-utils Michał Górny
@ 2023-01-01 15:59 ` Michał Górny
  2023-01-01 15:59 ` [gentoo-dev] [PATCH 4/5] python-r1.eclass: " Michał Górny
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2023-01-01 15:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/multilib-build.eclass | 1 -
 1 file changed, 1 deletion(-)

diff --git a/eclass/multilib-build.eclass b/eclass/multilib-build.eclass
index 40cc426a1359..8984600055a5 100644
--- a/eclass/multilib-build.eclass
+++ b/eclass/multilib-build.eclass
@@ -7,7 +7,6 @@
 # @AUTHOR:
 # Author: Michał Górny <mgorny@gentoo.org>
 # @SUPPORTED_EAPIS: 6 7 8
-# @PROVIDES: multibuild
 # @BLURB: flags and utility functions for building multilib packages
 # @DESCRIPTION:
 # The multilib-build.eclass exports USE flags and utility functions
-- 
2.39.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-dev] [PATCH 4/5] python-r1.eclass: Stop providing multibuild.eclass
  2023-01-01 15:59 [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass Michał Górny
  2023-01-01 15:59 ` [gentoo-dev] [PATCH 2/5] multibuild.eclass: Provide run_in_build_dir from out-of-source-utils Michał Górny
  2023-01-01 15:59 ` [gentoo-dev] [PATCH 3/5] multilib-build.eclass: Stop providing multibuild.eclass Michał Górny
@ 2023-01-01 15:59 ` Michał Górny
  2023-01-01 15:59 ` [gentoo-dev] [PATCH 5/5] out-of-source.eclass: Document BUILD_DIR Michał Górny
  2023-01-02  9:25 ` [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass Ulrich Mueller
  4 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2023-01-01 15:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/python-r1.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 622a479dcfa3..cda175dea136 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -8,7 +8,7 @@
 # Author: Michał Górny <mgorny@gentoo.org>
 # Based on work of: Krzysztof Pawlik <nelchael@gentoo.org>
 # @SUPPORTED_EAPIS: 7 8
-# @PROVIDES: multibuild python-utils-r1
+# @PROVIDES: python-utils-r1
 # @BLURB: A common, simple eclass for Python packages.
 # @DESCRIPTION:
 # A common eclass providing helper functions to build and install
-- 
2.39.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-dev] [PATCH 5/5] out-of-source.eclass: Document BUILD_DIR
  2023-01-01 15:59 [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass Michał Górny
                   ` (2 preceding siblings ...)
  2023-01-01 15:59 ` [gentoo-dev] [PATCH 4/5] python-r1.eclass: " Michał Górny
@ 2023-01-01 15:59 ` Michał Górny
  2023-01-02  9:25 ` [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass Ulrich Mueller
  4 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2023-01-01 15:59 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/out-of-source.eclass | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/eclass/out-of-source.eclass b/eclass/out-of-source.eclass
index 81e03f3894db..406d252621c3 100644
--- a/eclass/out-of-source.eclass
+++ b/eclass/out-of-source.eclass
@@ -40,6 +40,13 @@ esac
 if [[ ! ${_OUT_OF_SOURCE_ECLASS} ]]; then
 _OUT_OF_SOURCE_ECLASS=1
 
+# @ECLASS_VARIABLE: BUILD_DIR
+# @OUTPUT_VARIABLE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The current build directory.  Defaults to ${WORKDIR}/${P}_build
+# if unset.
+
 # @FUNCTION: out-of-source_src_configure
 # @DESCRIPTION:
 # The default src_configure() implementation establishes a BUILD_DIR,
-- 
2.39.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass
  2023-01-01 15:59 [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass Michał Górny
                   ` (3 preceding siblings ...)
  2023-01-01 15:59 ` [gentoo-dev] [PATCH 5/5] out-of-source.eclass: Document BUILD_DIR Michał Górny
@ 2023-01-02  9:25 ` Ulrich Mueller
  2023-01-02 12:24   ` Michał Górny
  4 siblings, 1 reply; 7+ messages in thread
From: Ulrich Mueller @ 2023-01-02  9:25 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 416 bytes --]

>>>>> On Sun, 01 Jan 2023, Michał Górny wrote:

> +case ${EAPI} in
> +	6|7|8) ;;
> +	*) die "${ECLASS}: EAPI ${EAPI} unsupported."

Are you sure that this will work without the final ;; terminator?
(Bash documentation says that a terminator is mandatory.)

Apart from that, I'd suggest to use the standard clause as in other
eclasses:

	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;

> +esac

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass
  2023-01-02  9:25 ` [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass Ulrich Mueller
@ 2023-01-02 12:24   ` Michał Górny
  0 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2023-01-02 12:24 UTC (permalink / raw
  To: gentoo-dev

On Mon, 2023-01-02 at 10:25 +0100, Ulrich Mueller wrote:
> > > > > > On Sun, 01 Jan 2023, Michał Górny wrote:
> 
> > +case ${EAPI} in
> > +	6|7|8) ;;
> > +	*) die "${ECLASS}: EAPI ${EAPI} unsupported."
> 
> Are you sure that this will work without the final ;; terminator?
> (Bash documentation says that a terminator is mandatory.)

Interesting enough, it does work.

> Apart from that, I'd suggest to use the standard clause as in other
> eclasses:
> 
> 	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
> 

Actually, this is what app-vim/gentoo-syntax spews by default.  I guess
I need to change it.

Anyway, replaced by your snippet.  I suppose it's fine if I don't
resubmit the batch for this change.

-- 
Best regards,
Michał Górny



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-01-02 12:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-01 15:59 [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass Michał Górny
2023-01-01 15:59 ` [gentoo-dev] [PATCH 2/5] multibuild.eclass: Provide run_in_build_dir from out-of-source-utils Michał Górny
2023-01-01 15:59 ` [gentoo-dev] [PATCH 3/5] multilib-build.eclass: Stop providing multibuild.eclass Michał Górny
2023-01-01 15:59 ` [gentoo-dev] [PATCH 4/5] python-r1.eclass: " Michał Górny
2023-01-01 15:59 ` [gentoo-dev] [PATCH 5/5] out-of-source.eclass: Document BUILD_DIR Michał Górny
2023-01-02  9:25 ` [gentoo-dev] [PATCH 1/5] out-of-source-utils.eclass: New utility eclass Ulrich Mueller
2023-01-02 12:24   ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox