Openembedded Core Discussions
 help / color / mirror / Atom feed
* [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support
@ 2020-06-22 20:02 Khem Raj
  2020-06-22 20:02 ` [dunfell][PATCH 2/4] go.bbclass: Add `-trimpath` to default build flags Khem Raj
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Khem Raj @ 2020-06-22 20:02 UTC (permalink / raw)
  To: openembedded-core; +Cc: Otavio Salvador, Otavio Salvador, Richard Purdie

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


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

end of thread, other threads:[~2020-06-22 23:09 UTC | newest]

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox