[英]Inheritance clarification in bitbake
In bitbake, are inheritances transferable between include files when they are added with require keyword?在 bitbake 中,当包含文件使用 require 关键字添加时,继承是否可以在包含文件之间转移? Or do we need to reuse inherit keyword over and over again in each of the include files?
或者我们是否需要在每个包含文件中一遍又一遍地重复使用 inherit 关键字? I'm using bitbake to built images with Yocto.
我正在使用 bitbake 与 Yocto 构建图像。
exampleA.inc file exampleA.inc 文件
inherit exampleC
exampleB.inc file exampleB.inc 文件
require exampleA.inc
In that case, if I want exampleB.inc to be inherited from exampleC as well, do I need to specify it in this file?那样的话,如果我想让exampleB.inc也继承自exampleC,我需要在这个文件中指定吗?
Assume that the exampleC is a bbclass file.假设 exampleC 是一个 bbclass 文件。
TLDR: one inherit statement is enough. TLDR:一个 inherit 语句就足够了。
require
and include
just insert the content of the specified file at the current position in the recipe. require
和include
只是在 recipe 的当前 position 处插入指定文件的内容。 This results in the same outcome, as if you had written the whole content of your .inc
file into the recipe.这会产生相同的结果,就像您已将
.inc
文件的全部内容写入配方一样。 Multiple layers of include
/ require
should not change that.多层
include
/ require
不应该改变这一点。 This means, that not the .inc
file inherits from exanpleC
, but rather the recipe, which requires said .inc
file.这意味着,不是
.inc
文件继承自exanpleC
,而是需要所述.inc
文件的配方。
I also ran some quick tests to confirm the theory, and it all seems to work.我还运行了一些快速测试来证实这个理论,这一切似乎都有效。
Do not be deterred by the BitBake documentation stating:不要被 BitBake 文档中的声明吓倒:
[...] you can use the
inherit
directive to inherit the functionality of a class (.bbclass).[...] 您可以使用
inherit
指令继承 class (.bbclass) 的功能。 BitBake only supports this directive when used within recipe and class files (ie .bb and.bbclass).BitBake 仅在配方和 class 文件(即 .bb 和 .bbclass)中使用时支持此指令。
This does not mean, that it does not work in .inc
files, but rather that it will not work for configuration files.这并不意味着它不适用于
.inc
文件,而是不适用于配置文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.