summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/data_smart.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-12-13 20:07:04 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-14 12:25:07 +0000
commitd325d94f3f8b6a475aebe3ae7d8a140ac6fec779 (patch)
tree0aed87e5ae71454350b631cc30e4dd6a2247b78b /bitbake/lib/bb/data_smart.py
parent727f332829a29cf71972573e68b53bb570e30ffd (diff)
downloadpoky-d325d94f3f8b6a475aebe3ae7d8a140ac6fec779.tar.gz
bitbake: data_smart: implement remote datastore functionality
This allows you to maintain a local reference to a remote datastore. The actual implementation of the remote connection is delegated to a connector object that the caller must define and supply. There is support for getting variable values and expanding python references (i.e. ${@...} remotely, however setting variables remotely is not supported - any variable setting is done locally as if the datastore were a copy (which it kind of is). Loosely based on an earlier prototype implementation by Qing He. (Bitbake rev: a3edc3eefa2d03c4ad5d12187b32fa4dc495082a) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/data_smart.py')
-rw-r--r--bitbake/lib/bb/data_smart.py39
1 files changed, 33 insertions, 6 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index 17768c8f4b..5d0ed12d6e 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -116,7 +116,15 @@ class VariableParse:
116 return match.group() 116 return match.group()
117 117
118 def python_sub(self, match): 118 def python_sub(self, match):
119 code = match.group()[3:-1] 119 if isinstance(match, str):
120 code = match
121 else:
122 code = match.group()[3:-1]
123
124 if "_remote_data" in self.d:
125 connector = self.d["_remote_data"]
126 return connector.expandPythonRef(self.varname, code)
127
120 codeobj = compile(code.strip(), self.varname or "<expansion>", "eval") 128 codeobj = compile(code.strip(), self.varname or "<expansion>", "eval")
121 129
122 parser = bb.codeparser.PythonParser(self.varname, logger) 130 parser = bb.codeparser.PythonParser(self.varname, logger)
@@ -247,10 +255,15 @@ class VariableHistory(object):
247 self.variables[var].append(loginfo.copy()) 255 self.variables[var].append(loginfo.copy())
248 256
249 def variable(self, var): 257 def variable(self, var):
250 if var in self.variables: 258 remote_connector = self.dataroot.getVar('_remote_data', False)
251 return self.variables[var] 259 if remote_connector:
260 varhistory = remote_connector.getVarHistory(var)
252 else: 261 else:
253 return [] 262 varhistory = []
263
264 if var in self.variables:
265 varhistory.extend(self.variables[var])
266 return varhistory
254 267
255 def emit(self, var, oval, val, o, d): 268 def emit(self, var, oval, val, o, d):
256 history = self.variable(var) 269 history = self.variable(var)
@@ -449,6 +462,10 @@ class DataSmart(MutableMapping):
449 if var in dest: 462 if var in dest:
450 return dest[var] 463 return dest[var]
451 464
465 if "_remote_data" in dest:
466 connector = dest["_remote_data"]["_content"]
467 return connector.getVar(var)
468
452 if "_data" not in dest: 469 if "_data" not in dest:
453 break 470 break
454 dest = dest["_data"] 471 dest = dest["_data"]
@@ -471,6 +488,12 @@ class DataSmart(MutableMapping):
471 if 'parsing' in loginfo: 488 if 'parsing' in loginfo:
472 parsing=True 489 parsing=True
473 490
491 if '_remote_data' in self.dict:
492 connector = self.dict["_remote_data"]["_content"]
493 res = connector.setVar(var, value)
494 if not res:
495 return
496
474 if 'op' not in loginfo: 497 if 'op' not in loginfo:
475 loginfo['op'] = "set" 498 loginfo['op'] = "set"
476 self.expand_cache = {} 499 self.expand_cache = {}
@@ -875,7 +898,7 @@ class DataSmart(MutableMapping):
875 898
876 def localkeys(self): 899 def localkeys(self):
877 for key in self.dict: 900 for key in self.dict:
878 if key != '_data': 901 if key not in ['_data', '_remote_data']:
879 yield key 902 yield key
880 903
881 def __iter__(self): 904 def __iter__(self):
@@ -884,7 +907,7 @@ class DataSmart(MutableMapping):
884 def keylist(d): 907 def keylist(d):
885 klist = set() 908 klist = set()
886 for key in d: 909 for key in d:
887 if key == "_data": 910 if key in ["_data", "_remote_data"]:
888 continue 911 continue
889 if key in deleted: 912 if key in deleted:
890 continue 913 continue
@@ -898,6 +921,10 @@ class DataSmart(MutableMapping):
898 if "_data" in d: 921 if "_data" in d:
899 klist |= keylist(d["_data"]) 922 klist |= keylist(d["_data"])
900 923
924 if "_remote_data" in d:
925 connector = d["_remote_data"]["_content"]
926 klist |= connector.getKeys()
927
901 return klist 928 return klist
902 929
903 self.need_overrides() 930 self.need_overrides()