Bitbake构建的简单源文件不会生成对象文件,除非我设置了-f(强制)标志选项



让我说我是Yocto的新手。我已经能够创建食谱、包、图像等,但我遇到了以下问题。使用有很多在线参考资料,我尝试使用bitbake创建和构建一个简单的Yocto"helloworld"食谱,该食谱具有以下结构:

├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
├── example
│   └── example_0.1.bb
└── helloworld
├── files
│   └── hellopeterworld.c
└── helloworld_0.1.bb

hellopeterworld.c源文件的内容如下:

#include <stdio.h>
int main() {
printf("Hello, C Programming World! This is Peter!");
return 0;
}

helloworld_01.bb配方的内容如下:

SUMMARY = "bitbake-layers recipe"
DESCRIPTION = "A friendly program that prints Hello World!"
PRIORITY = "optional"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302
SRC_URI = file://hellopeterworld.c
S = "${WORKDIR}"
do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} hellopeterworld.c -o hellopeterworld
}
do_install() {
install -d ${D}${bindir}
install -m 0755 hellopeterworld ${D}${bindir}
}

当试图构建配方时,比如说,文件夹中的构建输出:

/tmp-glibc/work/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/helloworld/0.1-r0/

如下所示:

-rw-r—r—1 pgroves pgroves    65 Feb 23 10:45 configure.sstate
drwxr-xr-x 3 pgroves pgroves  4096 Feb 23 10:20 deploy-debs
-rwxr-xr-x 1 pgroves pgroves 13512 Feb 23 10:45 hellopeterworld
-rw-rw-r—1 pgroves pgroves   101 Feb 23 10:15 hellopeterworld.c
drwxr-xr-x 3 pgroves pgroves  4096 Feb 23 10:45 image
drwxr-xr-x 2 pgroves pgroves  4096 Feb 23 10:45 patches
drwxrwxr-x 2 pgroves pgroves  4096 Feb 23 10:45 pseudo
drwxrwxr-x 5 pgroves pgroves  4096 Feb 23 10:45 recipe-sysroot
drwxrwxr-x 7 pgroves pgroves  4096 Feb 23 10:45 recipe-sysroot-native
drwxr-xr-x 2 pgroves pgroves  4096 Feb 23 10:45 source-date-epoch
drwxrwxr-x 2 pgroves pgroves  4096 Feb 23 10:55 sstate-install-package_write_deb
drwxrwxr-x 2 pgroves pgroves 20480 Feb 23 10:55 temp

问题是"hellopeterworld"对象并不总是在随后的"bitbake-helloworld"构建中生成。运行bitbake -c clean helloworld会删除"0.1-r0"目录的内容。只有当我使用bitbake -f -c compile helloworld强制构建时,才会恢复内容,但这会产生副作用,并引发以下警告:

'helloworld_0.1.bb:do_compile is tainted from a forced run'.

有趣的是,如果我编辑源文件并添加故意的错误语法更改,重建会检测到错误语法并生成错误,正如预期的那样:

NOTE: Executing Tasks
ERROR: helloworld-0.1-r0 do_compile: Execution of 
'<my_workspace>/build- 
openstlinuxweston-stm32mp13-disco/tmp-glibc/work/cortexa7t2hf-neon-vfpv4-ostl-linux- 
gnueabi/helloworld/0.1-r0/temp/run.do_compile.83597' failed with exit code 1:
hellopeterworld.c: In function 'main':
hellopeterworld.c:4:1: error: expected expression before '?' token
4 | ? printf("Hello, C Programming World! This is Peter!");
| ^

但是,如果我重新编辑和修复文件并重新生成,则构建完成,但对象文件仍然没有重新生成。我在更复杂的例子中也看到了同样的情况。

有人知道原因吗?我是不是遗漏了什么?

首先,奇怪的是,为什么它没有因为变量SRC_URILIC_FILES_CHKSUM中的语法错误而失败,它们需要在"中。

LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://hellopeterworld.c"

我已经测试了您的配方,当我更改配方文件夹中的hellopeterworld.c文件时,构建会自动重新启动。

但是,当您运行do_clean时,它不会删除配方的sstate对象,只会删除生成输出,因此当您再次运行时,它将不会执行任何操作。

为了清理sstate对象,您需要运行do_cleansstate

除此之外,我认为你的食谱没有任何问题。

最新更新