diff options
Diffstat (limited to 'import-layers/yocto-poky/bitbake/lib/bb/data_smart.py')
-rw-r--r-- | import-layers/yocto-poky/bitbake/lib/bb/data_smart.py | 120 |
1 files changed, 94 insertions, 26 deletions
diff --git a/import-layers/yocto-poky/bitbake/lib/bb/data_smart.py b/import-layers/yocto-poky/bitbake/lib/bb/data_smart.py index 805a9a71f..7dc1c6870 100644 --- a/import-layers/yocto-poky/bitbake/lib/bb/data_smart.py +++ b/import-layers/yocto-poky/bitbake/lib/bb/data_smart.py @@ -108,7 +108,7 @@ class VariableParse: varparse = self.d.expand_cache[key] var = varparse.value else: - var = self.d.getVarFlag(key, "_content", True) + var = self.d.getVarFlag(key, "_content") self.references.add(key) if var is not None: return var @@ -116,13 +116,21 @@ class VariableParse: return match.group() def python_sub(self, match): - code = match.group()[3:-1] + if isinstance(match, str): + code = match + else: + code = match.group()[3:-1] + + if "_remote_data" in self.d: + connector = self.d["_remote_data"] + return connector.expandPythonRef(self.varname, code, self.d) + codeobj = compile(code.strip(), self.varname or "<expansion>", "eval") parser = bb.codeparser.PythonParser(self.varname, logger) parser.parse_python(code) if self.varname: - vardeps = self.d.getVarFlag(self.varname, "vardeps", True) + vardeps = self.d.getVarFlag(self.varname, "vardeps") if vardeps is None: parser.log.flush() else: @@ -146,7 +154,7 @@ class DataContext(dict): self['d'] = metadata def __missing__(self, key): - value = self.metadata.getVar(key, True) + value = self.metadata.getVar(key) if value is None or self.metadata.getVarFlag(key, 'func', False): raise KeyError(key) else: @@ -222,6 +230,19 @@ class VariableHistory(object): new.variables = self.variables.copy() return new + def __getstate__(self): + vardict = {} + for k, v in self.variables.iteritems(): + vardict[k] = v + return {'dataroot': self.dataroot, + 'variables': vardict} + + def __setstate__(self, state): + self.dataroot = state['dataroot'] + self.variables = COWDictBase.copy() + for k, v in state['variables'].items(): + self.variables[k] = v + def record(self, *kwonly, **loginfo): if not self.dataroot._tracking: return @@ -247,10 +268,15 @@ class VariableHistory(object): self.variables[var].append(loginfo.copy()) def variable(self, var): - if var in self.variables: - return self.variables[var] + remote_connector = self.dataroot.getVar('_remote_data', False) + if remote_connector: + varhistory = remote_connector.getVarHistory(var) else: - return [] + varhistory = [] + + if var in self.variables: + varhistory.extend(self.variables[var]) + return varhistory def emit(self, var, oval, val, o, d): history = self.variable(var) @@ -318,7 +344,7 @@ class VariableHistory(object): the files in which they were added. """ history = self.variable(var) - finalitems = (d.getVar(var, True) or '').split() + finalitems = (d.getVar(var) or '').split() filemap = {} isset = False for event in history: @@ -426,11 +452,11 @@ class DataSmart(MutableMapping): # Can end up here recursively so setup dummy values self.overrides = [] self.overridesset = set() - self.overrides = (self.getVar("OVERRIDES", True) or "").split(":") or [] + self.overrides = (self.getVar("OVERRIDES") or "").split(":") or [] self.overridesset = set(self.overrides) self.inoverride = False self.expand_cache = {} - newoverrides = (self.getVar("OVERRIDES", True) or "").split(":") or [] + newoverrides = (self.getVar("OVERRIDES") or "").split(":") or [] if newoverrides == self.overrides: break self.overrides = newoverrides @@ -447,17 +473,22 @@ class DataSmart(MutableMapping): dest = self.dict while dest: if var in dest: - return dest[var] + return dest[var], self.overridedata.get(var, None) + + if "_remote_data" in dest: + connector = dest["_remote_data"]["_content"] + return connector.getVar(var) if "_data" not in dest: break dest = dest["_data"] + return None, self.overridedata.get(var, None) def _makeShadowCopy(self, var): if var in self.dict: return - local_var = self._findVar(var) + local_var, _ = self._findVar(var) if local_var: self.dict[var] = copy.copy(local_var) @@ -471,6 +502,12 @@ class DataSmart(MutableMapping): if 'parsing' in loginfo: parsing=True + if '_remote_data' in self.dict: + connector = self.dict["_remote_data"]["_content"] + res = connector.setVar(var, value) + if not res: + return + if 'op' not in loginfo: loginfo['op'] = "set" self.expand_cache = {} @@ -509,6 +546,8 @@ class DataSmart(MutableMapping): del self.dict[var]["_append"] if "_prepend" in self.dict[var]: del self.dict[var]["_prepend"] + if "_remove" in self.dict[var]: + del self.dict[var]["_remove"] if var in self.overridedata: active = [] self.need_overrides() @@ -541,7 +580,7 @@ class DataSmart(MutableMapping): nextnew = set() self.overridevars.update(new) for i in new: - vardata = self.expandWithRefs(self.getVar(i, True), i) + vardata = self.expandWithRefs(self.getVar(i), i) nextnew.update(vardata.references) nextnew.update(vardata.contains.keys()) new = nextnew @@ -565,13 +604,19 @@ class DataSmart(MutableMapping): if len(shortvar) == 0: override = None - def getVar(self, var, expand, noweakdefault=False, parsing=False): + def getVar(self, var, expand=True, noweakdefault=False, parsing=False): return self.getVarFlag(var, "_content", expand, noweakdefault, parsing) def renameVar(self, key, newkey, **loginfo): """ Rename the variable key to newkey """ + if '_remote_data' in self.dict: + connector = self.dict["_remote_data"]["_content"] + res = connector.renameVar(key, newkey) + if not res: + return + val = self.getVar(key, 0, parsing=True) if val is not None: loginfo['variable'] = newkey @@ -615,6 +660,12 @@ class DataSmart(MutableMapping): self.setVar(var + "_prepend", value, ignore=True, parsing=True) def delVar(self, var, **loginfo): + if '_remote_data' in self.dict: + connector = self.dict["_remote_data"]["_content"] + res = connector.delVar(var) + if not res: + return + loginfo['detail'] = "" loginfo['op'] = 'del' self.varhistory.record(**loginfo) @@ -641,6 +692,12 @@ class DataSmart(MutableMapping): override = None def setVarFlag(self, var, flag, value, **loginfo): + if '_remote_data' in self.dict: + connector = self.dict["_remote_data"]["_content"] + res = connector.setVarFlag(var, flag, value) + if not res: + return + self.expand_cache = {} if 'op' not in loginfo: loginfo['op'] = "set" @@ -662,14 +719,14 @@ class DataSmart(MutableMapping): self.dict["__exportlist"]["_content"] = set() self.dict["__exportlist"]["_content"].add(var) - def getVarFlag(self, var, flag, expand, noweakdefault=False, parsing=False): - local_var = self._findVar(var) + def getVarFlag(self, var, flag, expand=True, noweakdefault=False, parsing=False): + local_var, overridedata = self._findVar(var) value = None - if flag == "_content" and var in self.overridedata and not parsing: + if flag == "_content" and overridedata is not None and not parsing: match = False active = {} self.need_overrides() - for (r, o) in self.overridedata[var]: + for (r, o) in overridedata: # What about double overrides both with "_" in the name? if o in self.overridesset: active[o] = r @@ -759,8 +816,14 @@ class DataSmart(MutableMapping): return value def delVarFlag(self, var, flag, **loginfo): + if '_remote_data' in self.dict: + connector = self.dict["_remote_data"]["_content"] + res = connector.delVarFlag(var, flag) + if not res: + return + self.expand_cache = {} - local_var = self._findVar(var) + local_var, _ = self._findVar(var) if not local_var: return if not var in self.dict: @@ -803,7 +866,7 @@ class DataSmart(MutableMapping): self.dict[var][i] = flags[i] def getVarFlags(self, var, expand = False, internalflags=False): - local_var = self._findVar(var) + local_var, _ = self._findVar(var) flags = {} if local_var: @@ -845,7 +908,7 @@ class DataSmart(MutableMapping): data = DataSmart() data.dict["_data"] = self.dict data.varhistory = self.varhistory.copy() - data.varhistory.datasmart = data + data.varhistory.dataroot = data data.inchistory = self.inchistory.copy() data._tracking = self._tracking @@ -876,7 +939,7 @@ class DataSmart(MutableMapping): def localkeys(self): for key in self.dict: - if key != '_data': + if key not in ['_data', '_remote_data']: yield key def __iter__(self): @@ -885,7 +948,7 @@ class DataSmart(MutableMapping): def keylist(d): klist = set() for key in d: - if key == "_data": + if key in ["_data", "_remote_data"]: continue if key in deleted: continue @@ -899,6 +962,13 @@ class DataSmart(MutableMapping): if "_data" in d: klist |= keylist(d["_data"]) + if "_remote_data" in d: + connector = d["_remote_data"]["_content"] + for key in connector.getKeys(): + if key in deleted: + continue + klist.add(key) + return klist self.need_overrides() @@ -936,9 +1006,8 @@ class DataSmart(MutableMapping): data = {} d = self.createCopy() bb.data.expandKeys(d) - bb.data.update_data(d) - config_whitelist = set((d.getVar("BB_HASHCONFIG_WHITELIST", True) or "").split()) + config_whitelist = set((d.getVar("BB_HASHCONFIG_WHITELIST") or "").split()) keys = set(key for key in iter(d) if not key.startswith("__")) for key in keys: if key in config_whitelist: @@ -957,7 +1026,6 @@ class DataSmart(MutableMapping): for key in ["__BBTASKS", "__BBANONFUNCS", "__BBHANDLERS"]: bb_list = d.getVar(key, False) or [] - bb_list.sort() data.update({key:str(bb_list)}) if key == "__BBANONFUNCS": |