在 Yocto 中构建系统派生工具链

build system derived toolchain in Yocto

我有一个问题,从 rocko 升级开始,与 Yocto 2.3 中引入的 Recipe-specific Sysroots 相关

我们的项目使用cmake。所以我们的食谱有:

DEPENDS = "cmake-native [...]"

所以 cmake 结束于 build/tmp/work/cortexa5hf-neon-poky-linux-gnueabi/component/1.0-r0/recipe-sysroot-native/usr/bin/cmake 所以在 yocto 内部构建时一切正常。

当我们在 yocto 外部构建时,我们使用在构建目录中生成和填充的交叉工具链:

$ bitbake meta-ide-toolchain

然后获取环境:

$ source build/tmp/environment-setup-cortexa5hf-neon-poky-linux-gnueabi

在 rocko OECORE_NATIVE_SYSROOT 上设置为 [...]/build/tmp/work/cortexa5hf-neon-poky-linux-gnueabi/meta-ide-support/1.0-r3/recipe-sysroot-native - 没有 cmake:

  $ which cmake
  $

所以没有找到cmake...

在 Krogoth 上是 build/tmp/sysroots/x86_64-linux - cmake 在那里:

$ which cmake
  <full path>/build/tmp/sysroots/x86_64-linux/usr/bin/cmake

如何正确设置从构建目录派生的工具链以便在 Yocto 外部构建?

我最终没有使用 meta-ide-support,而是在我自己的配方(我的组件)中添加了生成工具链的支持:这是我的最终意图,也能够构建我在 Yocto 之外的组件。

因此,当我在构建组件之外执行 bitbake my-component 时,还会生成在 Yocto 外部构建组件所需的工具链。

在我的食谱中,我添加了一些来自 meta-ide-support:

的代码
inherit toolchain-scripts

do_populate_ide_support () {
  toolchain_create_tree_env_script
}
addtask populate_ide_support before do_build after do_install

现在,当我构建我的食谱时,我还在 build/tmp/ 目录中获得了一个环境设置脚本 - 与之前使用的 meta-ide-toolchain 相同的位置。

现在一切都已正确设置:

OECORE_NATIVE_SYSROOT 设置为 [...]/build/tmp/work/cortexa5hf-neon-poky-linux-gnueabi/component/1.0/recipe-sysroot-native