[PATCH 2/4] go-module.eclass: Support EAPI 9 with new src_configure phase function

James Le Cuirot <[email protected]>
Newsgroups gmane.linux.gentoo.devel
Message-ID <[email protected]>
src_configure now calls go-env_set_compile_environment(), which was
previously called during src_unpack. This was problematic because it
would set up flag variables before any flag filtering was typically done
in src_configure.

Closes: https://bugs.gentoo.org/963401
Signed-off-by: James Le Cuirot <[email protected]>
---
 eclass/go-env.eclass    |  2 +-
 eclass/go-module.eclass | 26 ++++++++++++++++++++------
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass
index 4f3067538928..f5c84c3abbb0 100644
--- a/eclass/go-env.eclass
+++ b/eclass/go-env.eclass
@@ -11,7 +11,7 @@
 # @DESCRIPTION:
 # This eclass includes helper functions for setting up the build environment for
 # Go ebuilds. Intended to be called by other Go eclasses in an early build
-# stage, e.g. src_unpack.
+# stage, e.g. src_configure.
 
 # @ECLASS_VARIABLE: GOMAXPROCS
 # @USER_VARIABLE
diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass
index 5294f50d8ad8..1d7b6044d802 100644
--- a/eclass/go-module.eclass
+++ b/eclass/go-module.eclass
@@ -7,7 +7,7 @@
 # @AUTHOR:
 # William Hubbs <[email protected]>
 # Robin H. Johnson <[email protected]>
-# @SUPPORTED_EAPIS: 7 8
+# @SUPPORTED_EAPIS: 7 8 9
 # @BLURB: basic eclass for building software written as go modules
 # @DESCRIPTION:
 # This eclass provides basic settings and functions needed by all software
@@ -61,7 +61,7 @@
 # @CODE
 
 case ${EAPI} in
-	7|8) ;;
+	7|8|9) ;;
 	*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
 esac
 
@@ -182,7 +182,7 @@ declare -A -g _GOMODULE_GOSUM_REVERSE_MAP
 # If set to a non-null value before inherit, the Go part of the
 # ebuild will be considered optional. No dependencies will be added and
 # no phase functions will be exported. You will need to set BDEPEND and
-# call go-module_src_unpack in your ebuild.
+# call go-module_src_unpack and go-module_src_configure in your ebuild.
 
 # @FUNCTION: ego
 # @USAGE: [<args>...]
@@ -347,12 +347,11 @@ go-module_setup_proxy() {
 
 # @FUNCTION: go-module_src_unpack
 # @DESCRIPTION:
-# Sets up GOFLAGS for the system and then unpacks based on the following rules:
+# Unpacks based on the following rules:
 # 1. If EGO_SUM is set, unpack the base tarball(s) and set up the
 #    local go proxy.  This mode is deprecated.
 # 2. Otherwise, if EGO_VENDOR is set, bail out, as this functionality was removed.
 # 3. Otherwise, call 'ego mod verify' and then do a normal unpack.
-# Set compile env via go-env.
 go-module_src_unpack() {
 	if [[ "${#EGO_SUM[@]}" -gt 0 ]]; then
 		eqawarn "QA Notice: This ebuild uses EGO_SUM which is deprecated"
@@ -372,7 +371,9 @@ go-module_src_unpack() {
 		fi
 	fi
 
-	go-env_set_compile_environment
+	case ${EAPI} in
+		7|8) go-env_set_compile_environment ;;
+	esac
 }
 
 # @FUNCTION: _go-module_src_unpack_gosum
@@ -501,8 +502,21 @@ go-module_live_vendor() {
 	popd >& /dev/null || die
 }
 
+# @FUNCTION: go-module_src_configure
+# @DESCRIPTION:
+# Sets up the environment to build Go code for the target system. If manually
+# calling this from your own src_configure, do it between handling build flags
+# and invoking another build system.
+go-module_src_configure() {
+	go-env_set_compile_environment
+}
+
 fi
 
 if [[ ! ${GO_OPTIONAL} ]]; then
 	EXPORT_FUNCTIONS src_unpack
+	case ${EAPI} in
+		7|8) ;;
+		*) EXPORT_FUNCTIONS src_configure ;;
+	esac
 fi
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.