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