2010-02-12 14:14:49 +00:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
"""
|
|
|
|
AbstractSyntaxTree classes for the Bitbake language
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Copyright (C) 2003, 2004 Chris Larson
|
|
|
|
# Copyright (C) 2003, 2004 Phil Blundell
|
|
|
|
# Copyright (C) 2009 Holger Hans Peter Freyther
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
2010-06-20 19:07:34 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from future_builtins import filter
|
2010-06-10 17:35:31 +00:00
|
|
|
import re
|
|
|
|
import string
|
|
|
|
import logging
|
|
|
|
import bb
|
2010-06-20 19:08:07 +00:00
|
|
|
import itertools
|
2010-06-10 17:35:31 +00:00
|
|
|
from bb import methodpool
|
|
|
|
from bb.parse import logger
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2009-05-18 17:24:07 +00:00
|
|
|
__parsed_methods__ = bb.methodpool.get_parsed_dict()
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
_bbversions_re = re.compile(r"\[(?P<from>[0-9]+)-(?P<to>[0-9]+)\]")
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class StatementGroup(list):
|
2009-05-18 17:24:07 +00:00
|
|
|
def eval(self, data):
|
2010-06-20 19:08:07 +00:00
|
|
|
for statement in self:
|
|
|
|
statement.eval(data)
|
2009-05-18 17:24:07 +00:00
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class AstNode(object):
|
2011-01-04 20:34:08 +00:00
|
|
|
def __init__(self, filename, lineno):
|
|
|
|
self.filename = filename
|
|
|
|
self.lineno = lineno
|
2009-05-19 07:37:07 +00:00
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class IncludeNode(AstNode):
|
2011-01-04 20:34:08 +00:00
|
|
|
def __init__(self, filename, lineno, what_file, force):
|
|
|
|
AstNode.__init__(self, filename, lineno)
|
2009-05-18 17:50:14 +00:00
|
|
|
self.what_file = what_file
|
2010-02-12 14:41:28 +00:00
|
|
|
self.force = force
|
2009-05-18 17:50:14 +00:00
|
|
|
|
|
|
|
def eval(self, data):
|
|
|
|
"""
|
|
|
|
Include the file and evaluate the statements
|
|
|
|
"""
|
|
|
|
s = bb.data.expand(self.what_file, data)
|
2011-01-04 20:34:08 +00:00
|
|
|
logger.debug(2, "CONF %s:%s: including %s", self.filename, self.lineno, s)
|
2009-05-18 17:50:14 +00:00
|
|
|
|
2009-05-19 10:10:37 +00:00
|
|
|
# TODO: Cache those includes... maybe not here though
|
2010-02-12 17:45:51 +00:00
|
|
|
if self.force:
|
2011-01-04 20:34:08 +00:00
|
|
|
bb.parse.ConfHandler.include(self.filename, s, data, "include required")
|
2010-02-12 14:41:28 +00:00
|
|
|
else:
|
2011-01-04 20:34:08 +00:00
|
|
|
bb.parse.ConfHandler.include(self.filename, s, data, False)
|
2009-05-18 17:50:14 +00:00
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class ExportNode(AstNode):
|
2011-01-04 20:34:08 +00:00
|
|
|
def __init__(self, filename, lineno, var):
|
|
|
|
AstNode.__init__(self, filename, lineno)
|
2009-05-18 17:50:14 +00:00
|
|
|
self.var = var
|
|
|
|
|
|
|
|
def eval(self, data):
|
|
|
|
bb.data.setVarFlag(self.var, "export", 1, data)
|
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class DataNode(AstNode):
|
2009-05-18 17:50:14 +00:00
|
|
|
"""
|
|
|
|
Various data related updates. For the sake of sanity
|
|
|
|
we have one class doing all this. This means that all
|
|
|
|
this need to be re-evaluated... we might be able to do
|
|
|
|
that faster with multiple classes.
|
|
|
|
"""
|
2011-01-04 20:34:08 +00:00
|
|
|
def __init__(self, filename, lineno, groupd):
|
|
|
|
AstNode.__init__(self, filename, lineno)
|
2009-05-18 17:50:14 +00:00
|
|
|
self.groupd = groupd
|
|
|
|
|
2009-05-18 18:03:50 +00:00
|
|
|
def getFunc(self, key, data):
|
|
|
|
if 'flag' in self.groupd and self.groupd['flag'] != None:
|
|
|
|
return bb.data.getVarFlag(key, self.groupd['flag'], data)
|
|
|
|
else:
|
|
|
|
return bb.data.getVar(key, data)
|
|
|
|
|
2009-05-18 17:50:14 +00:00
|
|
|
def eval(self, data):
|
|
|
|
groupd = self.groupd
|
|
|
|
key = groupd["var"]
|
|
|
|
if "exp" in groupd and groupd["exp"] != None:
|
|
|
|
bb.data.setVarFlag(key, "export", 1, data)
|
|
|
|
if "ques" in groupd and groupd["ques"] != None:
|
2009-05-18 18:03:50 +00:00
|
|
|
val = self.getFunc(key, data)
|
2009-05-18 17:50:14 +00:00
|
|
|
if val == None:
|
|
|
|
val = groupd["value"]
|
|
|
|
elif "colon" in groupd and groupd["colon"] != None:
|
|
|
|
e = data.createCopy()
|
|
|
|
bb.data.update_data(e)
|
|
|
|
val = bb.data.expand(groupd["value"], e)
|
|
|
|
elif "append" in groupd and groupd["append"] != None:
|
2009-05-18 18:03:50 +00:00
|
|
|
val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"])
|
2009-05-18 17:50:14 +00:00
|
|
|
elif "prepend" in groupd and groupd["prepend"] != None:
|
2009-05-18 18:03:50 +00:00
|
|
|
val = "%s %s" % (groupd["value"], (self.getFunc(key, data) or ""))
|
2009-05-18 17:50:14 +00:00
|
|
|
elif "postdot" in groupd and groupd["postdot"] != None:
|
2009-05-18 18:03:50 +00:00
|
|
|
val = "%s%s" % ((self.getFunc(key, data) or ""), groupd["value"])
|
2009-05-18 17:50:14 +00:00
|
|
|
elif "predot" in groupd and groupd["predot"] != None:
|
2009-05-18 18:03:50 +00:00
|
|
|
val = "%s%s" % (groupd["value"], (self.getFunc(key, data) or ""))
|
2009-05-18 17:50:14 +00:00
|
|
|
else:
|
|
|
|
val = groupd["value"]
|
2010-02-25 16:42:28 +00:00
|
|
|
|
2009-05-18 17:50:14 +00:00
|
|
|
if 'flag' in groupd and groupd['flag'] != None:
|
|
|
|
bb.data.setVarFlag(key, groupd['flag'], val, data)
|
2010-02-25 16:42:28 +00:00
|
|
|
elif groupd["lazyques"]:
|
|
|
|
bb.data.setVarFlag(key, "defaultval", val, data)
|
2009-05-18 17:50:14 +00:00
|
|
|
else:
|
|
|
|
bb.data.setVar(key, val, data)
|
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
class MethodNode(AstNode):
|
|
|
|
def __init__(self, filename, lineno, func_name, body):
|
|
|
|
AstNode.__init__(self, filename, lineno)
|
2009-05-19 07:51:29 +00:00
|
|
|
self.func_name = func_name
|
|
|
|
self.body = body
|
|
|
|
|
|
|
|
def eval(self, data):
|
|
|
|
if self.func_name == "__anonymous":
|
2011-01-04 20:34:08 +00:00
|
|
|
funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(string.maketrans('/.+-', '____'))))
|
2010-03-31 16:14:18 +00:00
|
|
|
if not funcname in bb.methodpool._parsed_fns:
|
|
|
|
text = "def %s(d):\n" % (funcname) + '\n'.join(self.body)
|
2011-01-04 20:34:08 +00:00
|
|
|
bb.methodpool.insert_method(funcname, text, self.filename)
|
2009-05-19 07:51:29 +00:00
|
|
|
anonfuncs = bb.data.getVar('__BBANONFUNCS', data) or []
|
2010-03-31 16:14:18 +00:00
|
|
|
anonfuncs.append(funcname)
|
2009-05-19 07:51:29 +00:00
|
|
|
bb.data.setVar('__BBANONFUNCS', anonfuncs, data)
|
|
|
|
else:
|
|
|
|
bb.data.setVarFlag(self.func_name, "func", 1, data)
|
|
|
|
bb.data.setVar(self.func_name, '\n'.join(self.body), data)
|
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class PythonMethodNode(AstNode):
|
2011-01-04 20:34:08 +00:00
|
|
|
def __init__(self, filename, lineno, function, define, body):
|
|
|
|
AstNode.__init__(self, filename, lineno)
|
|
|
|
self.function = function
|
|
|
|
self.define = define
|
2009-05-19 07:51:29 +00:00
|
|
|
self.body = body
|
|
|
|
|
|
|
|
def eval(self, data):
|
|
|
|
# Note we will add root to parsedmethods after having parse
|
|
|
|
# 'this' file. This means we will not parse methods from
|
|
|
|
# bb classes twice
|
2010-09-03 15:04:26 +00:00
|
|
|
text = '\n'.join(self.body)
|
2011-01-04 20:34:08 +00:00
|
|
|
if not bb.methodpool.parsed_module(self.define):
|
|
|
|
bb.methodpool.insert_method(self.define, text, self.filename)
|
|
|
|
bb.data.setVarFlag(self.function, "func", 1, data)
|
|
|
|
bb.data.setVarFlag(self.function, "python", 1, data)
|
|
|
|
bb.data.setVar(self.function, text, data)
|
2009-05-19 08:02:55 +00:00
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class MethodFlagsNode(AstNode):
|
2011-01-04 20:34:08 +00:00
|
|
|
def __init__(self, filename, lineno, key, m):
|
|
|
|
AstNode.__init__(self, filename, lineno)
|
2009-05-19 08:02:55 +00:00
|
|
|
self.key = key
|
|
|
|
self.m = m
|
|
|
|
|
|
|
|
def eval(self, data):
|
|
|
|
if bb.data.getVar(self.key, data):
|
|
|
|
# clean up old version of this piece of metadata, as its
|
|
|
|
# flags could cause problems
|
|
|
|
bb.data.setVarFlag(self.key, 'python', None, data)
|
|
|
|
bb.data.setVarFlag(self.key, 'fakeroot', None, data)
|
|
|
|
if self.m.group("py") is not None:
|
|
|
|
bb.data.setVarFlag(self.key, "python", "1", data)
|
|
|
|
else:
|
|
|
|
bb.data.delVarFlag(self.key, "python", data)
|
|
|
|
if self.m.group("fr") is not None:
|
|
|
|
bb.data.setVarFlag(self.key, "fakeroot", "1", data)
|
|
|
|
else:
|
|
|
|
bb.data.delVarFlag(self.key, "fakeroot", data)
|
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class ExportFuncsNode(AstNode):
|
2011-01-04 20:34:08 +00:00
|
|
|
def __init__(self, filename, lineno, fns, classes):
|
|
|
|
AstNode.__init__(self, filename, lineno)
|
2011-01-04 20:07:27 +00:00
|
|
|
self.n = fns.split()
|
2009-05-19 08:10:26 +00:00
|
|
|
self.classes = classes
|
|
|
|
|
|
|
|
def eval(self, data):
|
|
|
|
for f in self.n:
|
|
|
|
allvars = []
|
|
|
|
allvars.append(f)
|
|
|
|
allvars.append(self.classes[-1] + "_" + f)
|
|
|
|
|
|
|
|
vars = [[ allvars[0], allvars[1] ]]
|
|
|
|
if len(self.classes) > 1 and self.classes[-2] is not None:
|
|
|
|
allvars.append(self.classes[-2] + "_" + f)
|
|
|
|
vars = []
|
|
|
|
vars.append([allvars[2], allvars[1]])
|
|
|
|
vars.append([allvars[0], allvars[2]])
|
|
|
|
|
|
|
|
for (var, calledvar) in vars:
|
|
|
|
if bb.data.getVar(var, data) and not bb.data.getVarFlag(var, 'export_func', data):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if bb.data.getVar(var, data):
|
|
|
|
bb.data.setVarFlag(var, 'python', None, data)
|
|
|
|
bb.data.setVarFlag(var, 'func', None, data)
|
|
|
|
|
|
|
|
for flag in [ "func", "python" ]:
|
|
|
|
if bb.data.getVarFlag(calledvar, flag, data):
|
|
|
|
bb.data.setVarFlag(var, flag, bb.data.getVarFlag(calledvar, flag, data), data)
|
|
|
|
for flag in [ "dirs" ]:
|
|
|
|
if bb.data.getVarFlag(var, flag, data):
|
|
|
|
bb.data.setVarFlag(calledvar, flag, bb.data.getVarFlag(var, flag, data), data)
|
|
|
|
|
|
|
|
if bb.data.getVarFlag(calledvar, "python", data):
|
|
|
|
bb.data.setVar(var, "\tbb.build.exec_func('" + calledvar + "', d)\n", data)
|
|
|
|
else:
|
|
|
|
bb.data.setVar(var, "\t" + calledvar + "\n", data)
|
|
|
|
bb.data.setVarFlag(var, 'export_func', '1', data)
|
2009-05-19 08:52:18 +00:00
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class AddTaskNode(AstNode):
|
2011-01-04 20:34:08 +00:00
|
|
|
def __init__(self, filename, lineno, func, before, after):
|
|
|
|
AstNode.__init__(self, filename, lineno)
|
2009-05-19 08:52:18 +00:00
|
|
|
self.func = func
|
|
|
|
self.before = before
|
|
|
|
self.after = after
|
|
|
|
|
|
|
|
def eval(self, data):
|
|
|
|
var = self.func
|
|
|
|
if self.func[:3] != "do_":
|
|
|
|
var = "do_" + self.func
|
|
|
|
|
|
|
|
bb.data.setVarFlag(var, "task", 1, data)
|
|
|
|
bbtasks = bb.data.getVar('__BBTASKS', data) or []
|
|
|
|
if not var in bbtasks:
|
|
|
|
bbtasks.append(var)
|
|
|
|
bb.data.setVar('__BBTASKS', bbtasks, data)
|
|
|
|
|
|
|
|
existing = bb.data.getVarFlag(var, "deps", data) or []
|
|
|
|
if self.after is not None:
|
|
|
|
# set up deps for function
|
|
|
|
for entry in self.after.split():
|
|
|
|
if entry not in existing:
|
|
|
|
existing.append(entry)
|
|
|
|
bb.data.setVarFlag(var, "deps", existing, data)
|
|
|
|
if self.before is not None:
|
|
|
|
# set up things that depend on this func
|
|
|
|
for entry in self.before.split():
|
|
|
|
existing = bb.data.getVarFlag(entry, "deps", data) or []
|
|
|
|
if var not in existing:
|
|
|
|
bb.data.setVarFlag(entry, "deps", [var] + existing, data)
|
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class BBHandlerNode(AstNode):
|
2011-01-04 20:34:08 +00:00
|
|
|
def __init__(self, filename, lineno, fns):
|
|
|
|
AstNode.__init__(self, filename, lineno)
|
2011-01-04 20:07:27 +00:00
|
|
|
self.hs = fns.split()
|
2009-05-19 08:52:18 +00:00
|
|
|
|
|
|
|
def eval(self, data):
|
|
|
|
bbhands = bb.data.getVar('__BBHANDLERS', data) or []
|
|
|
|
for h in self.hs:
|
|
|
|
bbhands.append(h)
|
|
|
|
bb.data.setVarFlag(h, "handler", 1, data)
|
|
|
|
bb.data.setVar('__BBHANDLERS', bbhands, data)
|
2009-05-19 08:57:00 +00:00
|
|
|
|
2009-07-21 19:00:29 +00:00
|
|
|
class InheritNode(AstNode):
|
2011-01-04 20:34:08 +00:00
|
|
|
def __init__(self, filename, lineno, classes):
|
|
|
|
AstNode.__init__(self, filename, lineno)
|
2011-01-04 20:06:49 +00:00
|
|
|
self.classes = classes
|
2009-05-19 08:57:00 +00:00
|
|
|
|
|
|
|
def eval(self, data):
|
2011-01-04 20:06:49 +00:00
|
|
|
bb.parse.BBHandler.inherit(self.classes, data)
|
2010-03-24 23:56:12 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
def handleInclude(statements, filename, lineno, m, force):
|
|
|
|
statements.append(IncludeNode(filename, lineno, m.group(1), force))
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
def handleExport(statements, filename, lineno, m):
|
|
|
|
statements.append(ExportNode(filename, lineno, m.group(1)))
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
def handleData(statements, filename, lineno, groupd):
|
|
|
|
statements.append(DataNode(filename, lineno, groupd))
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
def handleMethod(statements, filename, lineno, func_name, body):
|
|
|
|
statements.append(MethodNode(filename, lineno, func_name, body))
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
def handlePythonMethod(statements, filename, lineno, funcname, root, body):
|
|
|
|
statements.append(PythonMethodNode(filename, lineno, funcname, root, body))
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
def handleMethodFlags(statements, filename, lineno, key, m):
|
|
|
|
statements.append(MethodFlagsNode(filename, lineno, key, m))
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
def handleExportFuncs(statements, filename, lineno, m, classes):
|
|
|
|
statements.append(ExportFuncsNode(filename, lineno, m.group(1), classes))
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
def handleAddTask(statements, filename, lineno, m):
|
2010-02-12 14:14:49 +00:00
|
|
|
func = m.group("func")
|
|
|
|
before = m.group("before")
|
|
|
|
after = m.group("after")
|
|
|
|
if func is None:
|
|
|
|
return
|
2009-05-19 08:52:18 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
statements.append(AddTaskNode(filename, lineno, func, before, after))
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
def handleBBHandlers(statements, filename, lineno, m):
|
|
|
|
statements.append(BBHandlerNode(filename, lineno, m.group(1)))
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2011-01-04 20:34:08 +00:00
|
|
|
def handleInherit(statements, filename, lineno, m):
|
2011-01-04 20:06:49 +00:00
|
|
|
classes = m.group(1)
|
2011-01-04 20:34:08 +00:00
|
|
|
statements.append(InheritNode(filename, lineno, classes.split()))
|
2010-02-12 14:14:49 +00:00
|
|
|
|
2010-08-31 13:49:43 +00:00
|
|
|
def finalize(fn, d, variant = None):
|
2009-05-18 17:56:36 +00:00
|
|
|
bb.data.expandKeys(d)
|
|
|
|
bb.data.update_data(d)
|
2010-03-31 16:14:18 +00:00
|
|
|
code = []
|
|
|
|
for funcname in bb.data.getVar("__BBANONFUNCS", d) or []:
|
|
|
|
code.append("%s(d)" % funcname)
|
|
|
|
bb.utils.simple_exec("\n".join(code), {"d": d})
|
2009-05-18 17:56:36 +00:00
|
|
|
bb.data.update_data(d)
|
|
|
|
|
2010-03-31 03:06:07 +00:00
|
|
|
all_handlers = {}
|
2009-05-18 17:56:36 +00:00
|
|
|
for var in bb.data.getVar('__BBHANDLERS', d) or []:
|
|
|
|
# try to add the handler
|
2010-04-12 00:03:55 +00:00
|
|
|
handler = bb.data.getVar(var, d)
|
2009-05-18 17:56:36 +00:00
|
|
|
bb.event.register(var, handler)
|
|
|
|
|
|
|
|
tasklist = bb.data.getVar('__BBTASKS', d) or []
|
|
|
|
bb.build.add_tasks(tasklist, d)
|
|
|
|
|
2010-08-31 13:49:43 +00:00
|
|
|
bb.parse.siggen.finalise(fn, d, variant)
|
2010-08-03 13:30:20 +00:00
|
|
|
|
2009-05-18 17:56:36 +00:00
|
|
|
bb.event.fire(bb.event.RecipeParsed(fn), d)
|
|
|
|
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
def _create_variants(datastores, names, function):
|
|
|
|
def create_variant(name, orig_d, arg = None):
|
|
|
|
new_d = bb.data.createCopy(orig_d)
|
|
|
|
function(arg or name, new_d)
|
|
|
|
datastores[name] = new_d
|
|
|
|
|
|
|
|
for variant, variant_d in datastores.items():
|
|
|
|
for name in names:
|
|
|
|
if not variant:
|
|
|
|
# Based on main recipe
|
|
|
|
create_variant(name, variant_d)
|
|
|
|
else:
|
|
|
|
create_variant("%s-%s" % (variant, name), variant_d, name)
|
|
|
|
|
|
|
|
def _expand_versions(versions):
|
|
|
|
def expand_one(version, start, end):
|
|
|
|
for i in xrange(start, end + 1):
|
|
|
|
ver = _bbversions_re.sub(str(i), version, 1)
|
|
|
|
yield ver
|
|
|
|
|
|
|
|
versions = iter(versions)
|
|
|
|
while True:
|
|
|
|
try:
|
2010-06-20 19:08:07 +00:00
|
|
|
version = next(versions)
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
except StopIteration:
|
|
|
|
break
|
|
|
|
|
|
|
|
range_ver = _bbversions_re.search(version)
|
|
|
|
if not range_ver:
|
|
|
|
yield version
|
|
|
|
else:
|
|
|
|
newversions = expand_one(version, int(range_ver.group("from")),
|
|
|
|
int(range_ver.group("to")))
|
2010-06-20 19:08:07 +00:00
|
|
|
versions = itertools.chain(newversions, versions)
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
|
|
|
|
def multi_finalize(fn, d):
|
2010-07-16 14:10:22 +00:00
|
|
|
appends = (d.getVar("__BBAPPEND", True) or "").split()
|
|
|
|
for append in appends:
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.debug(2, "Appending .bbappend file %s to %s", append, fn)
|
2010-07-16 14:10:22 +00:00
|
|
|
bb.parse.BBHandler.handle(append, d, True)
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
|
2011-04-10 17:50:16 +00:00
|
|
|
onlyfinalise = d.getVar("__ONLYFINALISE", False)
|
|
|
|
|
2010-07-16 14:10:22 +00:00
|
|
|
safe_d = d
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
d = bb.data.createCopy(safe_d)
|
|
|
|
try:
|
2011-04-10 17:50:16 +00:00
|
|
|
if not onlyfinalise or "default" in onlyfinalise:
|
|
|
|
finalize(fn, d)
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
except bb.parse.SkipPackage:
|
|
|
|
bb.data.setVar("__SKIPPED", True, d)
|
|
|
|
datastores = {"": safe_d}
|
|
|
|
|
|
|
|
versions = (d.getVar("BBVERSIONS", True) or "").split()
|
|
|
|
if versions:
|
|
|
|
pv = orig_pv = d.getVar("PV", True)
|
|
|
|
baseversions = {}
|
|
|
|
|
|
|
|
def verfunc(ver, d, pv_d = None):
|
|
|
|
if pv_d is None:
|
|
|
|
pv_d = d
|
|
|
|
|
|
|
|
overrides = d.getVar("OVERRIDES", True).split(":")
|
|
|
|
pv_d.setVar("PV", ver)
|
|
|
|
overrides.append(ver)
|
|
|
|
bpv = baseversions.get(ver) or orig_pv
|
|
|
|
pv_d.setVar("BPV", bpv)
|
|
|
|
overrides.append(bpv)
|
|
|
|
d.setVar("OVERRIDES", ":".join(overrides))
|
|
|
|
|
|
|
|
versions = list(_expand_versions(versions))
|
|
|
|
for pos, version in enumerate(list(versions)):
|
|
|
|
try:
|
|
|
|
pv, bpv = version.split(":", 2)
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
versions[pos] = pv
|
|
|
|
baseversions[pv] = bpv
|
|
|
|
|
|
|
|
if pv in versions and not baseversions.get(pv):
|
|
|
|
versions.remove(pv)
|
|
|
|
else:
|
|
|
|
pv = versions.pop()
|
|
|
|
|
|
|
|
# This is necessary because our existing main datastore
|
|
|
|
# has already been finalized with the old PV, we need one
|
|
|
|
# that's been finalized with the new PV.
|
|
|
|
d = bb.data.createCopy(safe_d)
|
|
|
|
verfunc(pv, d, safe_d)
|
|
|
|
try:
|
2010-04-08 23:01:14 +00:00
|
|
|
finalize(fn, d)
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
except bb.parse.SkipPackage:
|
|
|
|
bb.data.setVar("__SKIPPED", True, d)
|
|
|
|
|
|
|
|
_create_variants(datastores, versions, verfunc)
|
|
|
|
|
|
|
|
extended = d.getVar("BBCLASSEXTEND", True) or ""
|
|
|
|
if extended:
|
|
|
|
pn = d.getVar("PN", True)
|
|
|
|
def extendfunc(name, d):
|
|
|
|
d.setVar("PN", "%s-%s" % (pn, name))
|
|
|
|
bb.parse.BBHandler.inherit([name], d)
|
|
|
|
|
|
|
|
safe_d.setVar("BBCLASSEXTEND", extended)
|
|
|
|
_create_variants(datastores, extended.split(), extendfunc)
|
|
|
|
|
2010-06-20 19:08:07 +00:00
|
|
|
for variant, variant_d in datastores.iteritems():
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
if variant:
|
|
|
|
try:
|
2011-04-10 17:50:16 +00:00
|
|
|
if not onlyfinalise or variant in onlyfinalise:
|
|
|
|
finalize(fn, variant_d, variant)
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
except bb.parse.SkipPackage:
|
|
|
|
bb.data.setVar("__SKIPPED", True, variant_d)
|
|
|
|
|
|
|
|
if len(datastores) > 1:
|
2010-06-20 19:08:07 +00:00
|
|
|
variants = filter(None, datastores.iterkeys())
|
Implement BBVERSIONS
This implements a feature similar to BBCLASSEXTEND, but for generating
multiple versions of a given recipe. For example: BBVERSIONS = "1.0 2.0 git".
In addition to the above, one can utilize [a-b] style patterns, and can have a
:<basever> postfix, which allows you to essentially name the range of
versions. Both the current version and the basever end up in OVERRIDES, and
the basever gets placed into the BPV variable. The default BPV, if none is
specified, is the original PV of the recipe, before bbversions processing.
In this way, you can do things like:
BBVERSIONS = "1.0.[0-6]:1.0.0+
1.0.[7-9]:1.0.7+"
SRC_URI_append_1.0.7+ = "file://some_extra_patch.patch;patch=1"
Or you can create a recipe per range, and name the recipe file as such: nano_1.0.7+.bb.
(Bitbake rev: 4ee9a56e16f1eb3c1649eaa3127b09ab0e93d1ec)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-03-20 00:22:19 +00:00
|
|
|
safe_d.setVar("__VARIANTS", " ".join(variants))
|
|
|
|
|
|
|
|
datastores[""] = d
|
|
|
|
return datastores
|