[oe-commits] [openembedded-core] 61/65: go.bbclass: separate ${S} and ${B}

git at git.openembedded.org git at git.openembedded.org
Mon Sep 11 10:02:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 4fa1eff67484d57ac991daa67b20fa6fef4a10af
Author: Matt Madison <matt at madison.systems>
AuthorDate: Fri Sep 8 18:04:40 2017 -0300

    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.
    
    Signed-off-by: Matt Madison <matt at madison.systems>
    Signed-off-by: Otavio Salvador <otavio at ossystems.com.br>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/go.bbclass | 46 ++++++++++++++++++----------------------------
 1 file changed, 18 insertions(+), 28 deletions(-)

diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
index 82b5f83..cfe773e 100644
--- a/meta/classes/go.bbclass
+++ b/meta/classes/go.bbclass
@@ -53,40 +53,30 @@ FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*"
 
 GO_INSTALL ?= "${GO_IMPORT}/..."
 
+B = "${WORKDIR}/build"
+
+go_do_configure() {
+	ln -snf ${S}/src ${B}/
+}
+
 go_do_compile() {
-	GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env
+	GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env
 	if [ -n "${GO_INSTALL}" ]; then
-		GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install ${GOBUILDFLAGS} ${GO_INSTALL}
+		GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install ${GOBUILDFLAGS} ${GO_INSTALL}
 	fi
 }
+do_compile[cleandirs] = "${B}/bin ${B}/pkg"
 
 go_do_install() {
-	rm -rf ${WORKDIR}/staging
-	install -d ${WORKDIR}/staging${GOROOT_FINAL} ${D}${GOROOT_FINAL}
-	tar -C ${S} -cf - . | tar -C ${WORKDIR}/staging${GOROOT_FINAL} -xpvf -
-
-	find ${WORKDIR}/staging${GOROOT_FINAL} \( \
-		-name \*.indirectionsymlink -o \
-		-name .git\* -o                \
-		-name .hg -o                   \
-		-name .svn -o                  \
-		-name .pc\* -o                 \
-		-name patches\*                \
-		\) -print0 | \
-	xargs -r0 rm -rf
-
-	tar -C ${WORKDIR}/staging${GOROOT_FINAL} -cf - . | \
-	tar -C ${D}${GOROOT_FINAL} -xpvf -
-
-	chown -R root:root "${D}${GOROOT_FINAL}"
-
-	if [ -e "${D}${GOBIN_FINAL}" ]; then
-		install -d -m 0755 "${D}${bindir}"
-		find "${D}${GOBIN_FINAL}" ! -type d -print0 | xargs -r0 mv --target-directory="${D}${bindir}"
-		rmdir -p "${D}${GOBIN_FINAL}" || true
+	install -d ${D}${GOROOT_FINAL}/src/${GO_IMPORT}
+	tar -C ${S}/src/${GO_IMPORT} -cf - --exclude-vcs . | \
+		tar -C ${D}${GOROOT_FINAL}/src/${GO_IMPORT} --no-same-owner -xf -
+	tar -C ${B} -cf - pkg | tar -C ${D}${GOROOT_FINAL} --no-same-owner -xf -
+
+	if [ -n "`ls ${B}/${GO_BUILD_BINDIR}/`" ]; then
+		install -d ${D}${bindir}
+		install -m 0755 ${B}/${GO_BUILD_BINDIR}/* ${D}${bindir}/
 	fi
 }
-do_install[dirs] =+ "${WORKDIR}/staging"
-do_install[cleandirs] += "${WORKDIR}/staging"
 
-EXPORT_FUNCTIONS do_compile do_install
+EXPORT_FUNCTIONS do_configure do_compile do_install

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list