【发布时间】:2021-01-26 17:24:37
【问题描述】:
我想用 Yocto 2.4.1 为交叉编译的 golang 应用程序编写一个 yocto 配方,但我无法让外部依赖项工作。 谁能帮帮我?
current RECIPE_FILE: hello-world_%.bb
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
DESCRIPTION = "Hello world test with golang."
inherit go
COMPATIBLE_MACHINE = "(<machine>)"
DEPENDS = "go-cross-${TARGET_ARCH}"
GO_IMPORT = "hello-world"
SRC_URI = "<git_url>/${GO_IMPORT}.git;branch=${SRCBRANCH};tag=${PV}"
SRCBRANCH = "master"
PV = "0.01"
S = "${WORKDIR}/git"
do_compile() {
export GOPATH="${WORKDIR}/build"
export GOARCH="<machine_arch>"
export GOOS="linux"
export CGO_ENABLED="0"
go build src/${GO_IMPORT}/hello-world.go
}
do_install() {
install -d "${D}/${bindir}"
install -m 0755 "${WORKDIR}/build/hello-world" "${D}/${bindir}/hello-world"
}
RDEPENDS_${PN}-dev += "bash"
此配方仅适用于内部依赖项。但是如何集成“github.com/golang/protobuf/ptypes”之类的外部依赖项?
PROJECT_FILE: hello-world.go
package main
import (
"fmt"
"github.com/golang/protobuf/ptypes"
)
func main() {
timestamp := ptypes.TimestampNow()
fmt.Println(timestamp)
}
有人知道这个用例的解决方案吗?
或者有谁知道“go-dep”如何处理这个问题?
最好的问候
【问题讨论】:
标签: go dependency-management yocto recipe