diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-01-24 15:27:08 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-12 22:50:27 +0100 |
commit | f3b7c3e054ce230ea5c2db5813390383e8dfd6db (patch) | |
tree | b22214f9c9b99d89df06fd5b568e877357500b59 /lib/bb/data_smart.py | |
parent | a075332c9e13be35f1ae84adc6b29e9137a487ff (diff) | |
download | openembedded-core-contrib-f3b7c3e054ce230ea5c2db5813390383e8dfd6db.tar.gz |
data_smart: Cache overrides and fix data store
Rather than repeatedly expanding the value of OVERRIDES, cache
the value and update it when things change.
There were also some bugs introduced in the replaces functionality
which this approach fixes by ensuring the replaces data is updated
at the correct points.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/data_smart.py')
-rw-r--r-- | lib/bb/data_smart.py | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py index eee5827b29..884ca190a6 100644 --- a/lib/bb/data_smart.py +++ b/lib/bb/data_smart.py @@ -311,6 +311,7 @@ class DataSmart(MutableMapping): self.expand_cache = {} + self.overrides = [] self.overridevars = set(["OVERRIDES", "FILE"]) self.replaces = {} @@ -360,7 +361,7 @@ class DataSmart(MutableMapping): def internal_finalize(self, parent = False): """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 [] # # Well let us see what breaks here. We used to iterate @@ -380,7 +381,7 @@ class DataSmart(MutableMapping): self.replaces = {} - for o in overrides: + for o in self.overrides: # calculate '_'+override l = len(o) + 1 @@ -393,6 +394,18 @@ class DataSmart(MutableMapping): name = var[:-l] self.replaces[name] = var + def internal_finalize2(self, var, o): + """Performs final steps upon the datastore, including application of overrides""" + + l = len(o) + 1 + name = var[:-l] + + if name in self.replaces: + del self.replaces[name] + for o in self.overrides: + if o in self._seen_overrides and name + "_" + o in self._seen_overrides[o]: + self.replaces[name] = name + "_" + o + def initVar(self, var): self.expand_cache = {} if not var in self.dict: @@ -457,6 +470,12 @@ class DataSmart(MutableMapping): if "_prepend" in self.dict[var]: del self.dict[var]["_prepend"] + if var in self.replaces: + del self.replaces[var] + for o in self.overrides: + if o in self._seen_overrides and var + "_" + o in self._seen_overrides[o]: + self.delVar(var + "_" + o) + # more cookies for the cookie monster if '_' in var: self._setvar_update_overrides(var) @@ -477,6 +496,7 @@ class DataSmart(MutableMapping): if override not in self._seen_overrides: self._seen_overrides[override] = set() self._seen_overrides[override].add( var ) + self.internal_finalize2(var, override) override = None if "_" in shortvar: override = var[shortvar.rfind('_')+1:] @@ -534,6 +554,7 @@ class DataSmart(MutableMapping): override = var[var.rfind('_')+1:] if override and override in self._seen_overrides and var in self._seen_overrides[override]: self._seen_overrides[override].remove(var) + self.internal_finalize2(var, override) def setVarFlag(self, var, flag, value, **loginfo): self.expand_cache = {} @@ -574,9 +595,8 @@ class DataSmart(MutableMapping): for (r, o) in local_var["_append"]: match = True if o: - overrides = (self.getVar("OVERRIDES", True) or "").split(":") or [] for o2 in o.split("_"): - if not o2 in overrides: + if not o2 in self.overrides: match = False if match: value = value + r @@ -587,9 +607,8 @@ class DataSmart(MutableMapping): for (r, o) in local_var["_prepend"]: match = True if o: - overrides = (self.getVar("OVERRIDES", True) or "").split(":") or [] for o2 in o.split("_"): - if not o2 in overrides: + if not o2 in self.overrides: match = False if match: value = r + value @@ -608,9 +627,8 @@ class DataSmart(MutableMapping): for (r, o) in local_var["_remove"]: match = True if o: - overrides = (self.getVar("OVERRIDES", True) or "").split(":") or [] for o2 in o.split("_"): - if not o2 in overrides: + if not o2 in self.overrides: match = False if match: removes.extend(self.expand(r).split()) @@ -716,6 +734,7 @@ class DataSmart(MutableMapping): data._tracking = self._tracking + data.overrides = copy.copy(self.overrides) data.overridevars = copy.copy(self.overridevars) return data |