diff options
author | Matt Madison <matt@madison.systems> | 2017-09-08 18:04:42 -0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-09-11 17:30:30 +0100 |
commit | 245285e3be5996aa05542c52786cbb097e61f2d9 (patch) | |
tree | 9712855c77cf4f12f54f33c7bf94d153430e36c9 /meta/classes/go.bbclass | |
parent | 7149219b7630cb8cfb70caf4610d4b64a4eccff3 (diff) | |
download | poky-245285e3be5996aa05542c52786cbb097e61f2d9.tar.gz |
go.bbclass: add GO_INSTALL_FILTEROUT variable
When using the Go 'vendor' mechanism to bring in
dependencies for a Go package, the default GO_INSTALL
setting, which uses the '...' wildcard, will include
the vendored packages in the build, which produces
incorrect results.
There are also some Go packages that are structured
poorly, so that the '...' wildcard results in building
example or test code that should not be included in
the build, or fail to build.
This patch adds a mechanism for filtering out a
subset of the sources. It defaults to filtering
out everything under the 'vendor' subdirectory
under package's main directory, which is the
normal location for vendored packages, but can
be overridden by a recipe to filter out other
subdirectories, if needed.
(From OE-Core rev: 9819353726d85780546158428bd97a253705017d)
Signed-off-by: Matt Madison <matt@madison.systems>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/go.bbclass')
-rw-r--r-- | meta/classes/go.bbclass | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass index c1ef01fafe..cb1e96d88b 100644 --- a/meta/classes/go.bbclass +++ b/meta/classes/go.bbclass | |||
@@ -52,6 +52,7 @@ FILES_${PN}-staticdev += "${GOSRC_FINAL}/${GO_IMPORT}" | |||
52 | FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*" | 52 | FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*" |
53 | 53 | ||
54 | GO_INSTALL ?= "${GO_IMPORT}/..." | 54 | GO_INSTALL ?= "${GO_IMPORT}/..." |
55 | GO_INSTALL_FILTEROUT ?= "${GO_IMPORT}/vendor/" | ||
55 | 56 | ||
56 | B = "${WORKDIR}/build" | 57 | B = "${WORKDIR}/build" |
57 | 58 | ||
@@ -73,6 +74,11 @@ python go_do_unpack() { | |||
73 | raise bb.build.FuncFailed(e) | 74 | raise bb.build.FuncFailed(e) |
74 | } | 75 | } |
75 | 76 | ||
77 | go_list_packages() { | ||
78 | GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go list -f '{{.ImportPath}}' ${GOBUILDFLAGS} ${GO_INSTALL} | \ | ||
79 | egrep -v '${GO_INSTALL_FILTEROUT}' | ||
80 | } | ||
81 | |||
76 | go_do_configure() { | 82 | go_do_configure() { |
77 | ln -snf ${S}/src ${B}/ | 83 | ln -snf ${S}/src ${B}/ |
78 | } | 84 | } |
@@ -80,7 +86,7 @@ go_do_configure() { | |||
80 | go_do_compile() { | 86 | go_do_compile() { |
81 | GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env | 87 | GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env |
82 | if [ -n "${GO_INSTALL}" ]; then | 88 | if [ -n "${GO_INSTALL}" ]; then |
83 | GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install ${GOBUILDFLAGS} ${GO_INSTALL} | 89 | GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install ${GOBUILDFLAGS} `go_list_packages` |
84 | fi | 90 | fi |
85 | } | 91 | } |
86 | do_compile[cleandirs] = "${B}/bin ${B}/pkg" | 92 | do_compile[cleandirs] = "${B}/bin ${B}/pkg" |