aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOtavio Salvador <otavio@ossystems.com.br>2017-09-08 18:04:37 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-11 17:30:14 +0100
commit7a40ea8fc358aa134ad86862591329f94d0f3718 (patch)
tree747c8a40c2a846a6d0020245a8249f0ac44e3e95
parentd6b8e7e94ba6dae44907c5a65bc0bdf0ccebdb15 (diff)
downloadopenembedded-core-contrib-7a40ea8fc358aa134ad86862591329f94d0f3718.tar.gz
openembedded-core-contrib-7a40ea8fc358aa134ad86862591329f94d0f3718.tar.bz2
openembedded-core-contrib-7a40ea8fc358aa134ad86862591329f94d0f3718.zip
go.bbclass: Enable parallel build
The parallel build is based on PARALLEL_MAKE variable but can be overriden setting the GO_PARALLEL_BUILD one. This change is based on the meta-golang[1] layer. Thanks to Matt Madison <matt@madison.systems> for his work on this. 1. https://github.com/madisongh/meta-golang Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/go.bbclass20
1 files changed, 20 insertions, 0 deletions
diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
index 720a504cd85..f64b07fd82b 100644
--- a/meta/classes/go.bbclass
+++ b/meta/classes/go.bbclass
@@ -1,11 +1,31 @@
inherit goarch
+def get_go_parallel_make(d):
+ pm = (d.getVar('PARALLEL_MAKE') or '').split()
+ # look for '-j' and throw other options (e.g. '-l') away
+ # because they might have a different meaning in golang
+ while pm:
+ opt = pm.pop(0)
+ if opt == '-j':
+ v = pm.pop(0)
+ elif opt.startswith('-j'):
+ v = opt[2:].strip()
+ else:
+ continue
+
+ return '-p %d' % int(v)
+
+ return ""
+
+GO_PARALLEL_BUILD ?= "${@get_go_parallel_make(d)}"
+
GOROOT_class-native = "${STAGING_LIBDIR_NATIVE}/go"
GOROOT = "${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
GOBIN_FINAL_class-native = "${GOROOT_FINAL}/bin"
GOBIN_FINAL = "${GOROOT_FINAL}/${GO_BUILD_BINDIR}"
export GOBUILDFLAGS ?= "-v"
+GOBUILDFLAGS_prepend_task-compile = "${GO_PARALLEL_BUILD} "
export GOOS = "${TARGET_GOOS}"
export GOARCH = "${TARGET_GOARCH}"