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 181F81581C1 for ; Tue, 16 Jul 2024 09:16:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0CE56E2A5D; Tue, 16 Jul 2024 09:16:55 +0000 (UTC) Received: from smtp.gentoo.org (smtp.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 E531EE2A5D for ; Tue, 16 Jul 2024 09:16:54 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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 smtp.gentoo.org (Postfix) with ESMTPS id 386E1335D7B for ; Tue, 16 Jul 2024 09:16:54 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5BE951E36 for ; Tue, 16 Jul 2024 09:16:51 +0000 (UTC) From: "James Le Cuirot" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "James Le Cuirot" Message-ID: <1721121359.29f0721c4bc11ef3b9d94590016c25a190bc0f20.chewi@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/go-env.eclass X-VCS-Directories: eclass/ X-VCS-Committer: chewi X-VCS-Committer-Name: James Le Cuirot X-VCS-Revision: 29f0721c4bc11ef3b9d94590016c25a190bc0f20 X-VCS-Branch: master Date: Tue, 16 Jul 2024 09:16:51 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 4488227c-4b7a-410d-873a-ab4d0b84c56b X-Archives-Hash: b474a2e69b404ab47efaa7c84e636f55 commit: 29f0721c4bc11ef3b9d94590016c25a190bc0f20 Author: James Le Cuirot gentoo org> AuthorDate: Tue Jul 9 20:39:11 2024 +0000 Commit: James Le Cuirot gentoo org> CommitDate: Tue Jul 16 09:15:59 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=29f0721c 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 gentoo.org> eclass/go-env.eclass | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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: