免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2113 | 回复: 0
打印 上一主题 下一主题

从源码阐述Bitbake Collections [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-10-16 22:04 |只看该作者 |倒序浏览
BBFILES := "${OEDIR}/openembedded/packages/*/*.bb ${LOCALDIR}/packages/*/*.bb"
BBFILE_COLLECTIONS = "upstream local"
BBFILE_PATTERN_upstream = "^${OEDIR}/openembedded/packages/"
BBFILE_PATTERN_local = "^${LOCALDIR}/packages/"
BBFILE_PRIORITY_upstream = "5"
BBFILE_PRIORITY_local = "10"
官方OE有一个分支,这算成third party,我们自己需要开发自己的oe package,所以我们也需要一个分支,但是又不希望更改OE的分支,这也就是bitbake collections的来历吧

BBFILE_COLLECTIONS定义有多少个分支,这里有upstream和local
BBFILE_PATTERN,为每个分支定义正则表达式,
BBFILE_PRIORITY为每个分支定义优先级

我们来看源码


def handleCollections( self, collections ):
        """Handle collections"""
        if collections:
            collection_list = collections.split()
            for c in collection_list:
                regex = bb.data.getVar("BBFILE_PATTERN_%s" % c, self.configuration.data, 1)
                if regex == None:
                    bb.msg.error(bb.msg.domain.Parsing, "BBFILE_PATTERN_%s not defined" % c)
                    continue
                priority = bb.data.getVar("BBFILE_PRIORITY_%s" % c, self.configuration.data, 1)
                if priority == None:
                    bb.msg.error(bb.msg.domain.Parsing, "BBFILE_PRIORITY_%s not defined" % c)
                    continue
                try:
                    cre = re.compile(regex)
                except re.error:
                    bb.msg.error(bb.msg.domain.Parsing, "BBFILE_PATTERN_%s \"%s\" is not a valid regular expression" % (c, regex))
                    continue
                try:
                    pri = int(priority)
                    self.status.bbfile_config_priorities.append((cre, pri))
                except ValueError:
                    bb.msg.error(bb.msg.domain.Parsing, "invalid value for BBFILE_PRIORITY_%s: \"%s\"" % (c, priority))

传进来的参数就是BBFILE_COLLECTIONS 变量值,函数的主要功能就是为每个分支计算出正则表达式匹配和优先级,填充bbfile_config_priorities,比如如上面说定义的BBFILE_COLLECTIONS,
bbfile_config_priorities[(re.compile("^${OEDIR}/openembedded/packages/"),5),(re.compile("^${LOCALDIR}/packages/"),10)]
这就是这个函数的task
我们继续看如何计算每个bbfile 的priorities
def calc_bbfile_priority(filename):
            for (regex, pri) in self.status.bbfile_config_priorities:
                if regex.match(filename):
                    return pri
            return 0
每个bb文件,如果能够和bbfile_config_priorities里的正则表达式匹配,那么就赋予这个bb文件伴随的priorities


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/32610/showart_401992.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP