From: James Le Cuirot <chewi@gentoo.org>
To: gentoo-dev <gentoo-dev@lists.gentoo.org>
Cc: William Hubbs <williamh@gentoo.org>, James Le Cuirot <chewi@gentoo.org>
Subject: [gentoo-dev] [PATCH 8/8] dev-lang/go: Use go-env.eclass in 1.22.5 and 9999
Date: Tue, 9 Jul 2024 22:07:40 +0100 [thread overview]
Message-ID: <20240709210749.14002-8-chewi@gentoo.org> (raw)
In-Reply-To: <20240709210749.14002-1-chewi@gentoo.org>
This deduplicates some helper functions.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
---
dev-lang/go/go-1.22.5.ebuild | 65 +++++-------------------------------
dev-lang/go/go-9999.ebuild | 65 +++++-------------------------------
2 files changed, 18 insertions(+), 112 deletions(-)
diff --git a/dev-lang/go/go-1.22.5.ebuild b/dev-lang/go/go-1.22.5.ebuild
index fc36a2d33ae98..b16e86ae904f0 100644
--- a/dev-lang/go/go-1.22.5.ebuild
+++ b/dev-lang/go/go-1.22.5.ebuild
@@ -10,7 +10,7 @@ export CTARGET=${CTARGET:-${CHOST}}
GO_BOOTSTRAP_MIN=1.20.14
MY_PV=${PV/_/}
-inherit toolchain-funcs
+inherit go-env toolchain-funcs
case ${PV} in
*9999*)
@@ -33,7 +33,7 @@ HOMEPAGE="https://go.dev"
LICENSE="BSD"
SLOT="0/${PV}"
-IUSE="abi_mips_o32 abi_mips_n64 cpu_flags_x86_sse2"
+IUSE="cpu_flags_x86_sse2"
RDEPEND="
arm? ( sys-devel/binutils[gold] )
@@ -66,55 +66,8 @@ DOCS=(
SECURITY.md
)
-go_arch() {
- # By chance most portage arch names match Go
- local tc_arch=$(tc-arch $@)
- case "${tc_arch}" in
- x86) echo 386;;
- x64-*) echo amd64;;
- loong) echo loong64;;
- mips) if use abi_mips_o32; then
- [[ $(tc-endian $@) = big ]] && echo mips || echo mipsle
- elif use abi_mips_n64; then
- [[ $(tc-endian $@) = big ]] && echo mips64 || echo mips64le
- fi ;;
- ppc64) [[ $(tc-endian $@) = big ]] && echo ppc64 || echo ppc64le ;;
- riscv) echo riscv64 ;;
- s390) echo s390x ;;
- *) echo "${tc_arch}";;
- esac
-}
-
-go_arm() {
- case "${1:-${CHOST}}" in
- armv5*) echo 5;;
- armv6*) echo 6;;
- armv7*) echo 7;;
- *)
- die "unknown GOARM for ${1:-${CHOST}}"
- ;;
- esac
-}
-
-go_os() {
- case "${1:-${CHOST}}" in
- *-linux*) echo linux;;
- *-darwin*) echo darwin;;
- *-freebsd*) echo freebsd;;
- *-netbsd*) echo netbsd;;
- *-openbsd*) echo openbsd;;
- *-solaris*) echo solaris;;
- *-cygwin*|*-interix*|*-winnt*)
- echo windows
- ;;
- *)
- die "unknown GOOS for ${1:-${CHOST}}"
- ;;
- esac
-}
-
go_tuple() {
- echo "$(go_os $@)_$(go_arch $@)"
+ echo "$(go-env_goos $@)_$(go-env_goarch $@)"
}
go_cross_compile() {
@@ -140,16 +93,16 @@ src_compile() {
export GOBIN="${GOROOT}/bin"
# Go's build script does not use BUILD/HOST/TARGET consistently. :(
- export GOHOSTARCH=$(go_arch ${CBUILD})
- export GOHOSTOS=$(go_os ${CBUILD})
+ export GOHOSTARCH=$(go-env_goarch ${CBUILD})
+ export GOHOSTOS=$(go-env_goos ${CBUILD})
export CC=$(tc-getBUILD_CC)
- export GOARCH=$(go_arch)
- export GOOS=$(go_os)
+ export GOARCH=$(go-env_goarch)
+ export GOOS=$(go-env_goos)
export CC_FOR_TARGET=$(tc-getCC)
export CXX_FOR_TARGET=$(tc-getCXX)
- use arm && export GOARM=$(go_arm)
- use x86 && export GO386=$(usex cpu_flags_x86_sse2 '' 'softfloat')
+ use arm && export GOARM=$(go-env_goarm)
+ use x86 && export GO386=$(go-env_go386)
cd src
bash -x ./make.bash || die "build failed"
diff --git a/dev-lang/go/go-9999.ebuild b/dev-lang/go/go-9999.ebuild
index fc36a2d33ae98..b16e86ae904f0 100644
--- a/dev-lang/go/go-9999.ebuild
+++ b/dev-lang/go/go-9999.ebuild
@@ -10,7 +10,7 @@ export CTARGET=${CTARGET:-${CHOST}}
GO_BOOTSTRAP_MIN=1.20.14
MY_PV=${PV/_/}
-inherit toolchain-funcs
+inherit go-env toolchain-funcs
case ${PV} in
*9999*)
@@ -33,7 +33,7 @@ HOMEPAGE="https://go.dev"
LICENSE="BSD"
SLOT="0/${PV}"
-IUSE="abi_mips_o32 abi_mips_n64 cpu_flags_x86_sse2"
+IUSE="cpu_flags_x86_sse2"
RDEPEND="
arm? ( sys-devel/binutils[gold] )
@@ -66,55 +66,8 @@ DOCS=(
SECURITY.md
)
-go_arch() {
- # By chance most portage arch names match Go
- local tc_arch=$(tc-arch $@)
- case "${tc_arch}" in
- x86) echo 386;;
- x64-*) echo amd64;;
- loong) echo loong64;;
- mips) if use abi_mips_o32; then
- [[ $(tc-endian $@) = big ]] && echo mips || echo mipsle
- elif use abi_mips_n64; then
- [[ $(tc-endian $@) = big ]] && echo mips64 || echo mips64le
- fi ;;
- ppc64) [[ $(tc-endian $@) = big ]] && echo ppc64 || echo ppc64le ;;
- riscv) echo riscv64 ;;
- s390) echo s390x ;;
- *) echo "${tc_arch}";;
- esac
-}
-
-go_arm() {
- case "${1:-${CHOST}}" in
- armv5*) echo 5;;
- armv6*) echo 6;;
- armv7*) echo 7;;
- *)
- die "unknown GOARM for ${1:-${CHOST}}"
- ;;
- esac
-}
-
-go_os() {
- case "${1:-${CHOST}}" in
- *-linux*) echo linux;;
- *-darwin*) echo darwin;;
- *-freebsd*) echo freebsd;;
- *-netbsd*) echo netbsd;;
- *-openbsd*) echo openbsd;;
- *-solaris*) echo solaris;;
- *-cygwin*|*-interix*|*-winnt*)
- echo windows
- ;;
- *)
- die "unknown GOOS for ${1:-${CHOST}}"
- ;;
- esac
-}
-
go_tuple() {
- echo "$(go_os $@)_$(go_arch $@)"
+ echo "$(go-env_goos $@)_$(go-env_goarch $@)"
}
go_cross_compile() {
@@ -140,16 +93,16 @@ src_compile() {
export GOBIN="${GOROOT}/bin"
# Go's build script does not use BUILD/HOST/TARGET consistently. :(
- export GOHOSTARCH=$(go_arch ${CBUILD})
- export GOHOSTOS=$(go_os ${CBUILD})
+ export GOHOSTARCH=$(go-env_goarch ${CBUILD})
+ export GOHOSTOS=$(go-env_goos ${CBUILD})
export CC=$(tc-getBUILD_CC)
- export GOARCH=$(go_arch)
- export GOOS=$(go_os)
+ export GOARCH=$(go-env_goarch)
+ export GOOS=$(go-env_goos)
export CC_FOR_TARGET=$(tc-getCC)
export CXX_FOR_TARGET=$(tc-getCXX)
- use arm && export GOARM=$(go_arm)
- use x86 && export GO386=$(usex cpu_flags_x86_sse2 '' 'softfloat')
+ use arm && export GOARM=$(go-env_goarm)
+ use x86 && export GO386=$(go-env_go386)
cd src
bash -x ./make.bash || die "build failed"
--
2.45.2
prev parent reply other threads:[~2024-07-09 21:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-09 21:07 [gentoo-dev] [PATCH 1/8] golang-vcs.eclass: Drop support for EAPI 6 James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 2/8] golang-vcs-snapshot.eclass: " James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 3/8] golang-build.eclass: " James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 4/8] golang-base.eclass: Drop support for EAPI 5 and 6 James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 5/8] go-env.eclass: Establish EAPI 7 and 8 as supported James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 6/8] go-env.eclass: Rewrite the go-env_goarch() logic James Le Cuirot
2024-07-09 21:07 ` [gentoo-dev] [PATCH 7/8] go-env.eclass: Add the go-env_goos() helper function James Le Cuirot
2024-07-09 21:07 ` James Le Cuirot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240709210749.14002-8-chewi@gentoo.org \
--to=chewi@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
--cc=williamh@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox