diff options
Diffstat (limited to 'meta/classes-recipe/go.bbclass')
-rw-r--r-- | meta/classes-recipe/go.bbclass | 26 |
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 @@ | |||
7 | inherit goarch | 7 | inherit goarch |
8 | inherit linuxloader | 8 | inherit linuxloader |
9 | 9 | ||
10 | # if the GO_IMPORT is not set in recipe generate an error | ||
11 | GO_IMPORT ??= "${@bb.fatal("The recipe needs to set GO_IMPORT for go.bbclass to work")}" | ||
12 | |||
10 | GO_PARALLEL_BUILD ?= "${@oe.utils.parallel_make_argument(d, '-p %d')}" | 13 | GO_PARALLEL_BUILD ?= "${@oe.utils.parallel_make_argument(d, '-p %d')}" |
11 | 14 | ||
12 | export GODEBUG = "gocachehash=1" | 15 | export GODEBUG = "gocachehash=1" |
@@ -15,13 +18,12 @@ GOROOT:class-native = "${STAGING_LIBDIR_NATIVE}/go" | |||
15 | GOROOT:class-nativesdk = "${STAGING_DIR_TARGET}${libdir}/go" | 18 | GOROOT:class-nativesdk = "${STAGING_DIR_TARGET}${libdir}/go" |
16 | GOROOT = "${STAGING_LIBDIR}/go" | 19 | GOROOT = "${STAGING_LIBDIR}/go" |
17 | export GOROOT | 20 | export GOROOT |
18 | export GOROOT_FINAL = "${libdir}/go" | ||
19 | export GOCACHE = "${B}/.cache" | 21 | export GOCACHE = "${B}/.cache" |
20 | 22 | ||
21 | export GOARCH = "${TARGET_GOARCH}" | 23 | export GOARCH = "${TARGET_GOARCH}" |
22 | export GOOS = "${TARGET_GOOS}" | 24 | export GOOS = "${TARGET_GOOS}" |
23 | export GOHOSTARCH="${BUILD_GOARCH}" | 25 | export GOHOSTARCH = "${BUILD_GOARCH}" |
24 | export GOHOSTOS="${BUILD_GOOS}" | 26 | export GOHOSTOS = "${BUILD_GOOS}" |
25 | 27 | ||
26 | GOARM[export] = "0" | 28 | GOARM[export] = "0" |
27 | GOARM:arm:class-target = "${TARGET_GOARM}" | 29 | GOARM:arm:class-target = "${TARGET_GOARM}" |
@@ -48,8 +50,6 @@ GO_RPATH:class-native = "${@'-r ${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE | |||
48 | GO_RPATH_LINK:class-native = "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}" | 50 | GO_RPATH_LINK:class-native = "${@'-Wl,-rpath-link=${STAGING_LIBDIR_NATIVE}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}" |
49 | GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS}" | 51 | GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS}" |
50 | GO_LINKMODE ?= "" | 52 | GO_LINKMODE ?= "" |
51 | GO_LINKMODE:class-nativesdk = "--linkmode=external" | ||
52 | GO_LINKMODE:class-native = "--linkmode=external" | ||
53 | GO_EXTRA_LDFLAGS ?= "" | 53 | GO_EXTRA_LDFLAGS ?= "" |
54 | GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}" | 54 | GO_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" | |||
82 | export GOTMPDIR ?= "${WORKDIR}/build-tmp" | 82 | export GOTMPDIR ?= "${WORKDIR}/build-tmp" |
83 | GOTMPDIR[vardepvalue] = "" | 83 | GOTMPDIR[vardepvalue] = "" |
84 | 84 | ||
85 | python go_do_unpack() { | 85 | GO_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 | ||
99 | go_list_packages() { | 87 | go_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 | ||
156 | EXPORT_FUNCTIONS do_unpack do_configure do_compile do_install | 144 | EXPORT_FUNCTIONS do_configure do_compile do_install |
157 | 145 | ||
158 | FILES:${PN}-dev = "${libdir}/go/src" | 146 | FILES:${PN}-dev = "${libdir}/go/src" |
159 | FILES:${PN}-staticdev = "${libdir}/go/pkg" | 147 | FILES:${PN}-staticdev = "${libdir}/go/pkg" |