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 D592D1581C1 for ; Tue, 9 Jul 2024 21:12:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C17782BC0B4; Tue, 9 Jul 2024 21:10:26 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (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 7B3CA2BC0B1 for ; Tue, 9 Jul 2024 21:10:26 +0000 (UTC) From: James Le Cuirot To: gentoo-dev Cc: William Hubbs , James Le Cuirot Subject: [gentoo-dev] [PATCH 7/8] go-env.eclass: Add the go-env_goos() helper function Date: Tue, 9 Jul 2024 22:07:39 +0100 Message-ID: <20240709210749.14002-7-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: 4a5ccacc-f08e-437e-9dec-74fc4b9df5b1 X-Archives-Hash: a17e0340501e70b05be777f73104aadb 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 --- eclass/go-env.eclass | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/eclass/go-env.eclass b/eclass/go-env.eclass index c839c41be0d7e..be131133113be 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: -- 2.45.2