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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id EC8F9138334 for ; Wed, 11 Sep 2019 23:31:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2D0E0E0A95; Wed, 11 Sep 2019 23:31:15 +0000 (UTC) Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D51DEE087F for ; Wed, 11 Sep 2019 23:31:14 +0000 (UTC) Received: by mail-io1-xd44.google.com with SMTP id d25so50125700iob.6 for ; Wed, 11 Sep 2019 16:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gentoo-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uwFsfGPT5AnhWN0xD/uqe8DgfRr4kI+tW/AYNTf6v+w=; b=uZEWku8scE4sakvStBTzbF9vFqZxUQzxKoerreKwyEfuphDWVPzeHs5m3SfMHAZ735 SXmFf/+INYHOoVQqfIv2nGgIz1dOz7xCbmEn7paFTN/yKgj9fHV/hHhDp9sVP7q4DwDY vOf6Di3GJ9um9MsMgXz6msSzGOjr5sSfO2ulCQc3cex9sZ69jcu8XZDMBfKjFStttU0u 2tdyaJjETjb2870LH1ounlRIxzdnIOHtmgJcEr58+udYvIeI6ySzwU6gim87f37DN/Zs wXJtj3tL07RgYIalE+WfnepgpP14BIdZcS+tiwPR1Hnqp/rZ26AG/33r+Cbhww3Z3cu0 3CUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uwFsfGPT5AnhWN0xD/uqe8DgfRr4kI+tW/AYNTf6v+w=; b=YgjYfZYGu0uSH2rEOKaZfI3NzZKaZHAkOLMXQB7JU93SVgHNnA/SyBHuMyy3G5PwYQ 65EdGyJTn6ElhvO90gyJxdXIiqktNaLSN0ekfMEDKRUSKsKsJTmHhn1ivi2KNsH/c77U tptigZ++LCWdGLa4o/KpMfjNVpmkotaqCHYdWeRZlFG9xLY8ofTMCdbyHRWnZkTEmntz H153xIcE+3z47l2LRbNFhkZJKTQ+75bZCfi930JnaUzDsAzU/qhoUENM0I7FQtLUe9nZ enrJVzIYOoWHJu2eQjj5LLlZ9B9alTDphPYdGx7/mhyF5QCNIdPKVzyyiboudrZtBlqw +tDQ== X-Gm-Message-State: APjAAAXZwuO1VFce/CM7cX7LvN5BD5gj+miMPXOnDYj2jwAByR895EG3 JraW605+ZFYd6mR22ev85hMN3AM+dfL23JNf7OxfWFF+BaA= X-Google-Smtp-Source: APXvYqz3AqvxrYbHTs2tQXtPCKTedmFHyCOAeC/DekGktm8QmxrfIsEZb+DP1HUat3+ggOp/LGsImpUUs97OhBXCkdE= X-Received: by 2002:a5d:9904:: with SMTP id x4mr640226iol.20.1568244673597; Wed, 11 Sep 2019 16:31:13 -0700 (PDT) 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 References: <20190911172128.18885-1-williamh@gentoo.org> <20190911172128.18885-2-williamh@gentoo.org> In-Reply-To: <20190911172128.18885-2-williamh@gentoo.org> From: Alec Warner Date: Wed, 11 Sep 2019 16:31:00 -0700 Message-ID: Subject: Re: [gentoo-dev] [PATCH 1/3] go-module.eclass: introduce new eclass to handle go modules To: Gentoo Dev Cc: William Hubbs Content-Type: multipart/alternative; boundary="000000000000b0e3d205924f6a23" X-Archives-Salt: 0380a90c-89c1-4dd4-9b5f-f914c4721705 X-Archives-Hash: 89b3bbb935a66415a0a82aabb270aafd --000000000000b0e3d205924f6a23 Content-Type: text/plain; charset="UTF-8" On Wed, Sep 11, 2019 at 10:28 AM William Hubbs wrote: > Copyright: Sony Interactive Entertainment Inc. > Signed-off-by: William Hubbs > --- > eclass/go-module.eclass | 76 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 76 insertions(+) > create mode 100644 eclass/go-module.eclass > > diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass > new file mode 100644 > index 00000000000..7009fcd3beb > --- /dev/null > +++ b/eclass/go-module.eclass > @@ -0,0 +1,76 @@ > +# Copyright 1999-2015 Gentoo Foundation > +# Distributed under the terms of the GNU General Public License v2 > + > +# @ECLASS: go-module.eclass > +# @MAINTAINER: > +# William Hubbs > +# @SUPPORTED_EAPIS: 7 > +# @BLURB: basic eclass for building software written in the go > +# programming language that uses go modules. > +# @DESCRIPTION: > +# This eclass provides a convenience src_prepare() phase and some basic > +# settings needed for all software written in the go programming > +# language that uses go modules. > +# > +# You will know the software you are packaging uses modules because > +# it will have files named go.sum and go.mod in its top-level source > +# directory. If it does not have these files, use the golang-* eclasses. > +# > +# If the software you are packaging uses modules, the next question is > +# whether it has a directory named "vendor" at the top-level of the > source tree. > +# > +# If it doesn't, you need to create a tarball of what would be in the > +# vendor directory and mirror it locally. This is done with the > +# following commands if upstream is using a git repository: > +# > +# @CODE: > +# > +# $ cd /my/clone/of/upstream > +# $ git checkout > +# $ go mod vendor > +# $ tar cvf project-version-vendor.tar.gz vendor > +# > +# @CODE: > +# > +# Other than this, all you need to do is inherit this eclass then > +# make sure the exported src_prepare function is run. > + > +case ${EAPI:-0} in > + 7) ;; > + *) die "${ECLASS} API in EAPI ${EAPI} not yet established." > +esac > + > +if [[ -z ${_GO_MODULE} ]]; then > + > +_GO_MODULE=1 > + > +BDEPEND=">=dev-lang/go-1.12" > + > +# Do not download dependencies from the internet > +# make build output verbose by default > +export GOFLAGS="-mod=vendor -v -x" > + > +# Do not complain about CFLAGS etc since go projects do not use them. > +QA_FLAGS_IGNORED='.*' > + > +# Upstream does not support stripping go packages > +RESTRICT="strip" > https://golang.org/cmd/link/ implies you can pass -s -w to the compiler to reduce binary size. Does that not work in portage by default, or does upstream just consider that bad practice? -A > + > +EXPORT_FUNCTIONS src_prepare > + > +# @FUNCTION: go-module_src_prepare > +# @DESCRIPTION: > +# Run a default src_prepare then move our provided vendor directory to > +# the appropriate spot if upstream doesn't provide a vendor directory. > +go-module_src_prepare() { > + default > + # Use the upstream provided vendor directory if it exists. > + [[ -d vendor ]] && return > + # If we are not providing a mirror of a vendor directory we created > + # manually, return since there may be nothing to vendor. > + [[ ! -d ../vendor ]] && return > + # At this point, we know we are providing a vendor mirror. > + mv ../vendor . || die "Unable to move ../vendor directory" > +} > + > +fi > -- > 2.21.0 > > > --000000000000b0e3d205924f6a23 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Sep 11, 2019 at 10:28 AM Will= iam Hubbs <williamh@gentoo.org> wrote:
Cop= yright: Sony Interactive Entertainment Inc.
Signed-off-by: William Hubbs <
williamh@gentoo.org>
---
=C2=A0eclass/go-module.eclass | 76 ++++++++++++++++++++++++++++++++++++++++= +
=C2=A01 file changed, 76 insertions(+)
=C2=A0create mode 100644 eclass/go-module.eclass

diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass
new file mode 100644
index 00000000000..7009fcd3beb
--- /dev/null
+++ b/eclass/go-module.eclass
@@ -0,0 +1,76 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: go-module.eclass
+# @MAINTAINER:
+# William Hubbs <williamh@gentoo.org>
+# @SUPPORTED_EAPIS: 7
+# @BLURB: basic eclass for building software written in the go
+# programming language that uses go modules.
+# @DESCRIPTION:
+# This eclass provides a convenience src_prepare() phase and some basic +# settings needed for all software written in the go programming
+# language that uses go modules.
+#
+# You will know the software you are packaging uses modules because
+# it will have files named go.sum and go.mod in its top-level source
+# directory. If it does not have these files, use the golang-* eclasses. +#
+# If the software you are packaging uses modules, the next question is
+# whether it has a directory named "vendor" at the top-level of = the source tree.
+#
+# If it doesn't, you need to create a tarball of what would be in the<= br> +# vendor directory and mirror it locally. This is done with the
+# following commands if upstream is using a git repository:
+#
+# @CODE:
+#
+# $ cd /my/clone/of/upstream
+# $ git checkout <release>
+# $ go mod vendor
+# $ tar cvf project-version-vendor.tar.gz vendor
+#
+# @CODE:
+#
+# Other than this, all you need to do is inherit this eclass then
+# make sure=C2=A0 the exported src_prepare function is run.
+
+case ${EAPI:-0} in
+=C2=A0 =C2=A0 =C2=A0 =C2=A07) ;;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0*) die "${ECLASS} API in EAPI ${EAPI} not = yet established."
+esac
+
+if [[ -z ${_GO_MODULE} ]]; then
+
+_GO_MODULE=3D1
+
+BDEPEND=3D">=3Ddev-lang/go-1.12"
+
+# Do not download dependencies from the internet
+# make build output verbose by default
+export GOFLAGS=3D"-mod=3Dvendor -v -x"
+
+# Do not complain about CFLAGS etc since go projects do not use them.
+QA_FLAGS_IGNORED=3D'.*'
+
+# Upstream does not support stripping go packages
+RESTRICT=3D"strip"

https://golang.org/cmd/link/=C2=A0imp= lies you can pass -s -w to the compiler to reduce binary size.

Does that not work in portage by default, or does upstream= just consider that bad practice?

-A
=C2= =A0
+
+EXPORT_FUNCTIONS src_prepare
+
+# @FUNCTION: go-module_src_prepare
+# @DESCRIPTION:
+# Run a default src_prepare then move our provided vendor directory to
+# the appropriate spot if upstream doesn't provide a vendor directory.=
+go-module_src_prepare() {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0default
+=C2=A0 =C2=A0 =C2=A0 =C2=A0# Use the upstream provided vendor directory if= it exists.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0[[ -d vendor ]] && return
+=C2=A0 =C2=A0 =C2=A0 =C2=A0# If we are not providing a mirror of a vendor = directory we created
+=C2=A0 =C2=A0 =C2=A0 =C2=A0# manually, return since there may be nothing t= o vendor.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0[[ ! -d ../vendor ]] && return
+=C2=A0 =C2=A0 =C2=A0 =C2=A0# At this point, we know we are providing a ven= dor mirror.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0mv ../vendor . || die "Unable to move ../v= endor directory"
+}
+
+fi
--
2.21.0


--000000000000b0e3d205924f6a23--