summaryrefslogtreecommitdiffstats
path: root/lib/bb/data_smart.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-22 10:30:57 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-12 22:50:27 +0100
commitae87f5b8bf16191b3201cfb445062938eab992a0 (patch)
tree4850625bfc2d069cc62fc9719af644b330625df4 /lib/bb/data_smart.py
parent2a0b73110bede91777ada54d1d89b45fb6034b6c (diff)
downloadopenembedded-core-contrib-ae87f5b8bf16191b3201cfb445062938eab992a0.tar.gz
parse/ast/data_smart: Add parsing flag to getVar/setVar
When parsing we find problems if we clear prepends/appends when setting variables during the initial parsing phases. Later, we actively want to do this (in what would be post finalisation previously). To handle this, pass a parsing flag to the operations to control the correct behaviour for the context. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/data_smart.py')
-rw-r--r--lib/bb/data_smart.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 28ea2aef63..68efc7bb1c 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -386,6 +386,10 @@ class DataSmart(MutableMapping):
def setVar(self, var, value, **loginfo):
#print("var=" + str(var) + " val=" + str(value))
+ parsing=False
+ if 'parsing' in loginfo:
+ parsing=True
+
if 'op' not in loginfo:
loginfo['op'] = "set"
self.expand_cache = {}
@@ -421,12 +425,13 @@ class DataSmart(MutableMapping):
if not var in self.dict:
self._makeShadowCopy(var)
- if "_append" in self.dict[var]:
- del self.dict[var]["_append"]
- if "_prepend" in self.dict[var]:
- del self.dict[var]["_prepend"]
- if "_overrides" in self.dict[var]:
- del self.dict[var]["_overrides"]
+ if not parsing:
+ if "_append" in self.dict[var]:
+ del self.dict[var]["_append"]
+ if "_prepend" in self.dict[var]:
+ del self.dict[var]["_prepend"]
+ if "_overrides" in self.dict[var]:
+ del self.dict[var]["_overrides"]
# more cookies for the cookie monster
if '_' in var:
@@ -464,20 +469,20 @@ class DataSmart(MutableMapping):
if len(shortvar) == 0:
override = None
- def getVar(self, var, expand=False, noweakdefault=False):
- return self.getVarFlag(var, "_content", expand, noweakdefault)
+ def getVar(self, var, expand=False, noweakdefault=False, parsing=False):
+ return self.getVarFlag(var, "_content", expand, noweakdefault, parsing)
def renameVar(self, key, newkey, **loginfo):
"""
Rename the variable key to newkey
"""
- val = self.getVar(key, 0)
+ val = self.getVar(key, 0, parsing=True)
if val is not None:
loginfo['variable'] = newkey
loginfo['op'] = 'rename from %s' % key
loginfo['detail'] = val
self.varhistory.record(**loginfo)
- self.setVar(newkey, val, ignore=True)
+ self.setVar(newkey, val, ignore=True, parsing=True)
for i in (__setvar_keyword__):
src = self.getVarFlag(key, i)
@@ -545,11 +550,10 @@ class DataSmart(MutableMapping):
self.dict["__exportlist"]["_content"] = set()
self.dict["__exportlist"]["_content"].add(var)
- def getVarFlag(self, var, flag, expand=False, noweakdefault=False):
+ def getVarFlag(self, var, flag, expand=False, noweakdefault=False, parsing=False):
local_var = self._findVar(var)
value = None
-
- if flag == "_content" and local_var is not None and "_overrides" in local_var:
+ if flag == "_content" and local_var is not None and "_overrides" in local_var and not parsing:
match = False
active = {}
for (r, o) in local_var["_overrides"]:
@@ -580,7 +584,8 @@ class DataSmart(MutableMapping):
elif flag == "_content" and "_defaultval" in local_var and not noweakdefault:
value = copy.copy(local_var["_defaultval"])
- if flag == "_content" and local_var is not None and "_append" in local_var:
+
+ if flag == "_content" and local_var is not None and "_append" in local_var and not parsing:
if not value:
value = ""
for (r, o) in local_var["_append"]:
@@ -592,10 +597,11 @@ class DataSmart(MutableMapping):
if match:
value = value + r
- if flag == "_content" and local_var is not None and "_prepend" in local_var:
+ if flag == "_content" and local_var is not None and "_prepend" in local_var and not parsing:
if not value:
value = ""
for (r, o) in local_var["_prepend"]:
+
match = True
if o:
for o2 in o.split("_"):