Yocto do_patch 高级用法

新建machine 内部字符串,传递参数,bb文件选择控制,继承oe-core do patch机制,完成patch功能。pm 模块为例

1) machin conf 设置控制字符串。

2) bb 文件中进行选择控制,FILESEXTRAPATHS_prepend  @bb.utils.contains

详述举例如下:

machine conf中的设置:PM_XXX_XXX 都是新建字符串

PM_PATCH_FILEPATH = "${THISDIR}/files"
PM_MACHINE_PATCH = " \
                      file://0001-update-pm-build-config-for-extra-toolchain.patch \
                   "

pm_0.1.bb 文件为例:

PM_PATCH_FILEPATH ?= ""
FILESEXTRAPATHS_prepend := "${PM_PATCH_FILEPATH}:"

PM_MACHINE_PATCH ?= ""
SRC_URI += " \
             ${@bb.utils.contains('GCCVERSION', '8.3.0', '${PM_MACHINE_PATCH}', '', d)} \
           "

注意事项:如果使用bb.utils.contains 该函数的三个参数是变量字符串是要加$ 符号的,如果不是变量是普通字符串就可以不用$

${@bb.utils.contains('GCCVERSION', '8.3.0', '${PM_MACHINE_PATCH}', '', d)} \

仅仅使用‘PM_MACHINE_PATCH’ 会报错,因为PM_MACHINE_PATCH 是变量名。

File: '/home2/guobin.xue/yocto-001/bitbake/lib/bb/fetch2/__init__.py', lineno: 368, function: decodeurl
     0364:    """
     0365:
     0366:    m = re.compile('(?P[^:]*)://((?P[^/;]+)@)?(?P[^;]+)(;(?P.*))?').match(url)
     0367:    if not m:
 *** 0368:        raise MalformedUrl(url)
     0369:
     0370:    type = m.group('type')
     0371:    location = m.group('location')
     0372:    if not location:
Exception: bb.fetch2.MalformedUrl: The URL: 'PM_MACHINE_PATCH' is invalid and cannot be interpreted

ERROR: Failed to parse recipe: /home2/guobin.xue/yocto-001/build-unisoc-initgc/conf/../../layers/meta-unisoc/recipes-core/pm/pm_0.0.1.bb  

你可能感兴趣的:(Yocto,bitbake)