使用 bitbake 构建 OpenDDS

Building OpenDDS with bitbake

我需要使用 bitbake 为我的 Yocto 项目构建 OpenDDS-3.13.1。 Target 目前只有 QEMU。

但是,我下载了源代码(它们在主机系统上配置、编译和 link 非常好)并将它们 link 编辑到我的食谱中。 继承 "autoconf" 会导致配置步骤出错,它无法以某种方式扩展默认参数(这已经很奇怪了)。

经过一番搜索,我发现了一个关于这个话题的很老的讨论:https://lists.yoctoproject.org/pipermail/yocto/2011-July/002126.html

我的食谱目前看起来如下:

FILESEXTRAPATHS_prepend := "[PATH_TO_SOURCE]:"

PV = "3.13.1"

SRC_URI = "file://${PN}-${PV}.tar.gz"

S = "${WORKDIR}/${PN}-${PV}"
B = "${S}"

do_configure() {
    ./configure
}

do_compile() {
    make
}

目前配置步骤运行成功,但编译失败,因为找不到 header 个文件。如上面邮件列表 post 中所述,我尝试将 CXXFLAGS 添加到配置步骤。这将越过第一个缺失的包含 ("features"),但在下一个 ("sting") 处停止。两个 header 分别在 ${S} 和 ${B} 中可用,因此也是 ${STAGING_DIR_HOST} 的一部分。

我在这里错过了什么?我实际上希望所有步骤都被继承自动工具隐式覆盖。

编辑:

这里要求的是日志输出:

DEBUG: Executing shell function do_compile
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/ace'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/ace/GNUmakefile.ACE MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/ace'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/ACEXML/common'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/ACEXML/common/GNUmakefile.ACEXML MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/ACEXML/common'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/ACEXML/parser/parser'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/ACEXML/parser/parser/GNUmakefile.ACEXML_Parser MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/ACEXML/parser/parser'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_FE MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_BE MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_BE_VIS_A MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_BE_VIS_C MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_BE_VIS_E MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_BE_VIS_I MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_BE_VIS_O MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_BE_VIS_S MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_BE_VIS_U MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_BE_VIS_V MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/apps/gperf/src'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/apps/gperf/src/GNUmakefile.gperf MAKEFLAGS=w

make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/apps/gperf/src'
make[1]: Entering directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'

GNUmakefile: /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL/GNUmakefile.TAO_IDL_EXE MAKEFLAGS=w

x86_64-poky-linux-g++  -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/recipe-sysroot -fvisibility=hidden -fvisibility-inlines-hidden -Wnon-virtual-dtor -ggdb -pthread -fno-strict-aliasing -Wall -W -Wpointer-arith -pipe  -D_GNU_SOURCE   -I/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers -D__ACE_INLINE__ -I../.. -I../TAO_IDL/fe -I../TAO_IDL/include -I.. -Iinclude -Ibe_include -Ife -I.. -DTAO_IDL_PREPROCESSOR=\"x86_64-poky-linux-g++ -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/recipe-sysroot\"  -c -o .obj/driver/drv_args.o driver/drv_args.cpp
<command-line>:0:22: warning: missing terminating " character
driver/drv_args.cpp:69:10: fatal error: string: No such file or directory
 #include <string>
          ^~~~~~~~
compilation terminated.
/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/include/makeinclude/rules.local.GNU:134: recipe for target '.obj/driver/drv_args.o' failed
make[1]: *** [.obj/driver/drv_args.o] Error 1
make[1]: Leaving directory '/media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/OpenDDS-3.13.1/ACE_wrappers/TAO/TAO_IDL'
GNUmakefile.dist:568: recipe for target 'TAO_IDL_EXE' failed
make: *** [TAO_IDL_EXE] Error 2
WARNING: exit code 2 from a shell command.
ERROR: Function failed: do_compile (log file is located at /media/work/10_Projects/Yocto/blub/build/tmp/work/core2-64-poky-linux/OpenDDS/3.13.1-r0/temp/log.do_compile.15963)

I actually expected all step are implicitly covered by inheriting autotools.

但你没有 inherit autotools。无论如何这都无济于事,因为 OpenDDS 不使用自动工具。

首先进行一些清理:FILESEXTRAPATH 应该被删除,调用配方 name_version.bb 并且您可以删除 PV,那些 SB 值是默认值。您的 do_compile 基本上与默认值相同。 SRC_URI应该是https://github.com/objectcomputing/OpenDDS/releases/download/DDS-3.13.1/OpenDDS-3.13.1.tar.gz

重要的是 do_configure 任务的输出是什么。 OpenDDS 有一个手工编码的一次性 configure ,您需要小心调用。看一眼脚本,似乎传递 --target 是一个好的开始。

对于 openDDS,通常的 cross-compiling 方法无法开箱即用。在这里,您需要 运行 在您的主机上下文中进行编译过程,并引用您的交叉编译器,它将被 openDDS 的构建系统使用。

获取方法如下运行:

来自 openDDS 源的配置脚本不接受 bitbake 所需的 cross-compilers 的额外参数。因此,我将它们包装成脚本,替换了对 CC、CXX、LD 和 AR 的最终调用:

在 do_unpack 执行以下操作后创建一个新任务

  • 从变量(CC、CXX 和 AR)中提取二进制名称并创建同名的本地脚本
  • 将 shebang 插入刚刚创建的包装器脚本
  • 将变量的全部值(此处为 $CC)附加到包装脚本中
  • 使包装器可执行
cc_wrapper=`echo ${CC} | cut -f 1 -d\  `
echo '#!/bin/sh' > ${S}/${cc_wrapper}
echo "${CC} \"$@\"" >> ${S}/${cc_wrapper}
chmod +x ${S}/${cc_wrapper}
  • 对 CXX 和 AR 做同样的事情

覆盖配置步骤

  • 提取目标交叉编译器的完整路径
target_compiler="${S}/`echo ${CXX} | cut -f 1 -d\  `"
  • 并将指向 bitbake cross-compiler 的 CC 变量替换为主机本地变量:
export CC=$BUILD_CC
  • 对 CXX 和 AR 也做同样的事情
  • 使用预期的交叉编译选项对配置脚本进行最终调用
./configure --target=linux-cross --target-compiler=$target_compiler

(Note the reference to $target_compiler set above)

覆盖编译步骤

  • 再次导出 CC、CXX、AR 以及 LD 以指向主机本机实例
export CC=$BUILD_CC
  • 最后只需在编译步骤中调用 make,就可以实现!