[dunfell,1/4] go-mod.bbclass: Add class for `go mod` support

Submitted by Khem Raj on June 22, 2020, 8:02 p.m. | Patch ID: 173792

Details

Message ID 20200622200230.54899-1-raj.khem@gmail.com
State New
Headers show

Commit Message

Khem Raj June 22, 2020, 8:02 p.m.
From: Otavio Salvador <otavio.salvador@gmail.com>

When using Go Modules, the the current working directory MUST be at or
below the location of the 'go.mod' file when the go tool is used, and
there is no way to tell it to look elsewhere.  It will automatically
look upwards for the file, but not downwards.

To support this use case, we provide the `GO_WORKDIR` variable, which
defaults to `GO_IMPORT` but allows for easy override.

[YOCTO #13883]

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/go-mod.bbclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 meta/classes/go-mod.bbclass

Patch hide | download patch | download mbox

diff --git a/meta/classes/go-mod.bbclass b/meta/classes/go-mod.bbclass
new file mode 100644
index 0000000000..5871d02506
--- /dev/null
+++ b/meta/classes/go-mod.bbclass
@@ -0,0 +1,20 @@ 
+# Handle Go Modules support
+#
+# When using Go Modules, the the current working directory MUST be at or below
+# the location of the 'go.mod' file when the go tool is used, and there is no
+# way to tell it to look elsewhere.  It will automatically look upwards for the
+# file, but not downwards.
+#
+# To support this use case, we provide the `GO_WORKDIR` variable, which defaults
+# to `GO_IMPORT` but allows for easy override.
+#
+# Copyright 2020 (C) O.S. Systems Software LTDA.
+
+# The '-modcacherw' option ensures we have write access to the cached objects so
+# we avoid errors during clean task as well as when removing the TMPDIR.
+export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -modcacherw"
+
+inherit go
+
+GO_WORKDIR ?= "${GO_IMPORT}"
+do_compile[dirs] += "${B}/src/${GO_WORKDIR}"

Comments

Steve Sakoman June 22, 2020, 8:12 p.m.
This set of patches is contained in the series I sent out for review
this morning :-)

Steve

On Mon, Jun 22, 2020 at 10:02 AM Khem Raj <raj.khem@gmail.com> wrote:
>
> From: Otavio Salvador <otavio.salvador@gmail.com>
>
> When using Go Modules, the the current working directory MUST be at or
> below the location of the 'go.mod' file when the go tool is used, and
> there is no way to tell it to look elsewhere.  It will automatically
> look upwards for the file, but not downwards.
>
> To support this use case, we provide the `GO_WORKDIR` variable, which
> defaults to `GO_IMPORT` but allows for easy override.
>
> [YOCTO #13883]
>
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> ---
>  meta/classes/go-mod.bbclass | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>  create mode 100644 meta/classes/go-mod.bbclass
>
> diff --git a/meta/classes/go-mod.bbclass b/meta/classes/go-mod.bbclass
> new file mode 100644
> index 0000000000..5871d02506
> --- /dev/null
> +++ b/meta/classes/go-mod.bbclass
> @@ -0,0 +1,20 @@
> +# Handle Go Modules support
> +#
> +# When using Go Modules, the the current working directory MUST be at or below
> +# the location of the 'go.mod' file when the go tool is used, and there is no
> +# way to tell it to look elsewhere.  It will automatically look upwards for the
> +# file, but not downwards.
> +#
> +# To support this use case, we provide the `GO_WORKDIR` variable, which defaults
> +# to `GO_IMPORT` but allows for easy override.
> +#
> +# Copyright 2020 (C) O.S. Systems Software LTDA.
> +
> +# The '-modcacherw' option ensures we have write access to the cached objects so
> +# we avoid errors during clean task as well as when removing the TMPDIR.
> +export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -modcacherw"
> +
> +inherit go
> +
> +GO_WORKDIR ?= "${GO_IMPORT}"
> +do_compile[dirs] += "${B}/src/${GO_WORKDIR}"
> --
> 2.27.0
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#139796): https://lists.openembedded.org/g/openembedded-core/message/139796
Mute This Topic: https://lists.openembedded.org/mt/75046944/3617530
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  [oe-patchwork@oe-patch.openembedded.org]
-=-=-=-=-=-=-=-=-=-=-=-
Khem Raj June 22, 2020, 11:08 p.m.
On Mon, Jun 22, 2020 at 1:13 PM Steve Sakoman <sakoman@gmail.com> wrote:
>
> This set of patches is contained in the series I sent out for review
> this morning :-)

ah even better, Feel free to ignore this series then

>
> Steve
>
> On Mon, Jun 22, 2020 at 10:02 AM Khem Raj <raj.khem@gmail.com> wrote:
> >
> > From: Otavio Salvador <otavio.salvador@gmail.com>
> >
> > When using Go Modules, the the current working directory MUST be at or
> > below the location of the 'go.mod' file when the go tool is used, and
> > there is no way to tell it to look elsewhere.  It will automatically
> > look upwards for the file, but not downwards.
> >
> > To support this use case, we provide the `GO_WORKDIR` variable, which
> > defaults to `GO_IMPORT` but allows for easy override.
> >
> > [YOCTO #13883]
> >
> > Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> > Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> > ---
> >  meta/classes/go-mod.bbclass | 20 ++++++++++++++++++++
> >  1 file changed, 20 insertions(+)
> >  create mode 100644 meta/classes/go-mod.bbclass
> >
> > diff --git a/meta/classes/go-mod.bbclass b/meta/classes/go-mod.bbclass
> > new file mode 100644
> > index 0000000000..5871d02506
> > --- /dev/null
> > +++ b/meta/classes/go-mod.bbclass
> > @@ -0,0 +1,20 @@
> > +# Handle Go Modules support
> > +#
> > +# When using Go Modules, the the current working directory MUST be at or below
> > +# the location of the 'go.mod' file when the go tool is used, and there is no
> > +# way to tell it to look elsewhere.  It will automatically look upwards for the
> > +# file, but not downwards.
> > +#
> > +# To support this use case, we provide the `GO_WORKDIR` variable, which defaults
> > +# to `GO_IMPORT` but allows for easy override.
> > +#
> > +# Copyright 2020 (C) O.S. Systems Software LTDA.
> > +
> > +# The '-modcacherw' option ensures we have write access to the cached objects so
> > +# we avoid errors during clean task as well as when removing the TMPDIR.
> > +export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -modcacherw"
> > +
> > +inherit go
> > +
> > +GO_WORKDIR ?= "${GO_IMPORT}"
> > +do_compile[dirs] += "${B}/src/${GO_WORKDIR}"
> > --
> > 2.27.0
> >
> >
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#139808): https://lists.openembedded.org/g/openembedded-core/message/139808
Mute This Topic: https://lists.openembedded.org/mt/75046944/3617530
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub  [oe-patchwork@oe-patch.openembedded.org]
-=-=-=-=-=-=-=-=-=-=-=-