Yocto 配方中的函数未被重写
我想重写配方(bb)中继承自bbclass的函数,但它不起作用——将执行bbclass(超类)中的函数,而不是新函数 下面是一个最小的(非)工作示例 类别:Yocto 配方中的函数未被重写,yocto,bitbake,openembedded,Yocto,Bitbake,Openembedded,我想重写配方(bb)中继承自bbclass的函数,但它不起作用——将执行bbclass(超类)中的函数,而不是新函数 下面是一个最小的(非)工作示例 类别: # myclass.bbclass do_compile() { echo MyClass } 配方: # myrecipe.bb do_compile() { echo MyRecipe } inherit myclass # myrecipe.bb inherit myclass do_compile()
# myclass.bbclass
do_compile() {
echo MyClass
}
配方:
# myrecipe.bb
do_compile() {
echo MyRecipe
}
inherit myclass
# myrecipe.bb
inherit myclass
do_compile() {
echo MyRecipe
}
编译配方后,日志文件如下所示:
$ cat temp/log.do_compile
DEBUG: Executing shell function do_compile
MyClass
DEBUG: Shell function do_compile finished
$ cat temp/log.do_compile
DEBUG: Executing shell function do_compile
MyRecipe
DEBUG: Shell function do_compile finished
为什么重写
编译不起作用?配方文件中继承的位置很重要。如果您将它放在文件的开头(在(子类)配方中定义函数do_compile
之前),它会工作
配方:
# myrecipe.bb
do_compile() {
echo MyRecipe
}
inherit myclass
# myrecipe.bb
inherit myclass
do_compile() {
echo MyRecipe
}
编译配方后,日志文件如下所示:
$ cat temp/log.do_compile
DEBUG: Executing shell function do_compile
MyClass
DEBUG: Shell function do_compile finished
$ cat temp/log.do_compile
DEBUG: Executing shell function do_compile
MyRecipe
DEBUG: Shell function do_compile finished