From 57044b9a6240235a403eac4067e2e2113e03b6eb Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Thu, 25 Feb 2010 09:42:28 -0700 Subject: Implement ??= operator ??= is a lazy, conditional assignment. Whereas a ?= immediately assigns to the variable if the variable has not yet been set, ??= does not apply the default assignment until the end of the parse. As a result, the final ??= for a given variable is used, as opposed to the first as in ?=. Note that the initial implementation relies upon finalise() to apply the defaults, so a "bitbake -e" without specifying a recipe will not show the defaults as set by ??=. Moving application of the default into getVar adds too large a performance hit. We may want to revisit this later. (Bitbake rev: 74f50fbca194c9c72bd2a540f4b9de458cb08e2d) Signed-off-by: Chris Larson Signed-off-by: Richard Purdie --- bitbake/lib/bb/parse/ast.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'bitbake/lib/bb/parse/ast.py') diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index e0b795fa68..70a69b8d14 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py @@ -99,9 +99,15 @@ class DataNode(AstNode): val = "%s%s" % (groupd["value"], (self.getFunc(key, data) or "")) else: val = groupd["value"] + if 'flag' in groupd and groupd['flag'] != None: bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) bb.data.setVarFlag(key, groupd['flag'], val, data) + elif groupd["lazyques"]: + assigned = bb.data.getVar("__lazy_assigned", data) or [] + assigned.append(key) + bb.data.setVar("__lazy_assigned", assigned, data) + bb.data.setVarFlag(key, "defaultval", val, data) else: bb.data.setVar(key, val, data) @@ -286,6 +292,11 @@ def handleInherit(statements, m): statements.append(InheritNode(m.group(1))) def finalise(fn, d): + for lazykey in bb.data.getVar("__lazy_assigned", d) or (): + if bb.data.getVar(lazykey, d) is None: + val = bb.data.getVarFlag(lazykey, "defaultval", d) + bb.data.setVar(lazykey, val, d) + bb.data.expandKeys(d) bb.data.update_data(d) anonqueue = bb.data.getVar("__anonqueue", d, 1) or [] -- cgit v1.2.3-54-g00ecf