简单源文件的 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_0 的内容.1.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 -ccompile 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!");
| ^
但是如果我然后重新编辑并修复文件并重建,构建会完成,但目标文件仍然不会重新生成。我在更复杂的例子中看到了同样的事情。
有谁知道这是为什么?我在这里错过了什么吗?
Let me just say that I am new to Yocto. I have been able to create recipes, packages, images etc. however I am encountering the following issue. Using online references of which there are many, I have tried to create and build a simple Yocto 'helloworld' recipe using bitbake, which has the following structure:
├── conf
│ └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
├── example
│ └── example_0.1.bb
└── helloworld
├── files
│ └── hellopeterworld.c
└── helloworld_0.1.bb
The content of the hellopeterworld.c source file is as follows:
#include <stdio.h>
int main() {
printf("Hello, C Programming World! This is Peter!");
return 0;
}
The content of the helloworld_0.1.bb recipe is as follows:
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}
}
When attempting to build the recipe, say, the build output in the folder:
/tmp-glibc/work/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/helloworld/0.1-r0/
is as follows:
-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
The problem is that the ‘hellopeterworld’ object is not always being generated on subsequent 'bitbake helloworld' builds. Running a bitbake -c clean helloworld
removes the contents of '0.1-r0' directory. The contents is restored only if I force the build using bitbake -f -c compile helloworld
but this has a side effect with the following WARNING being raised:
'helloworld_0.1.bb:do_compile is tainted from a forced run'.
The funny thing is that if I edit the source file and add a deliberate bad syntax change, the rebuild detects the bad syntax and generates an error, as expected:
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!");
| ^
But if I then re-edit and fix the file and rebuild, the build completes but the the object file still isn’t being regenerated. I'm seeing the same thing with more complex examples.
Does anyone know the reason for this? Am I missing something here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,奇怪的是为什么它没有因为变量
SRC_URI
和LIC_FILES_CHKSUM
中的语法错误而失败,它们需要位于"
中>。我已经测试了您的配方,当我更改配方文件夹中的
hellopeterworld.c
文件时,构建会自动重新启动。但是,当您运行
do_clean
时,它不会删除该文件。配方的 sstate 对象,它只会删除构建输出,因此当您再次重新运行时,它不会执行任何操作。为了清理 sstate 对象,您需要运行 。 >do_cleansstate
除此之外,我没有发现你的食谱有任何问题。
First of all, it is weird why it didn't fail because of a syntax error in variables
SRC_URI
andLIC_FILES_CHKSUM
, they need to be in"
.I have tested your recipe and the build restarts automatically when I change the
hellopeterworld.c
file in the recipe folder.However, when you run
do_clean
it does not remove thesstate
object of the recipe, it only removes the build output, so when you rerun again it will do nothing.In order to clean the
sstate
object you need to rundo_cleansstate
.Other than that, I do not see any issue with your recipe.