diff options
author | James Le Cuirot <chewi@gentoo.org> | 2024-07-09 21:39:11 +0100 |
---|---|---|
committer | James Le Cuirot <chewi@gentoo.org> | 2024-07-16 10:15:59 +0100 |
commit | 29f0721c4bc11ef3b9d94590016c25a190bc0f20 (patch) | |
tree | 3bf09ceb37ace56ac76c6938be9582c01933a4c1 /eclass | |
parent | go-env.eclass: Rewrite the go-env_goarch() logic (diff) | |
download | gentoo-29f0721c4bc11ef3b9d94590016c25a190bc0f20.tar.gz gentoo-29f0721c4bc11ef3b9d94590016c25a190bc0f20.tar.bz2 gentoo-29f0721c4bc11ef3b9d94590016c25a190bc0f20.zip |
go-env.eclass: Add the go-env_goos() helper function
This code is taken from dev-lang/go. No other packages have code like
this, but some erroneously call `go env GOOS`, which is bad for
cross-compiling. They should use this function instead.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/go-env.eclass | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass index c839c41be0d7..be131133113b 100644 --- a/eclass/go-env.eclass +++ b/eclass/go-env.eclass @@ -48,6 +48,24 @@ go-env_set_compile_environment() { export CGO_LDFLAGS="${CGO_LDFLAGS:-$LDFLAGS}" } +# @FUNCTION: go-env_goos +# @USAGE: [toolchain prefix] +# @DESCRIPTION: +# Returns the appropriate GOOS setting for the target operating system. +go-env_goos() { + local target=${1:-${CHOST}} + case "${target}" 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 ${target}" ;; + esac +} + # @FUNCTION: go-env_goarch # @USAGE: [toolchain prefix] # @DESCRIPTION: |