0

让我说我是 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”构建中生成。运行 abitbake -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!");
      | ^

但是,如果我随后重新编辑并修复文件并重建,则构建完成,但目标文件仍未重新生成。我在更复杂的例子中看到了同样的事情。

有谁知道这是什么原因?我在这里错过了什么吗?

4

1 回答 1

0

首先,奇怪的是为什么它没有因为变量中的语法错误而失败,SRC_URI并且LIC_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

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

于 2022-03-03T09:10:53.400 回答