Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 56 additions & 27 deletions classes/go.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,74 @@ def map_go_arch(a, d):
else:
bb.error("cannot map '%s' to a Go architecture" % a)

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}/bin/${GOOS}_${GOARCH}"
def map_go_arm(f, d):
values = set(f.split())
if 'armv7' in values: return '7'
elif 'armv6' in values: return '6'
elif 'armv5' in values: return '5'
else: return ''

def map_go_386(f, d):
values = set(f.split())
if 'pentium4' in values: return 'sse2'
elif 'i586' in values: return '387'
else: return ''

export GOOS = "linux"
export GOARCH = "${@map_go_arch(d.getVar('TARGET_ARCH', True), d)}"
export GOROOT
export GOROOT_FINAL = "${libdir}/${TARGET_SYS}/go"
export GOBIN_FINAL
export GOPKG_FINAL = "${GOROOT_FINAL}/pkg/${GOOS}_${GOARCH}"
export GOSRC_FINAL = "${GOROOT_FINAL}/src"
export GO_GCFLAGS = "${TARGET_CFLAGS}"
export GO_LDFLAGS = "${TARGET_LDFLAGS}"
export CGO_CFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CFLAGS}"
export CGO_CPPFLAGS = "${TARGET_CPPFLAGS}"
export CGO_CXXFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CXXFLAGS}"
export CGO_LDFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_LDFLAGS}"

DEPENDS += "go-cross-${TARGET_ARCH}"
DEPENDS_class-native += "go-native"

FILES_${PN}-staticdev += "${GOSRC_FINAL}/${GO_IMPORT}"
export GOARM = "${@map_go_arm(d.getVar('TUNE_FEATURES', True), d)}"
export GO386 = "${@map_go_386(d.getVar('TUNE_FEATURES', True), d)}"

GO_FLAGS ?= ""
GO_GCFLAGS ?= ""
GO_ASMFLAGS ?= ""
GO_LDFLAGS ?= ""
export CGO_ENABLED = "1"
export CGO_CFLAGS = "${CFLAGS}"
export CGO_CPPFLAGS = "${CPPFLAGS}"
export CGO_CXXFLAGS = "${CXXFLAGS}"
export CGO_LDFLAGS = "${LDFLAGS}"

DEPENDS += "go-native"

# go binaries don't use GNU_HASH. Known, disable "QA Issue: No GNU_HASH in the elf binary: ..." warnings.
INSANE_SKIP_${PN} += "ldflags"

PACKAGE_ARCH_${PN}-dev = "all"
FILES_${PN}-dev += "${GOSRC_FINAL}/${GO_IMPORT}"
FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*"

GO ?= "go"

GO_INSTALL ?= "${GO_IMPORT}/..."

B = "${WORKDIR}/gopath"
export GOPATH = "${B}:${STAGING_LIBDIR}/go"
export GOROOT = "${STAGING_LIBDIR_NATIVE}/go"

# The "real" GOROOT is embedded in the built go binary
GOROOT_FINAL = "${libdir}/go"
GOROOT_FINAL_class-native = "${STAGING_LIBDIR_NATIVE}/go"

GOPKG_FINAL = "${GOROOT_FINAL}/pkg/${GOOS}_${GOARCH}"
GOSRC_FINAL = "${GOROOT_FINAL}/src"

do_go_compile() {
GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env
if test -n "${GO_INSTALL}" ; then
GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install -v ${GO_INSTALL}
go env

install -d ${B}/src/${GO_IMPORT}
tar -C ${S} -cf - . | tar -C ${B}/src/${GO_IMPORT} -xpf -

if [ -n "${GO_INSTALL}" ]; then
# `godep` needs to be run from dir with ./vendor; `go` doesn't care
( cd ${B}/src/${GO_IMPORT} && ${GO} install -x -asmflags "${GO_ASMFLAGS}" -gcflags "${GO_GCFLAGS}" -ldflags "${GO_LDFLAGS}" ${GO_FLAGS} ${GO_INSTALL} )
fi
}

do_go_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 -
tar -C ${B} -cf - src pkg | tar -C ${WORKDIR}/staging${GOROOT_FINAL} -xpf -

