1 |
On Wed, Sep 11, 2019 at 04:31:00PM -0700, Alec Warner wrote: |
2 |
> On Wed, Sep 11, 2019 at 10:28 AM William Hubbs <williamh@g.o> wrote: |
3 |
> |
4 |
> > Copyright: Sony Interactive Entertainment Inc. |
5 |
> > Signed-off-by: William Hubbs <williamh@g.o> |
6 |
> > --- |
7 |
> > eclass/go-module.eclass | 76 +++++++++++++++++++++++++++++++++++++++++ |
8 |
> > 1 file changed, 76 insertions(+) |
9 |
> > create mode 100644 eclass/go-module.eclass |
10 |
> > |
11 |
> > diff --git a/eclass/go-module.eclass b/eclass/go-module.eclass |
12 |
> > new file mode 100644 |
13 |
> > index 00000000000..7009fcd3beb |
14 |
> > --- /dev/null |
15 |
> > +++ b/eclass/go-module.eclass |
16 |
> > @@ -0,0 +1,76 @@ |
17 |
> > +# Copyright 1999-2015 Gentoo Foundation |
18 |
> > +# Distributed under the terms of the GNU General Public License v2 |
19 |
> > + |
20 |
> > +# @ECLASS: go-module.eclass |
21 |
> > +# @MAINTAINER: |
22 |
> > +# William Hubbs <williamh@g.o> |
23 |
> > +# @SUPPORTED_EAPIS: 7 |
24 |
> > +# @BLURB: basic eclass for building software written in the go |
25 |
> > +# programming language that uses go modules. |
26 |
> > +# @DESCRIPTION: |
27 |
> > +# This eclass provides a convenience src_prepare() phase and some basic |
28 |
> > +# settings needed for all software written in the go programming |
29 |
> > +# language that uses go modules. |
30 |
> > +# |
31 |
> > +# You will know the software you are packaging uses modules because |
32 |
> > +# it will have files named go.sum and go.mod in its top-level source |
33 |
> > +# directory. If it does not have these files, use the golang-* eclasses. |
34 |
> > +# |
35 |
> > +# If the software you are packaging uses modules, the next question is |
36 |
> > +# whether it has a directory named "vendor" at the top-level of the |
37 |
> > source tree. |
38 |
> > +# |
39 |
> > +# If it doesn't, you need to create a tarball of what would be in the |
40 |
> > +# vendor directory and mirror it locally. This is done with the |
41 |
> > +# following commands if upstream is using a git repository: |
42 |
> > +# |
43 |
> > +# @CODE: |
44 |
> > +# |
45 |
> > +# $ cd /my/clone/of/upstream |
46 |
> > +# $ git checkout <release> |
47 |
> > +# $ go mod vendor |
48 |
> > +# $ tar cvf project-version-vendor.tar.gz vendor |
49 |
> > +# |
50 |
> > +# @CODE: |
51 |
> > +# |
52 |
> > +# Other than this, all you need to do is inherit this eclass then |
53 |
> > +# make sure the exported src_prepare function is run. |
54 |
> > + |
55 |
> > +case ${EAPI:-0} in |
56 |
> > + 7) ;; |
57 |
> > + *) die "${ECLASS} API in EAPI ${EAPI} not yet established." |
58 |
> > +esac |
59 |
> > + |
60 |
> > +if [[ -z ${_GO_MODULE} ]]; then |
61 |
> > + |
62 |
> > +_GO_MODULE=1 |
63 |
> > + |
64 |
> > +BDEPEND=">=dev-lang/go-1.12" |
65 |
> > + |
66 |
> > +# Do not download dependencies from the internet |
67 |
> > +# make build output verbose by default |
68 |
> > +export GOFLAGS="-mod=vendor -v -x" |
69 |
> > + |
70 |
> > +# Do not complain about CFLAGS etc since go projects do not use them. |
71 |
> > +QA_FLAGS_IGNORED='.*' |
72 |
> > + |
73 |
> > +# Upstream does not support stripping go packages |
74 |
> > +RESTRICT="strip" |
75 |
> > |
76 |
> |
77 |
> https://golang.org/cmd/link/ implies you can pass -s -w to the compiler to |
78 |
> reduce binary size. |
79 |
> |
80 |
> Does that not work in portage by default, or does upstream just consider |
81 |
> that bad practice? |
82 |
|
83 |
I haven't tried it, but here are the definitions of -s and -w. |
84 |
|
85 |
-s Omit the symbol table and debug information. |
86 |
-w Omit the DWARF symbol table. |
87 |
|
88 |
These look like Go's equivalent of stripping the binaries, and I have my |
89 |
doubts as to whether we should force this. |
90 |
|
91 |
William |