bitbake: data_smart: Remove need for update_data calls

Move the update_data functionality into internal data store operations
so the main finalize (update_data) call is a nop.

To make this work we need to call the internal finalization function
whenever OVERRIDES is changed to ensure values get updated correctly.

This has performance issues but the subsequant patches look into this.

(Bitbake rev: 546d9932d6c4413824319a9d780c0d77d2725f4a)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2015-01-23 18:01:00 +00:00
parent 42a59961fa
commit e7ccd90712

View File

@@ -298,6 +298,7 @@ class VariableHistory(object):
class DataSmart(MutableMapping): class DataSmart(MutableMapping):
def __init__(self, special = None, seen = None ): def __init__(self, special = None, seen = None ):
self.dict = {} self.dict = {}
self.overrides = []
if special is None: if special is None:
special = COWDictBase.copy() special = COWDictBase.copy()
@@ -354,11 +355,13 @@ class DataSmart(MutableMapping):
def expand(self, s, varname = None): def expand(self, s, varname = None):
return self.expandWithRefs(s, varname).value return self.expandWithRefs(s, varname).value
def finalize(self, parent = False): def finalize(self, parent = False):
return
def internal_finalize(self, parent = False):
"""Performs final steps upon the datastore, including application of overrides""" """Performs final steps upon the datastore, including application of overrides"""
overrides = (self.getVar("OVERRIDES", True) or "").split(":") or [] self.overrides = (self.getVar("OVERRIDES", True) or "").split(":") or []
finalize_caller = { finalize_caller = {
'op': 'finalize', 'op': 'finalize',
} }
@@ -383,7 +386,7 @@ class DataSmart(MutableMapping):
# We only want to report finalization once per variable overridden. # We only want to report finalization once per variable overridden.
finalizes_reported = {} finalizes_reported = {}
for o in overrides: for o in self.overrides:
# calculate '_'+override # calculate '_'+override
l = len(o) + 1 l = len(o) + 1
@@ -417,12 +420,15 @@ class DataSmart(MutableMapping):
if op in self._special_values: if op in self._special_values:
appends = self._special_values[op] or [] appends = self._special_values[op] or []
for append in appends: for append in appends:
self.handle_special_values(append, op)
def handle_special_values(self, append, op):
keep = [] keep = []
for (a, o) in self.getVarFlag(append, op) or []: for (a, o) in self.getVarFlag(append, op) or []:
match = True match = True
if o: if o:
for o2 in o.split("_"): for o2 in o.split("_"):
if not o2 in overrides: if not o2 in self.overrides:
match = False match = False
if not match: if not match:
keep.append((a ,o)) keep.append((a ,o))
@@ -502,6 +508,7 @@ class DataSmart(MutableMapping):
except KeyError: except KeyError:
self._special_values[keyword] = set() self._special_values[keyword] = set()
self._special_values[keyword].add(base) self._special_values[keyword].add(base)
self.handle_special_values(base, keyword)
return return
@@ -521,6 +528,9 @@ class DataSmart(MutableMapping):
self.dict[var]["_content"] = value self.dict[var]["_content"] = value
self.varhistory.record(**loginfo) self.varhistory.record(**loginfo)
if var == "OVERRIDES":
self.internal_finalize(True)
def _setvar_update_overrides(self, var): def _setvar_update_overrides(self, var):
# aka pay the cookie monster # aka pay the cookie monster
override = var[var.rfind('_')+1:] override = var[var.rfind('_')+1:]
@@ -733,6 +743,7 @@ class DataSmart(MutableMapping):
# we really want this to be a DataSmart... # we really want this to be a DataSmart...
data = DataSmart(seen=self._seen_overrides.copy(), special=self._special_values.copy()) data = DataSmart(seen=self._seen_overrides.copy(), special=self._special_values.copy())
data.dict["_data"] = self.dict data.dict["_data"] = self.dict
data.overrides = copy.copy(self.overrides)
data.varhistory = self.varhistory.copy() data.varhistory = self.varhistory.copy()
data.varhistory.datasmart = data data.varhistory.datasmart = data
data.inchistory = self.inchistory.copy() data.inchistory = self.inchistory.copy()