Yocto食谱,可通过Dep工具管理Go依赖项 [英] Yocto recipe to manage Go dependencies with dep tool

查看:537
本文介绍了Yocto食谱,可通过Dep工具管理Go依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:此问题已解决。我正在重新编辑问题以将其更新为固定状态。

Update: This question is already SOLVED. I'm re-editing the question to update to the fixed state.

我正在尝试编写使用 dep 工具,用于在构建之前解决 go 相关项目的依赖关系。我正在使用 rocko Yocto项目分支的 poky层。该分支提供了构建 go 编译器和 dep 依赖项工具的方法。

I'm trying to write a recipe that uses dep tool to resolve dependencies of a go related project before building it. I'm using the 'poky' layer of the 'rocko' Yocto project branch. That branch provides recipes to build the go compiler and the dep dependencies tool.

我的初始配方从bitbucket存储库中获取源代码:

My initial recipe fetches source code from a bitbucket repository:

GO_IMPORT = "bitbucket.org/path/to/my_project"
SRC_URI = "git://${GO_IMPORT}/protocol=http;user=${GIT_USER}:${GIT_PASS};destsuffix=${PN}-${PV}/src/${GO_IMPORT}"

然后我添加:

inherit go
DEPENDS += "go-dep"

然后添加此函数:

do_compile_prepend() {
    dep init
    dep ensure
}

Yocto抱怨此错误:

Yocto complains with this error:

run.do_compile.8543: line 118: dep: command not found

阅读下面的一些答案后,我在poky / meta / recipes-devtools / go / go-dep_0.3.0.bb配方文件的末尾添加了建议的补丁 - 非常感谢!! :-)

After reading some of your answers below, I add suggested patch in your answers at the end of my poky/meta/recipes-devtools/go/go-dep_0.3.0.bb recipe file - thanks a lot!! :-)

BBCLASSEXTEND = "native nativesdk"

在我执行了一些bitbake命令后:

After I execute some bitbake commands:

$ bitbake -c cleanall go-dep-native
$ bitbake go-dep-native

Bitbake进程结束,不显示错误或警告。本机 go-dep 工具已内置到tmp / work / x86_64-linux / go-dep-native目录中,并已正确安装到tmp / sysroots-components / x86_64 / go-dep-native / usr / bin。

Bitbake process ends ok, displaying no errors nor warnings. The native go-dep tool has been built into tmp/work/x86_64-linux/go-dep-native directory and is properly installed into tmp/sysroots-components/x86_64/go-dep-native/usr/bin.

我修改do_compile_prepend()函数,如下所示:

I modify the do_compile_prepend() function as shown below:

do_compile_prepend() {
    rm -f ${WORKDIR}/build/src/${GO_IMPORT}/Gopkg.toml
    rm -f ${WORKDIR}/build/src/${GO_IMPORT}/Gopkg.lock
    cd ${WORKDIR}/build/src/${GO_IMPORT}
    dep init
    dep ensure
}

我在食谱中修改DEPENDS,如下所示:

I modify DEPENDS in my recipe like this:

DEPENDS = "go-native go-dep-native"

注意go-dep已被删除(我不需要在目标设备上使用 dep 工具,只需解决本机平台上的依赖项即可。

Note the go-dep has been removed (I don't need dep tool on the target device, just to resolve dependencies on the native platform).

之后那我执行以下命令:

After that, I execute this command:

$ bitbake <foo>

do_compile阶段工作正常,但是在执行do_package阶段时会出现一些错误:

The do_compile stage works fine, but some errors appear when doing the do_package stage:

ERROR: <foo>-1.0-r0 do_package: QA Issue: File '/usr/bin/dep' from <foo> was already stripped, this will prevent future debugging! [already-stripped]
ERROR: <foo>-1.0-r0 do_package: Fatal QA errors found, failing task.
ERROR: <foo>-1.0-r0 do_package: Function failed: do_package

这些错误已在我的食谱末尾附加:

These errors are fixed appending this at the end of my recipe:

INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
INHIBIT_PACKAGE_STRIP = "1"
RDEPENDS_${PN}-staticdev += "bash"
RDEPENDS_${PN}-dev += "bash"

我不知道这是否是解决我的问题的最佳方法,但至少现在可以正常工作。任何改善此食谱的建议都是可以的。先感谢您! :-)

I don't know if this is the best way to solve my issue, but at least now it works fine. Any advice to improve this recipe is wellcome. Thank you in advance! :-)

推荐答案

DEPENDS + = go-dep 表示您的 target 配方可以包含go-dep提供的标题或链接库,但是您无法运行dep命令,如果需要运行dep命令,则需要依赖go-dep-native :

The DEPENDS += "go-dep" means that your target recipe can include headers or link libs provided by go-dep, but you can't run the dep command, if you need run dep command, you need depend on go-dep-native:

DEPENDS += "go-dep-native"

但是yocto当前不提供go-dep-native,因此您必须添加:

But yocto doesn't provide go-dep-native currently, so you have to add:

BBCLASSEXTEND = "native"

元/配方-devtools / go / go-dep_XXX.bb。

然后您可以在 do_compile_prepend()中运行dep命令

这篇关于Yocto食谱,可通过Dep工具管理Go依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