简体   繁体   English

仅当计算机名称包含特定的子字符串时,才如何在yocto中添加位烘烤层?

[英]How to add in yocto a bitbake layer only if machine name contains a specific substring?

I have a custom meta-layer with a bitbake recipe that add some files to the final image running do_install(). 我有一个带有bitbake食谱的自定义元层,该食谱将一些文件添加到运行do_install()的最终映像中。

I want to execute this do_install (or the entire recipe) only if machine name contain a specific substring. 仅当计算机名称包含特定的子字符串时,我才想执行此do_install(或整个配方)。

For example if I have 3 possibile machine names: "machine1", "machiABCne2", "machABine3", and the substring that I evaluating is "ABC", only if MACHINE="machiABCne2" I want include and run my custom recipe. 例如,如果我有3个可能的机器名称:“ machine1”,“ machiABCne2”,“ machABine3”,并且要评估的子字符串是“ ABC”,则仅当我要包含MACHINE =“ machiABCne2”并运行我的自定义配方时。

How can I do that in a general way, without creating multiple files and directories with all possibile machine names, but searching for the substring inside the machine name? 如何以一种通用方式做到这一点,而不用所有可能的机器名称创建多个文件和目录,而是在机器名称中搜索子字符串?

It's ok also running the content of do_install based on machine if not possibile in other ways. 如果没有其他可能的方式,也可以基于计算机运行do_install的内容。

Try to add below macro in your recipe(example.bb) file. 尝试在您的食谱(example.bb)文件中添加以下宏。

COMPATIBLE_MACHINE  =  "machiABCne2"

if the machine name is "machiABCne2" then only example.bb file will compile and add to your rootfs otherwise bitbake throws error. 如果计算机名称为"machiABCne2"则仅example.bb文件将编译并添加到您的rootfs中,否则bitbake抛出错误。 OR you can also add this recipe for more machine using below function in your example.bb 或者您也可以在example.bb使用以下功能为更多机器添加此配方

python () {
        machine = d.getVar("MACHINE", True)

        import re
        if re.match('imx6qpdlsolox',machine):
                subplatform = 'mx6qsabresd'
        elif re.match('imx6ul7d',machine):
                subplatform = 'mx6ulevk'
        elif re.match('imx6ull',machine):
                subplatform = 'mx6ullevk'
        elif re.match('imx',machine):
                subplatform = machine[1:]
        else:
                bb.fatal("optee-os-imx doesn't recognize this MACHINE")
        d.setVar("OPTEE_PLATFORM", subplatform)
}

hope the function will help you. 希望该功能对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM