All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support
@ 2020-05-22  2:22 Otavio Salvador
  2020-05-22  2:22 ` [PATCH 2/4] glide: Avoid use of 'go mod' support Otavio Salvador
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Otavio Salvador @ 2020-05-22  2:22 UTC (permalink / raw)
  To: OpenEmbedded Core Mailing List; +Cc: Otavio Salvador

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>
---

 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.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] glide: Avoid use of 'go mod' support
  2020-05-22  2:22 [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Otavio Salvador
@ 2020-05-22  2:22 ` Otavio Salvador
  2020-05-22  2:22 ` [PATCH 3/4] go-dep: " Otavio Salvador
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2020-05-22  2:22 UTC (permalink / raw)
  To: OpenEmbedded Core Mailing List; +Cc: Otavio Salvador

Glide utility must not use 'go mod' support, so we explicitly disable
it.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---

 meta/recipes-devtools/glide/glide_0.13.3.bb | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/recipes-devtools/glide/glide_0.13.3.bb b/meta/recipes-devtools/glide/glide_0.13.3.bb
index ebad0ec60a..31295edf90 100644
--- a/meta/recipes-devtools/glide/glide_0.13.3.bb
+++ b/meta/recipes-devtools/glide/glide_0.13.3.bb
@@ -9,6 +9,10 @@ SRCREV = "8ed5b9292379d86c39592a7e6a58eb9c903877cf"
 
 inherit go
 
+# New Go versions has Go modules support enabled by default and cause the Glide
+# tool build to fail.
+export GO111MODULE = "off"
+
 RDEPENDS_${PN}-dev += "bash"
 RDEPENDS_${PN}-ptest += "bash"
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] go-dep: Avoid use of 'go mod' support
  2020-05-22  2:22 [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Otavio Salvador
  2020-05-22  2:22 ` [PATCH 2/4] glide: Avoid use of 'go mod' support Otavio Salvador
@ 2020-05-22  2:22 ` Otavio Salvador
  2020-05-22  2:22 ` [PATCH 4/4] go.bbclass: Add `-trimpath` to default build flags Otavio Salvador
  2020-05-22 17:23 ` [OE-core] [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Khem Raj
  3 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2020-05-22  2:22 UTC (permalink / raw)
  To: OpenEmbedded Core Mailing List; +Cc: Otavio Salvador

dep utility must not use 'go mod' support, so we explicitly disable it.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---

 meta/recipes-devtools/go/go-dep_0.5.4.bb | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/meta/recipes-devtools/go/go-dep_0.5.4.bb b/meta/recipes-devtools/go/go-dep_0.5.4.bb
index 615cb289e5..496224a5cf 100644
--- a/meta/recipes-devtools/go/go-dep_0.5.4.bb
+++ b/meta/recipes-devtools/go/go-dep_0.5.4.bb
@@ -13,6 +13,10 @@ SRCREV = "1f7c19e5f52f49ffb9f956f64c010be14683468b"
 
 inherit go
 
+# New Go versions has Go modules support enabled by default and cause the Glide
+# tool build to fail.
+export GO111MODULE = "off"
+
 GO_INSTALL = "${GO_IMPORT}/cmd/dep"
 
 RDEPENDS_${PN}-dev += "bash"
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] go.bbclass: Add `-trimpath` to default build flags
  2020-05-22  2:22 [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Otavio Salvador
  2020-05-22  2:22 ` [PATCH 2/4] glide: Avoid use of 'go mod' support Otavio Salvador
  2020-05-22  2:22 ` [PATCH 3/4] go-dep: " Otavio Salvador
@ 2020-05-22  2:22 ` Otavio Salvador
  2020-05-22 17:23 ` [OE-core] [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Khem Raj
  3 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2020-05-22  2:22 UTC (permalink / raw)
  To: OpenEmbedded Core Mailing List; +Cc: Otavio Salvador

The `-trimpath` option is important for reproducible builds so full
build paths and module paths are not embedded.

Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
---

 meta/classes/go.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
index c99689ac59..a9e31b50ea 100644
--- a/meta/classes/go.bbclass
+++ b/meta/classes/go.bbclass
@@ -41,7 +41,7 @@ GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS
 GO_LINKMODE ?= ""
 GO_LINKMODE_class-nativesdk = "--linkmode=external"
 GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} -extldflags '${GO_EXTLDFLAGS}'"'
-export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS}"
+export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -trimpath"
 export GOPATH_OMIT_IN_ACTIONID ?= "1"
 export GOPTESTBUILDFLAGS ?= "${GOBUILDFLAGS} -c"
 export GOPTESTFLAGS ?= ""
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support
  2020-05-22  2:22 [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Otavio Salvador
                   ` (2 preceding siblings ...)
  2020-05-22  2:22 ` [PATCH 4/4] go.bbclass: Add `-trimpath` to default build flags Otavio Salvador
@ 2020-05-22 17:23 ` Khem Raj
  2020-05-22 20:12   ` Otavio Salvador
  3 siblings, 1 reply; 6+ messages in thread
From: Khem Raj @ 2020-05-22 17:23 UTC (permalink / raw)
  To: openembedded-core



On 5/21/20 7:22 PM, Otavio Salvador wrote:
> 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]
> 

This series looks ok

> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> ---
> 
>   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.
> +

Do you also want to add license on top along with copyrights ?

> +# 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}"
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [OE-core] [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support
  2020-05-22 17:23 ` [OE-core] [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Khem Raj
@ 2020-05-22 20:12   ` Otavio Salvador
  0 siblings, 0 replies; 6+ messages in thread
From: Otavio Salvador @ 2020-05-22 20:12 UTC (permalink / raw)
  To: Khem Raj; +Cc: Patches and discussions about the oe-core layer

On Fri, May 22, 2020 at 2:23 PM Khem Raj <raj.khem@gmail.com> wrote:
...
> > +# Copyright 2020 (C) O.S. Systems Software LTDA.
> > +
>
> Do you also want to add license on top along with copyrights ?

It is same as OE-Core, if desired, I can make it explicit.

-- 
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9 9981-7854          Mobile: +1 (347) 903-9750

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-05-22 20:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22  2:22 [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Otavio Salvador
2020-05-22  2:22 ` [PATCH 2/4] glide: Avoid use of 'go mod' support Otavio Salvador
2020-05-22  2:22 ` [PATCH 3/4] go-dep: " Otavio Salvador
2020-05-22  2:22 ` [PATCH 4/4] go.bbclass: Add `-trimpath` to default build flags Otavio Salvador
2020-05-22 17:23 ` [OE-core] [PATCH 1/4] go-mod.bbclass: Add class for `go mod` support Khem Raj
2020-05-22 20:12   ` Otavio Salvador

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.