summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Le Cuirot <chewi@gentoo.org>2024-07-09 21:45:46 +0100
committerJames Le Cuirot <chewi@gentoo.org>2024-07-16 10:16:00 +0100
commit10ce0f5c2719a2395f51952d9ad2dad9e0a79f1a (patch)
tree69af9b241d0f1113e66fc5541ca12f544503e392 /dev-lang/go
parentgo-env.eclass: Add the go-env_goos() helper function (diff)
downloadgentoo-10ce0f5c2719a2395f51952d9ad2dad9e0a79f1a.tar.gz
gentoo-10ce0f5c2719a2395f51952d9ad2dad9e0a79f1a.tar.bz2
gentoo-10ce0f5c2719a2395f51952d9ad2dad9e0a79f1a.zip
dev-lang/go: Use go-env.eclass in 1.22.5 and 9999
This deduplicates some helper functions. Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Diffstat (limited to 'dev-lang/go')
-rw-r--r--dev-lang/go/go-1.22.5.ebuild65
-rw-r--r--dev-lang/go/go-9999.ebuild65
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 fc36a2d33ae9..b16e86ae904f 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 fc36a2d33ae9..b16e86ae904f 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"