diff options
-rw-r--r-- | meta/classes/go-mod.bbclass | 20 |
1 files changed, 20 insertions, 0 deletions
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 @@ | |||
1 | # Handle Go Modules support | ||
2 | # | ||
3 | # When using Go Modules, the the current working directory MUST be at or below | ||
4 | # the location of the 'go.mod' file when the go tool is used, and there is no | ||
5 | # way to tell it to look elsewhere. It will automatically look upwards for the | ||
6 | # file, but not downwards. | ||
7 | # | ||
8 | # To support this use case, we provide the `GO_WORKDIR` variable, which defaults | ||
9 | # to `GO_IMPORT` but allows for easy override. | ||
10 | # | ||
11 | # Copyright 2020 (C) O.S. Systems Software LTDA. | ||
12 | |||
13 | # The '-modcacherw' option ensures we have write access to the cached objects so | ||
14 | # we avoid errors during clean task as well as when removing the TMPDIR. | ||
15 | export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -modcacherw" | ||
16 | |||
17 | inherit go | ||
18 | |||
19 | GO_WORKDIR ?= "${GO_IMPORT}" | ||
20 | do_compile[dirs] += "${B}/src/${GO_WORKDIR}" | ||