diff options
author | Matt Madison <matt@madison.systems> | 2017-09-08 18:04:40 -0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-09-11 17:30:30 +0100 |
commit | 07ef4dd93dcb21418647932f3324ee09bc514895 (patch) | |
tree | 2f059cf1c2a0942327d4b0bca77e9c07a6e59dd4 /meta/classes/go.bbclass | |
parent | f01000da80d40e344f33c60c788d36dbb966af36 (diff) | |
download | poky-07ef4dd93dcb21418647932f3324ee09bc514895.tar.gz |
go.bbclass: separate ${S} and ${B}
Add a do_configure task to populate ${B} by symlinking
in the src subdirectory under ${S}, which lets us point
GOPATH at ${B}. This lets us take advantage of the
automatic directory creation and cleaning for do_configure.
This necessitates a change to do_install to split the
installation of the sources and built artifacts. Taking
advantage of some additional tar options, we can eliminate
the extra staging area and extra recursive chown command.
So overall efficiency should be improved.
(From OE-Core rev: c62a083306c26b7e4deca1ff41336bb6b33d5b3a)
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 | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass index 82b5f83aa0..cfe773e13d 100644 --- a/meta/classes/go.bbclass +++ b/meta/classes/go.bbclass | |||
@@ -53,40 +53,30 @@ FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*" | |||
53 | 53 | ||
54 | GO_INSTALL ?= "${GO_IMPORT}/..." | 54 | GO_INSTALL ?= "${GO_IMPORT}/..." |
55 | 55 | ||
56 | B = "${WORKDIR}/build" | ||
57 | |||
58 | go_do_configure() { | ||
59 | ln -snf ${S}/src ${B}/ | ||
60 | } | ||
61 | |||
56 | go_do_compile() { | 62 | go_do_compile() { |
57 | GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env | 63 | GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env |
58 | if [ -n "${GO_INSTALL}" ]; then | 64 | if [ -n "${GO_INSTALL}" ]; then |
59 | GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install ${GOBUILDFLAGS} ${GO_INSTALL} | 65 | GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install ${GOBUILDFLAGS} ${GO_INSTALL} |
60 | fi | 66 | fi |
61 | } | 67 | } |
68 | do_compile[cleandirs] = "${B}/bin ${B}/pkg" | ||
62 | 69 | ||
63 | go_do_install() { | 70 | go_do_install() { |
64 | rm -rf ${WORKDIR}/staging | 71 | install -d ${D}${GOROOT_FINAL}/src/${GO_IMPORT} |
65 | install -d ${WORKDIR}/staging${GOROOT_FINAL} ${D}${GOROOT_FINAL} | 72 | tar -C ${S}/src/${GO_IMPORT} -cf - --exclude-vcs . | \ |
66 | tar -C ${S} -cf - . | tar -C ${WORKDIR}/staging${GOROOT_FINAL} -xpvf - | 73 | tar -C ${D}${GOROOT_FINAL}/src/${GO_IMPORT} --no-same-owner -xf - |
67 | 74 | tar -C ${B} -cf - pkg | tar -C ${D}${GOROOT_FINAL} --no-same-owner -xf - | |
68 | find ${WORKDIR}/staging${GOROOT_FINAL} \( \ | 75 | |
69 | -name \*.indirectionsymlink -o \ | 76 | if [ -n "`ls ${B}/${GO_BUILD_BINDIR}/`" ]; then |
70 | -name .git\* -o \ | 77 | install -d ${D}${bindir} |
71 | -name .hg -o \ | 78 | install -m 0755 ${B}/${GO_BUILD_BINDIR}/* ${D}${bindir}/ |
72 | -name .svn -o \ | ||
73 | -name .pc\* -o \ | ||
74 | -name patches\* \ | ||
75 | \) -print0 | \ | ||
76 | xargs -r0 rm -rf | ||
77 | |||
78 | tar -C ${WORKDIR}/staging${GOROOT_FINAL} -cf - . | \ | ||
79 | tar -C ${D}${GOROOT_FINAL} -xpvf - | ||
80 | |||
81 | chown -R root:root "${D}${GOROOT_FINAL}" | ||
82 | |||
83 | if [ -e "${D}${GOBIN_FINAL}" ]; then | ||
84 | install -d -m 0755 "${D}${bindir}" | ||
85 | find "${D}${GOBIN_FINAL}" ! -type d -print0 | xargs -r0 mv --target-directory="${D}${bindir}" | ||
86 | rmdir -p "${D}${GOBIN_FINAL}" || true | ||
87 | fi | 79 | fi |
88 | } | 80 | } |
89 | do_install[dirs] =+ "${WORKDIR}/staging" | ||
90 | do_install[cleandirs] += "${WORKDIR}/staging" | ||
91 | 81 | ||
92 | EXPORT_FUNCTIONS do_compile do_install | 82 | EXPORT_FUNCTIONS do_configure do_compile do_install |