From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2EE9C1581C1 for ; Tue, 9 Jul 2024 21:12:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BFE4B2BC0C0; Tue, 9 Jul 2024 21:10:27 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 7C2E22BC0BD for ; Tue, 9 Jul 2024 21:10:27 +0000 (UTC) From: James Le Cuirot To: gentoo-dev Cc: William Hubbs , James Le Cuirot 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 Message-ID: <20240709210749.14002-8-chewi@gentoo.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709210749.14002-1-chewi@gentoo.org> References: <20240709210749.14002-1-chewi@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: dae5468f-5660-4f06-8c15-6b8818d9fcea X-Archives-Hash: 995b01e984f7352d292657d8f7bda9df This deduplicates some helper functions. Signed-off-by: James Le Cuirot --- 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