如何扩展 BitBake class
How to extend BitBake class
我正在使用 Yocto 构建图像,需要在上游树中修补 BitBake class。我不想修改上游源,而是希望将修改添加到本地层。
对于 BitBake 配方,我会使用 .bbappend
文件。 class应该用什么?
在元层中创建 classes
文件夹并创建一个新的 class,例如myclass.bbclass
。使用 inherit original-bitbake-CLASS
继承原始 class 并添加您需要的任何功能。
那就用新的bbclass代替原来的bb
通常对于 .bbclass 文件,缺少与附加食谱 (.bbappends) 类似的方法。 @Oleksandr-Kravchuk 提出的解决方案很好,但有一些限制。当您必须修改某些功能或进行更复杂的更改时,我更愿意将此 class 文件复制到我的元数据层并在那里进行改编。最后 bitbake 基于层中的配置(conf/layer.conf 文件)- BBFILE_PRIORITY 将决定将此 class 文件来自更高优先级的层控制杆 - 不接触食谱。
@lukaszgard 方法有效,但有一个小问题。 BBFILE_PRIORITY 不提供对 bbclass 和 conf 文件的覆盖功能,它仅适用于食谱 (.bb)。这是基于 Yocto 手册的一部分,Prioritizing Your Layer 其中说
Note: It is possible for a recipe with a lower version number PV in a layer that has a higher priority to take precedence.
Also, the layer priority does not currently affect the precedence order of .conf or .bbclass files. Future versions of BitBake might address this.
我发现一个可行的方法是创建一个 bblayer,创建并应用所需 bbclass 的更改,然后在 /build/conf/bblayers.conf 中,放置创建的 bblayer在您试图覆盖的层之上。
这是基于 Yocto manual 的另一部分
Note: During a build, the OpenEmbedded build system looks in the layers from the top of the list down to the bottom in that order.
一个例子:
BBLAYERS ?= " \
${TOPDIR}/../layers/<layer with new bbclass> \
${TOPDIR}/../layers/<layer with old bbclass> \
"
我正在使用 Yocto 构建图像,需要在上游树中修补 BitBake class。我不想修改上游源,而是希望将修改添加到本地层。
对于 BitBake 配方,我会使用 .bbappend
文件。 class应该用什么?
在元层中创建 classes
文件夹并创建一个新的 class,例如myclass.bbclass
。使用 inherit original-bitbake-CLASS
继承原始 class 并添加您需要的任何功能。
那就用新的bbclass代替原来的bb
通常对于 .bbclass 文件,缺少与附加食谱 (.bbappends) 类似的方法。 @Oleksandr-Kravchuk 提出的解决方案很好,但有一些限制。当您必须修改某些功能或进行更复杂的更改时,我更愿意将此 class 文件复制到我的元数据层并在那里进行改编。最后 bitbake 基于层中的配置(conf/layer.conf 文件)- BBFILE_PRIORITY 将决定将此 class 文件来自更高优先级的层控制杆 - 不接触食谱。
@lukaszgard 方法有效,但有一个小问题。 BBFILE_PRIORITY 不提供对 bbclass 和 conf 文件的覆盖功能,它仅适用于食谱 (.bb)。这是基于 Yocto 手册的一部分,Prioritizing Your Layer 其中说
Note: It is possible for a recipe with a lower version number PV in a layer that has a higher priority to take precedence. Also, the layer priority does not currently affect the precedence order of .conf or .bbclass files. Future versions of BitBake might address this.
我发现一个可行的方法是创建一个 bblayer,创建并应用所需 bbclass 的更改,然后在 /build/conf/bblayers.conf 中,放置创建的 bblayer在您试图覆盖的层之上。
这是基于 Yocto manual 的另一部分
Note: During a build, the OpenEmbedded build system looks in the layers from the top of the list down to the bottom in that order.
一个例子:
BBLAYERS ?= " \
${TOPDIR}/../layers/<layer with new bbclass> \
${TOPDIR}/../layers/<layer with old bbclass> \
"