summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-01-24 15:27:08 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-12 22:50:45 +0100
commit7fc6f6c98d4479a8ae81e0961a7dd93d436e804e (patch)
tree1764e2b382f80a6fc35d1b59e02591e6bb29d956
parent35a6f7d21fc4a034a427e25f98da6202becfd2a7 (diff)
downloadpoky-7fc6f6c98d4479a8ae81e0961a7dd93d436e804e.tar.gz
bitbake: 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. (Bitbake rev: f3b7c3e054ce230ea5c2db5813390383e8dfd6db) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/data_smart.py35
1 files changed, 27 insertions, 8 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index eee5827b29..884ca190a6 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -311,6 +311,7 @@ class DataSmart(MutableMapping):
311 311
312 self.expand_cache = {} 312 self.expand_cache = {}
313 313
314 self.overrides = []
314 self.overridevars = set(["OVERRIDES", "FILE"]) 315 self.overridevars = set(["OVERRIDES", "FILE"])
315 self.replaces = {} 316 self.replaces = {}
316 317
@@ -360,7 +361,7 @@ class DataSmart(MutableMapping):
360 def internal_finalize(self, parent = False): 361 def internal_finalize(self, parent = False):
361 """Performs final steps upon the datastore, including application of overrides""" 362 """Performs final steps upon the datastore, including application of overrides"""
362 363
363 overrides = (self.getVar("OVERRIDES", True) or "").split(":") or [] 364 self.overrides = (self.getVar("OVERRIDES", True) or "").split(":") or []
364 365
365 # 366 #
366 # Well let us see what breaks here. We used to iterate 367 # Well let us see what breaks here. We used to iterate
@@ -380,7 +381,7 @@ class DataSmart(MutableMapping):
380 381
381 self.replaces = {} 382 self.replaces = {}
382 383
383 for o in overrides: 384 for o in self.overrides:
384 # calculate '_'+override 385 # calculate '_'+override
385 l = len(o) + 1 386 l = len(o) + 1
386 387
@@ -393,6 +394,18 @@ class DataSmart(MutableMapping):
393 name = var[:-l] 394 name = var[:-l]
394 self.replaces[name] = var 395 self.replaces[name] = var
395 396
397 def internal_finalize2(self, var, o):
398 """Performs final steps upon the datastore, including application of overrides"""
399
400 l = len(o) + 1
401 name = var[:-l]
402
403 if name in self.replaces:
404 del self.replaces[name]
405 for o in self.overrides:
406 if o in self._seen_overrides and name + "_" + o in self._seen_overrides[o]:
407 self.replaces[name] = name + "_" + o
408
396 def initVar(self, var): 409 def initVar(self, var):
397 self.expand_cache = {} 410 self.expand_cache = {}
398 if not var in self.dict: 411 if not var in self.dict:
@@ -457,6 +470,12 @@ class DataSmart(MutableMapping):
457 if "_prepend" in self.dict[var]: 470 if "_prepend" in self.dict[var]:
458 del self.dict[var]["_prepend"] 471 del self.dict[var]["_prepend"]
459 472
473 if var in self.replaces:
474 del self.replaces[var]
475 for o in self.overrides:
476 if o in self._seen_overrides and var + "_" + o in self._seen_overrides[o]:
477 self.delVar(var + "_" + o)
478
460 # more cookies for the cookie monster 479 # more cookies for the cookie monster
461 if '_' in var: 480 if '_' in var:
462 self._setvar_update_overrides(var) 481 self._setvar_update_overrides(var)
@@ -477,6 +496,7 @@ class DataSmart(MutableMapping):
477 if override not in self._seen_overrides: 496 if override not in self._seen_overrides:
478 self._seen_overrides[override] = set() 497 self._seen_overrides[override] = set()
479 self._seen_overrides[override].add( var ) 498 self._seen_overrides[override].add( var )
499 self.internal_finalize2(var, override)
480 override = None 500 override = None
481 if "_" in shortvar: 501 if "_" in shortvar:
482 override = var[shortvar.rfind('_')+1:] 502 override = var[shortvar.rfind('_')+1:]
@@ -534,6 +554,7 @@ class DataSmart(MutableMapping):
534 override = var[var.rfind('_')+1:] 554 override = var[var.rfind('_')+1:]
535 if override and override in self._seen_overrides and var in self._seen_overrides[override]: 555 if override and override in self._seen_overrides and var in self._seen_overrides[override]:
536 self._seen_overrides[override].remove(var) 556 self._seen_overrides[override].remove(var)
557 self.internal_finalize2(var, override)
537 558
538 def setVarFlag(self, var, flag, value, **loginfo): 559 def setVarFlag(self, var, flag, value, **loginfo):
539 self.expand_cache = {} 560 self.expand_cache = {}
@@ -574,9 +595,8 @@ class DataSmart(MutableMapping):
574 for (r, o) in local_var["_append"]: 595 for (r, o) in local_var["_append"]:
575 match = True 596 match = True
576 if o: 597 if o:
577 overrides = (self.getVar("OVERRIDES", True) or "").split(":") or []
578 for o2 in o.split("_"): 598 for o2 in o.split("_"):
579 if not o2 in overrides: 599 if not o2 in self.overrides:
580 match = False 600 match = False
581 if match: 601 if match:
582 value = value + r 602 value = value + r
@@ -587,9 +607,8 @@ class DataSmart(MutableMapping):
587 for (r, o) in local_var["_prepend"]: 607 for (r, o) in local_var["_prepend"]:
588 match = True 608 match = True
589 if o: 609 if o:
590 overrides = (self.getVar("OVERRIDES", True) or "").split(":") or []
591 for o2 in o.split("_"): 610 for o2 in o.split("_"):
592 if not o2 in overrides: 611 if not o2 in self.overrides:
593 match = False 612 match = False
594 if match: 613 if match:
595 value = r + value 614 value = r + value
@@ -608,9 +627,8 @@ class DataSmart(MutableMapping):
608 for (r, o) in local_var["_remove"]: 627 for (r, o) in local_var["_remove"]:
609 match = True 628 match = True
610 if o: 629 if o:
611 overrides = (self.getVar("OVERRIDES", True) or "").split(":") or []
612 for o2 in o.split("_"): 630 for o2 in o.split("_"):
613 if not o2 in overrides: 631 if not o2 in self.overrides:
614 match = False 632 match = False
615 if match: 633 if match:
616 removes.extend(self.expand(r).split()) 634 removes.extend(self.expand(r).split())
@@ -716,6 +734,7 @@ class DataSmart(MutableMapping):
716 734
717 data._tracking = self._tracking 735 data._tracking = self._tracking
718 736
737 data.overrides = copy.copy(self.overrides)
719 data.overridevars = copy.copy(self.overridevars) 738 data.overridevars = copy.copy(self.overridevars)
720 739
721 return data 740 return data