summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/go.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes-recipe/go.bbclass')
-rw-r--r--meta/classes-recipe/go.bbclass26
1 files changed, 7 insertions, 19 deletions
diff --git a/meta/classes-recipe/go.bbclass b/meta/classes-recipe/go.bbclass
index cc3564c36a..e0f667373e 100644
--- a/meta/classes-recipe/go.bbclass
+++ b/meta/classes-recipe/go.bbclass
@@ -7,6 +7,9 @@
7inherit goarch 7inherit goarch
8inherit linuxloader 8inherit linuxloader
9 9
10# if the GO_IMPORT is not set in recipe generate an error
11GO_IMPORT ??= "${@bb.fatal("The recipe needs to set GO_IMPORT for go.bbclass to work")}"
12
10GO_PARALLEL_BUILD ?= "${@oe.utils.parallel_make_argument(d, '-p %d')}" 13GO_PARALLEL_BUILD ?= "${@oe.utils.parallel_make_argument(d, '-p %d')}"
11 14
12export GODEBUG = "gocachehash=1" 15export GODEBUG = "gocachehash=1"
@@ -15,13 +18,12 @@ GOROOT:class-native = "${STAGING_LIBDIR_NATIVE}/go"
15GOROOT:class-nativesdk = "${STAGING_DIR_TARGET}${libdir}/go" 18GOROOT:class-nativesdk = "${STAGING_DIR_TARGET}${libdir}/go"
16GOROOT = "${STAGING_LIBDIR}/go" 19GOROOT = "${STAGING_LIBDIR}/go"
17export GOROOT 20export GOROOT
18export GOROOT_FINAL = "${libdir}/go"
19export GOCACHE = "${B}/.cache" 21export GOCACHE = "${B}/.cache"
20 22
21export GOARCH = "${TARGET_GOARCH}" 23export GOARCH = "${TARGET_GOARCH}"
22export GOOS = "${TARGET_GOOS}" 24export GOOS = "${TARGET_GOOS}"
23export GOHOSTARCH="${BUILD_GOARCH}" 25export GOHOSTARCH = "${BUILD_GOARCH}"
24export GOHOSTOS="${BUILD_GOOS}" 26export GOHOSTOS = "${BUILD_GOOS}"
25 27
26GOARM[export] = "0" 28GOARM[export] = "0"
27GOARM:arm:class-target = "${TARGET_GOARM}" 29GOARM:arm:class-target = "${TARGET_GOARM}"
@@ -48,8 +50,6 @@ GO_RPATH:class-native = "${@'-r ${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE
48GO_RPATH_LINK:class-native = "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}" 50GO_RPATH_LINK:class-native = "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}"
49GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS}" 51GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS}"
50GO_LINKMODE ?= "" 52GO_LINKMODE ?= ""
51GO_LINKMODE:class-nativesdk = "--linkmode=external"
52GO_LINKMODE:class-native = "--linkmode=external"
53GO_EXTRA_LDFLAGS ?= "" 53GO_EXTRA_LDFLAGS ?= ""
54GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}" 54GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}"
55# Use system loader. If uninative is used, the uninative loader will be patched automatically 55# Use system loader. If uninative is used, the uninative loader will be patched automatically
@@ -82,19 +82,7 @@ export GOPROXY ??= "https://proxy.golang.org,direct"
82export GOTMPDIR ?= "${WORKDIR}/build-tmp" 82export GOTMPDIR ?= "${WORKDIR}/build-tmp"
83GOTMPDIR[vardepvalue] = "" 83GOTMPDIR[vardepvalue] = ""
84 84
85python go_do_unpack() { 85GO_SRCURI_DESTSUFFIX = "${@os.path.join(os.path.basename(d.getVar('S')), 'src', d.getVar('GO_IMPORT')) + '/'}"
86 src_uri = (d.getVar('SRC_URI') or "").split()
87 if len(src_uri) == 0:
88 return
89
90 fetcher = bb.fetch2.Fetch(src_uri, d)
91 for url in fetcher.urls:
92 if fetcher.ud[url].type == 'git':
93 if fetcher.ud[url].parm.get('destsuffix') is None:
94 s_dirname = os.path.basename(d.getVar('S'))
95 fetcher.ud[url].parm['destsuffix'] = os.path.join(s_dirname, 'src', d.getVar('GO_IMPORT')) + '/'
96 fetcher.unpack(d.getVar('WORKDIR'))
97}
98 86
99go_list_packages() { 87go_list_packages() {
100 ${GO} list -f '{{.ImportPath}}' ${GOBUILDFLAGS} ${GO_INSTALL} | \ 88 ${GO} list -f '{{.ImportPath}}' ${GOBUILDFLAGS} ${GO_INSTALL} | \
@@ -153,7 +141,7 @@ go_stage_testdata() {
153 cd "$oldwd" 141 cd "$oldwd"
154} 142}
155 143
156EXPORT_FUNCTIONS do_unpack do_configure do_compile do_install 144EXPORT_FUNCTIONS do_configure do_compile do_install
157 145
158FILES:${PN}-dev = "${libdir}/go/src" 146FILES:${PN}-dev = "${libdir}/go/src"
159FILES:${PN}-staticdev = "${libdir}/go/pkg" 147FILES:${PN}-staticdev = "${libdir}/go/pkg"