From: "Khem Raj" <raj.khem@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Otavio Salvador <otavio.salvador@gmail.com>,
Otavio Salvador <otavio@ossystems.com.br>,
Richard Purdie <richard.purdie@linuxfoundation.org>
Subject: [dunfell][PATCH 1/4] go-mod.bbclass: Add class for `go mod` support
Date: Mon, 22 Jun 2020 13:02:27 -0700 [thread overview]
Message-ID: <20200622200230.54899-1-raj.khem@gmail.com> (raw)
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
next reply other threads:[~2020-06-22 20:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-22 20:02 Khem Raj [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200622200230.54899-1-raj.khem@gmail.com \
--to=raj.khem@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=otavio.salvador@gmail.com \
--cc=otavio@ossystems.com.br \
--cc=richard.purdie@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox