Yocto:闭源库,带有库和 header 的独立包

Yocto: closed source library with separated packages for library and header

我有自己的.so闭源库,提供header文件。我的 .so 库文件应该在 yocto 图像中,但是 header 文件应该只在另一个项目编译期间使用。

这是 yocto 收据:

SUMMARY = "foo library"
LICENSE = "CLOSED"
SECTION = "libs"
SRC_URI = "file://usr/lib/libfoo.so \
           file://usr/include/foo.h "
S = "${WORKDIR}"
inherit autotools pkgconfig
do_compile() {
}
do_install() {
        install -d ${D}/usr/lib
        install -m 0755 ${WORKDIR}/usr/lib/libfoo.so ${D}/usr/lib/libfoo.so.1
        ln -s /usr/lib/libfoo.so.1 ${D}/usr/lib/libfoo.so
        install -d ${D}/usr/include
        install -m 0644 ${WORKDIR}/usr/include/foo.h ${D}/usr/include/
}

FILES_${PN}-dev += "${includedir} "
FILES_${PN} += "/usr/lib/libfoo.so \
        /usr/lib/libfoo.so.1"
PROVIDES += "libfoo"

我希望 ${PN} 包有 libfoo.so 和 libfoo.so.1 并且 ${PN}-dev 包只有一个 header 文件。但是 yocto bitbake 仅在 ${PN} 中复制 libfoo.so.1 并且 libfoo.so 在 ${PN}-dev 数据包中。

请问如何将 so 文件移动到 ${PN} 包中?

这里的行为是正确的。 Non-versioned .so 文件安装在 -dev 包中,因为系统中的包应该 link 针对版本化文件。

需要在映像中安装 -dev 包的情况很少见,因此有效地,只有版本化的 so 文件才能安装。

如您所见,header 在 -dev 包中,因此除非明确将 -dev 包添加到图像中,否则不会出现在图像中。

因为您的 header 文件位于 includedir 中,这是用于其他食谱 (c.f. SYSROOT_DIRS) 的 sysroot 的目录之一,它将在构建时可用于其他配方。与您的库相同,因为它安装在 lib_dir 中(也在上述变量中​​)。

所以当前的行为是预期的。目前还不清楚为什么你想要你的 non-versioned symlink 也在主包中。

如果出于某种原因这确实是您想要做的,您只需将以下内容添加到您的食谱中:

 SOLIBS = ".so"
 FILES_SOLIBSDEV = ""

c.f。 https://wiki.yoctoproject.org/wiki/TipsAndTricks/Packaging_Prebuilt_Libraries#Non-versioned_Libraries