diff --git a/bitbake/doc/manual/usermanual.xml b/bitbake/doc/manual/usermanual.xml
index c3403449fe..450ac77d7a 100644
--- a/bitbake/doc/manual/usermanual.xml
+++ b/bitbake/doc/manual/usermanual.xml
@@ -91,7 +91,13 @@ share common metadata between many packages.
Setting a default value (?=)
A ?= "aval"
- If A is set before the above is called, it will retain it's previous value. If A is unset prior to the above call, A will be set to aval.
+ If A is set before the above is called, it will retain it's previous value. If A is unset prior to the above call, A will be set to aval. Note that this assignment is immediate, so if there are multiple ?= assignments to a single variable, the first of those will be used.
+
+
+ Setting a default value (??=)
+ A ??= "somevalue"
+ A ??= "someothervalue"
+ If A is set before the above, it will retain that value. If A is unset prior to the above, A will be set to someothervalue. This is a lazy version of ??=, in that the assignment does not occur until the end of the parsing process, so that the last, rather than the first, ??= assignment to a given variable will be used.
Immediate variable expansion (:=)
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 []
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
index a1eaf317ac..f4f85de245 100644
--- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py
@@ -28,7 +28,7 @@ import re, bb.data, os, sys
from bb.parse import ParseError, resolve_file, ast
#__config_regexp__ = re.compile( r"(?Pexport\s*)?(?P[a-zA-Z0-9\-_+.${}]+)\s*(?P:)?(?P\?)?=\s*(?P['\"]?)(?P.*)(?P=apo)$")
-__config_regexp__ = re.compile( r"(?Pexport\s*)?(?P[a-zA-Z0-9\-_+.${}/]+)(\[(?P[a-zA-Z0-9\-_+.]+)\])?\s*((?P:=)|(?P\?=)|(?P\+=)|(?P=\+)|(?P=\.)|(?P\.=)|=)\s*(?P['\"]?)(?P.*)(?P=apo)$")
+__config_regexp__ = re.compile( r"(?Pexport\s*)?(?P[a-zA-Z0-9\-_+.${}/]+)(\[(?P[a-zA-Z0-9\-_+.]+)\])?\s*((?P:=)|(?P\?\?=)|(?P\?=)|(?P\+=)|(?P=\+)|(?P=\.)|(?P\.=)|=)\s*(?P['\"]?)(?P.*)(?P=apo)$")
__include_regexp__ = re.compile( r"include\s+(.+)" )
__require_regexp__ = re.compile( r"require\s+(.+)" )
__export_regexp__ = re.compile( r"export\s+(.+)" )