find ${WORKDIR}/staging${GOROOT_FINAL} \( \
-name \*.indirectionsymlink -o \
Expand All @@ -62,10 +92,9 @@ do_go_install() {

chown -R root:root "${D}${GOROOT_FINAL}"

if test -e "${D}${GOBIN_FINAL}" ; then
if test -e "${B}/bin" ; 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
find "${B}/bin" ! -type d -print0 | xargs -r0 install -m 0755 --target-directory="${D}${bindir}"
fi
}

Expand Down
7 changes: 3 additions & 4 deletions recipes-caddy/caddy/github.com-burntsushi-toml.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ GO_IMPORT = "github.com/BurntSushi/toml"

inherit go

SRC_URI = "git://github.com/BurntSushi/toml;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/BurntSushi/toml;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "DWTFYW"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/COPYING;md5=389a9e29629d1f05e115f8f05c283df5"

FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://COPYING;md5=389a9e29629d1f05e115f8f05c283df5"
S = "${WORKDIR}/git"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be simplified even futher similar to how the pypi.bbclass is implemented.

For example in a gopkg.bbclass it could:

  • the SRC_URI could be derived from the import path
  • S could be set by default
  • fill the HOMEPAGE variable

There would only be a minimal set of information required for a standard conform packages, like it is for python for example: https://github.com/openembedded/meta-openembedded/blob/master/meta-python/recipes-devtools/python/python-chardet.inc

Example:

GO_IMPORT = "github.com/BurntSushi/toml"
LICENSE = "DWTFYW"
LIC_FILES_CHKSUM = "file://COPYING;md5=389a9e29629d1f05e115f8f05c283df5"

SRCREV = "${AUTOREV}"

inherit gopkg

9 changes: 6 additions & 3 deletions recipes-caddy/caddy/github.com-codegangsta-cli.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ GO_IMPORT = "github.com/codegangsta/cli"

inherit go

SRC_URI = "git://github.com/codegangsta/cli;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/codegangsta/cli;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=ed9b539ed65d73926f30ff1f1587dc44"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c542707ca9fc0b7802407ba62310bd8f"
S = "${WORKDIR}/git"

FILES_${PN} += "${GOBIN_FINAL}/*"
DEPENDS += "github.com-burntsushi-toml"

GO_INSTALL = "${GO_IMPORT}"
7 changes: 3 additions & 4 deletions recipes-caddy/caddy/github.com-dustin-go-humanize.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ GO_IMPORT = "github.com/dustin/go-humanize"

inherit go

SRC_URI = "git://github.com/dustin/go-humanize;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/dustin/go-humanize;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=8c6127b79304a5e0a5756d03c7a58766"

FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://LICENSE;md5=8c6127b79304a5e0a5756d03c7a58766"
S = "${WORKDIR}/git"
7 changes: 3 additions & 4 deletions recipes-caddy/caddy/github.com-flynn-go-shlex.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ GO_IMPORT = "github.com/flynn/go-shlex"

inherit go

SRC_URI = "git://github.com/flynn/go-shlex;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/flynn/go-shlex;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"

FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
S = "${WORKDIR}/git"
7 changes: 3 additions & 4 deletions recipes-caddy/caddy/github.com-gorilla-websocket.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ GO_IMPORT = "github.com/gorilla/websocket"

inherit go

SRC_URI = "git://github.com/gorilla/websocket;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/gorilla/websocket;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=c007b54a1743d596f46b2748d9f8c044"

FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c007b54a1743d596f46b2748d9f8c044"
S = "${WORKDIR}/git"
7 changes: 3 additions & 4 deletions recipes-caddy/caddy/github.com-hashicorp-go-syslog.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ GO_IMPORT = "github.com/hashicorp/go-syslog"

inherit go

SRC_URI = "git://github.com/hashicorp/go-syslog;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/hashicorp/go-syslog;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=cb04212e101fbbd028f325e04ad45778"

FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://LICENSE;md5=cb04212e101fbbd028f325e04ad45778"
S = "${WORKDIR}/git"
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ GO_IMPORT = "github.com/jimstudt/http-authentication"

inherit go

SRC_URI = "git://github.com/jimstudt/http-authentication;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/jimstudt/http-authentication;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=61e7f1bfbf294711fc438f57de71ccdd"

FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://LICENSE;md5=61e7f1bfbf294711fc438f57de71ccdd"
S = "${WORKDIR}/git"
7 changes: 3 additions & 4 deletions recipes-caddy/caddy/github.com-mholt-caddy.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ GO_IMPORT = "github.com/mholt/caddy"

inherit go

SRC_URI = "git://github.com/mholt/caddy;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/mholt/caddy;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c29e"

FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=e3fc50a88d0a364313df4b21ef20c29e"
S = "${WORKDIR}/git"

DEPENDS += "\
github.com-burntsushi-toml \
Expand Down
7 changes: 4 additions & 3 deletions recipes-caddy/caddy/github.com-russross-blackfriday.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ GO_IMPORT = "github.com/russross/blackfriday"

inherit go

SRC_URI = "git://github.com/russross/blackfriday;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/russross/blackfriday;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE.txt;md5=ecf8a8a60560c35a862a4a545f2db1b3"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=ecf8a8a60560c35a862a4a545f2db1b3"
S = "${WORKDIR}/git"

FILES_${PN} += "${GOBIN_FINAL}/*"
DEPENDS += "github.com-shurcool-sanitized-anchor-name"
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ GO_IMPORT = "github.com/shurcooL/sanitized_anchor_name"

inherit go

SRC_URI = "git://github.com/shurcooL/sanitized_anchor_name;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/shurcooL/sanitized_anchor_name;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "BSD"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=bee2c3aa5bd0f265ffbd193eb18ca30d"

FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://LICENSE;md5=bee2c3aa5bd0f265ffbd193eb18ca30d"
S = "${WORKDIR}/git"
9 changes: 5 additions & 4 deletions recipes-caddy/caddy/github.com-square-go-jose.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ GO_IMPORT = "github.com/square/go-jose"

inherit go

SRC_URI = "git://github.com/square/go-jose;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/square/go-jose;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"

FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
S = "${WORKDIR}/git"

DEPENDS += "github.com-codegangsta-cli"

GO_INSTALL = "${GO_IMPORT}"
7 changes: 4 additions & 3 deletions recipes-caddy/caddy/github.com-xenolf-lego.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ GO_IMPORT = "github.com/xenolf/lego"

inherit go

SRC_URI = "git://github.com/xenolf/lego;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://github.com/xenolf/lego;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=bc6cc6b9955a86b318178c38ac271bba"
LIC_FILES_CHKSUM = "file://LICENSE;md5=bc6cc6b9955a86b318178c38ac271bba"
S = "${WORKDIR}/git"

FILES_${PN} += "${GOBIN_FINAL}/*"
GO_INSTALL = ""
7 changes: 3 additions & 4 deletions recipes-caddy/caddy/gopkg.in-natefinch-lumberjack.v2.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ GO_IMPORT = "gopkg.in/natefinch/lumberjack.v2"

inherit go

SRC_URI = "git://gopkg.in/natefinch/lumberjack.v2;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://gopkg.in/natefinch/lumberjack.v2;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=574cdb55b81249478f5af5f789e9e29f"

FILES_${PN} += "${GOBIN_FINAL}/*"
LIC_FILES_CHKSUM = "file://LICENSE;md5=574cdb55b81249478f5af5f789e9e29f"
S = "${WORKDIR}/git"
9 changes: 4 additions & 5 deletions recipes-caddy/caddy/gopkg.in-yaml.v2.bb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ GO_IMPORT = "gopkg.in/yaml.v2"

inherit go

SRC_URI = "git://gopkg.in/yaml.v2;protocol=https;destsuffix=${PN}-${PV}/src/${GO_IMPORT}"
SRC_URI = "git://gopkg.in/yaml.v2;protocol=https"
SRCREV = "${AUTOREV}"
LICENSE = "LGPL-3"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=3493bb7e185df64f59d28a975a1f91a7"

FILES_${PN} += "${GOBIN_FINAL}/*"
LICENSE = "Apache-2"
LIC_FILES_CHKSUM = "file://LICENSE;md5=6964839e54f4fefcdae13f22b92d0fbb"
S = "${WORKDIR}/git"
2 changes: 0 additions & 2 deletions recipes-devtools/examples/go-examples.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ DESCRIPTION = "This is a simple example recipe that cross-compiles a Go program.
SECTION = "examples"
HOMEPAGE = "https://golang.org/"

DEPENDS = "go-cross-${TARGET_ARCH}"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

LICENSE = "MIT"
Expand Down
16 changes: 5 additions & 11 deletions recipes-devtools/go/go-bootstrap-native_1.4.3.bb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ require go_${PV}.inc

inherit native

do_compile() {
## Setting `$GOBIN` doesn't do any good, looks like it ends up copying binaries there.
export GOROOT_FINAL="${SYSROOT}${nonarch_libdir}/${PN}-${PV}"

setup_go_arch
CGO_ENABLED = "0"
GOROOT_FINAL="${SYSROOT}${nonarch_libdir}/${PN}-${PV}"

export CGO_ENABLED="0"
## TODO: consider setting GO_EXTLINK_ENABLED

# Compile
cd src && bash -x ./make.bash
do_compile() {
bash -x ./make.bash

# Log the resulting environment
env "GOROOT=${WORKDIR}/go-${PV}/go" "${WORKDIR}/go-${PV}/go/bin/go" env
"${S}/bin/go" env
}
1 change: 0 additions & 1 deletion recipes-devtools/go/go-cross

This file was deleted.

8 changes: 0 additions & 8 deletions recipes-devtools/go/go-cross.inc

This file was deleted.

32 changes: 0 additions & 32 deletions recipes-devtools/go/go-cross_1.4.3.bb

This file was deleted.

1 change: 0 additions & 1 deletion recipes-devtools/go/go-cross_1.6.3.bb

This file was deleted.

Loading