在bitbake中,当使用require关键字添加包含文件时,继承是否可以在包含文件之间转移?或者我们是否需要在每个包含文件中一遍又一遍地重用inherit关键字?我正在使用 Bitbake 和 Yocto 构建图像。
exampleA.inc 文件
inherit exampleC
exampleB.inc 文件
require exampleA.inc
那么,如果我也希望 exampleB.inc 继承自 exampleC,是否需要在此文件中指定它?
假设 exampleC 是 bbclass 文件。
最佳答案
TLDR:一个继承语句就足够了。
require
和 include
只是将指定文件的内容插入到配方中的当前位置。这会产生相同的结果,就好像您已将 .inc
文件的全部内容写入配方中一样。多层 include
/require
不应改变这一点。这意味着,不是 .inc
文件继承自 exanpleC
,而是配方,它需要所述 .inc
文件。
我还进行了一些快速测试来证实这个理论,这一切似乎都有效。
不要被 BitBake 文档中的说明吓倒:
[...] you can use the
inherit
directive to inherit the functionality of a class (.bbclass). BitBake only supports this directive when used within recipe and class files (i.e. .bb and .bbclass).
这并不意味着它不适用于 .inc
文件,而是不适用于配置文件。
关于yocto - bitbake 中的继承澄清,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74974925/