diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-11-07 13:31:53 +0000 |
| commit | 8c22ff0d8b70d9b12f0487ef696a7e915b9e3173 (patch) | |
| tree | efdc32587159d0050a69009bdf2330a531727d95 /meta/classes-recipe/go.bbclass | |
| parent | d412d2747595c1cc4a5e3ca975e3adc31b2f7891 (diff) | |
| download | poky-8c22ff0d8b70d9b12f0487ef696a7e915b9e3173.tar.gz | |
The poky repository master branch is no longer being updated.
You can either:
a) switch to individual clones of bitbake, openembedded-core, meta-yocto and yocto-docs
b) use the new bitbake-setup
You can find information about either approach in our documentation:
https://docs.yoctoproject.org/
Note that "poky" the distro setting is still available in meta-yocto as
before and we continue to use and maintain that.
Long live Poky!
Some further information on the background of this change can be found
in: https://lists.openembedded.org/g/openembedded-architecture/message/2179
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/go.bbclass')
| -rw-r--r-- | meta/classes-recipe/go.bbclass | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/meta/classes-recipe/go.bbclass b/meta/classes-recipe/go.bbclass deleted file mode 100644 index e0f667373e..0000000000 --- a/meta/classes-recipe/go.bbclass +++ /dev/null | |||
| @@ -1,159 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Copyright OpenEmbedded Contributors | ||
| 3 | # | ||
| 4 | # SPDX-License-Identifier: MIT | ||
| 5 | # | ||
| 6 | |||
| 7 | inherit goarch | ||
| 8 | inherit linuxloader | ||
| 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 | |||
| 13 | GO_PARALLEL_BUILD ?= "${@oe.utils.parallel_make_argument(d, '-p %d')}" | ||
| 14 | |||
| 15 | export GODEBUG = "gocachehash=1" | ||
| 16 | |||
| 17 | GOROOT:class-native = "${STAGING_LIBDIR_NATIVE}/go" | ||
| 18 | GOROOT:class-nativesdk = "${STAGING_DIR_TARGET}${libdir}/go" | ||
| 19 | GOROOT = "${STAGING_LIBDIR}/go" | ||
| 20 | export GOROOT | ||
| 21 | export GOCACHE = "${B}/.cache" | ||
| 22 | |||
| 23 | export GOARCH = "${TARGET_GOARCH}" | ||
| 24 | export GOOS = "${TARGET_GOOS}" | ||
| 25 | export GOHOSTARCH = "${BUILD_GOARCH}" | ||
| 26 | export GOHOSTOS = "${BUILD_GOOS}" | ||
| 27 | |||
| 28 | GOARM[export] = "0" | ||
| 29 | GOARM:arm:class-target = "${TARGET_GOARM}" | ||
| 30 | GOARM:arm:class-target[export] = "1" | ||
| 31 | |||
| 32 | GO386[export] = "0" | ||
| 33 | GO386:x86:class-target = "${TARGET_GO386}" | ||
| 34 | GO386:x86:class-target[export] = "1" | ||
| 35 | |||
| 36 | GOMIPS[export] = "0" | ||
| 37 | GOMIPS:mips:class-target = "${TARGET_GOMIPS}" | ||
| 38 | GOMIPS:mips:class-target[export] = "1" | ||
| 39 | |||
| 40 | DEPENDS_GOLANG:class-target = "virtual/${TUNE_PKGARCH}-go virtual/${TARGET_PREFIX}go-runtime" | ||
| 41 | DEPENDS_GOLANG:class-native = "go-native" | ||
| 42 | DEPENDS_GOLANG:class-nativesdk = "virtual/${TARGET_PREFIX}go virtual/${TARGET_PREFIX}go-runtime" | ||
| 43 | |||
| 44 | DEPENDS:append = " ${DEPENDS_GOLANG}" | ||
| 45 | |||
| 46 | GO_LINKSHARED ?= "${@'-linkshared' if d.getVar('GO_DYNLINK') else ''}" | ||
| 47 | GO_RPATH_LINK = "${@'-Wl,-rpath-link=${STAGING_DIR_TARGET}${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}" | ||
| 48 | GO_RPATH = "${@'-r ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink' if d.getVar('GO_DYNLINK') else ''}" | ||
| 49 | GO_RPATH:class-native = "${@'-r ${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 ''}" | ||
| 51 | GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${GO_RPATH_LINK} ${LDFLAGS}" | ||
| 52 | GO_LINKMODE ?= "" | ||
| 53 | GO_EXTRA_LDFLAGS ?= "" | ||
| 54 | GO_LINUXLOADER ?= "-I ${@get_linuxloader(d)}" | ||
| 55 | # Use system loader. If uninative is used, the uninative loader will be patched automatically | ||
| 56 | GO_LINUXLOADER:class-native = "" | ||
| 57 | GO_LDFLAGS ?= '-ldflags="${GO_RPATH} ${GO_LINKMODE} ${GO_LINUXLOADER} ${GO_EXTRA_LDFLAGS} -extldflags '${GO_EXTLDFLAGS}'"' | ||
| 58 | export GOBUILDFLAGS ?= "-v ${GO_LDFLAGS} -trimpath" | ||
| 59 | export GOPATH_OMIT_IN_ACTIONID ?= "1" | ||
| 60 | export GOPTESTBUILDFLAGS ?= "${GOBUILDFLAGS} -c" | ||
| 61 | export GOPTESTFLAGS ?= "" | ||
| 62 | GOBUILDFLAGS:prepend:task-compile = "${GO_PARALLEL_BUILD} " | ||
| 63 | |||
| 64 | export GO = "${HOST_PREFIX}go" | ||
| 65 | GOTOOLDIR = "${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go/pkg/tool/${BUILD_GOTUPLE}" | ||
| 66 | GOTOOLDIR:class-native = "${STAGING_LIBDIR_NATIVE}/go/pkg/tool/${BUILD_GOTUPLE}" | ||
| 67 | export GOTOOLDIR | ||
| 68 | |||
| 69 | export CGO_ENABLED ?= "1" | ||
| 70 | export CGO_CFLAGS ?= "${CFLAGS}" | ||
| 71 | export CGO_CPPFLAGS ?= "${CPPFLAGS}" | ||
| 72 | export CGO_CXXFLAGS ?= "${CXXFLAGS}" | ||
| 73 | export CGO_LDFLAGS ?= "${LDFLAGS}" | ||
| 74 | |||
| 75 | GO_INSTALL ?= "${GO_IMPORT}/..." | ||
| 76 | GO_INSTALL_FILTEROUT ?= "${GO_IMPORT}/vendor/" | ||
| 77 | |||
| 78 | B = "${WORKDIR}/build" | ||
| 79 | export GOPATH = "${B}" | ||
| 80 | export GOENV = "off" | ||
| 81 | export GOPROXY ??= "https://proxy.golang.org,direct" | ||
| 82 | export GOTMPDIR ?= "${WORKDIR}/build-tmp" | ||
| 83 | GOTMPDIR[vardepvalue] = "" | ||
| 84 | |||
| 85 | GO_SRCURI_DESTSUFFIX = "${@os.path.join(os.path.basename(d.getVar('S')), 'src', d.getVar('GO_IMPORT')) + '/'}" | ||
| 86 | |||
| 87 | go_list_packages() { | ||
| 88 | ${GO} list -f '{{.ImportPath}}' ${GOBUILDFLAGS} ${GO_INSTALL} | \ | ||
| 89 | egrep -v '${GO_INSTALL_FILTEROUT}' | ||
| 90 | } | ||
| 91 | |||
| 92 | go_list_package_tests() { | ||
| 93 | ${GO} list -f '{{.ImportPath}} {{.TestGoFiles}}' ${GOBUILDFLAGS} ${GO_INSTALL} | \ | ||
| 94 | grep -v '\[\]$' | \ | ||
| 95 | egrep -v '${GO_INSTALL_FILTEROUT}' | \ | ||
| 96 | awk '{ print $1 }' | ||
| 97 | } | ||
| 98 | |||
| 99 | go_do_configure() { | ||
| 100 | ln -snf ${S}/src ${B}/ | ||
| 101 | } | ||
| 102 | do_configure[dirs] =+ "${GOTMPDIR}" | ||
| 103 | |||
| 104 | go_do_compile() { | ||
| 105 | export TMPDIR="${GOTMPDIR}" | ||
| 106 | if [ -n "${GO_INSTALL}" ]; then | ||
| 107 | if [ -n "${GO_LINKSHARED}" ]; then | ||
| 108 | ${GO} install ${GOBUILDFLAGS} `go_list_packages` | ||
| 109 | rm -rf ${B}/bin | ||
| 110 | fi | ||
| 111 | ${GO} install ${GO_LINKSHARED} ${GOBUILDFLAGS} `go_list_packages` | ||
| 112 | fi | ||
| 113 | } | ||
| 114 | do_compile[dirs] =+ "${GOTMPDIR}" | ||
| 115 | do_compile[cleandirs] = "${B}/bin ${B}/pkg" | ||
| 116 | |||
| 117 | go_do_install() { | ||
| 118 | install -d ${D}${libdir}/go/src/${GO_IMPORT} | ||
| 119 | tar -C ${S}/src/${GO_IMPORT} -cf - --exclude-vcs --exclude '*.test' --exclude 'testdata' . | \ | ||
| 120 | tar -C ${D}${libdir}/go/src/${GO_IMPORT} --no-same-owner -xf - | ||
| 121 | tar -C ${B} -cf - --exclude-vcs --exclude '*.test' --exclude 'testdata' pkg | \ | ||
| 122 | tar -C ${D}${libdir}/go --no-same-owner -xf - | ||
| 123 | |||
| 124 | if ls ${B}/${GO_BUILD_BINDIR}/* >/dev/null 2>/dev/null ; then | ||
| 125 | install -d ${D}${bindir} | ||
| 126 | install -m 0755 ${B}/${GO_BUILD_BINDIR}/* ${D}${bindir}/ | ||
| 127 | fi | ||
| 128 | } | ||
| 129 | |||
| 130 | go_stage_testdata() { | ||
| 131 | oldwd="$PWD" | ||
| 132 | cd ${S}/src | ||
| 133 | find ${GO_IMPORT} -depth -type d -name testdata | while read d; do | ||
| 134 | if echo "$d" | grep -q '/vendor/'; then | ||
| 135 | continue | ||
| 136 | fi | ||
| 137 | parent=`dirname $d` | ||
| 138 | install -d ${D}${PTEST_PATH}/$parent | ||
| 139 | cp --preserve=mode,timestamps -R $d ${D}${PTEST_PATH}/$parent/ | ||
| 140 | done | ||
| 141 | cd "$oldwd" | ||
| 142 | } | ||
| 143 | |||
| 144 | EXPORT_FUNCTIONS do_configure do_compile do_install | ||
| 145 | |||
| 146 | FILES:${PN}-dev = "${libdir}/go/src" | ||
| 147 | FILES:${PN}-staticdev = "${libdir}/go/pkg" | ||
| 148 | |||
| 149 | INSANE_SKIP:${PN} += "ldflags" | ||
| 150 | |||
| 151 | # Add -buildmode=pie to GOBUILDFLAGS to satisfy "textrel" QA checking, but mips | ||
| 152 | # doesn't support -buildmode=pie, so skip the QA checking for mips/rv32 and its | ||
| 153 | # variants. | ||
| 154 | python() { | ||
| 155 | if 'mips' in d.getVar('TARGET_ARCH') or 'riscv32' in d.getVar('TARGET_ARCH'): | ||
| 156 | d.appendVar('INSANE_SKIP:%s' % d.getVar('PN'), " textrel") | ||
| 157 | else: | ||
| 158 | d.appendVar('GOBUILDFLAGS', ' -buildmode=pie') | ||
| 159 | } | ||
