summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tinfoil.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/tinfoil.py')
-rw-r--r--bitbake/lib/bb/tinfoil.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
index 13b05cec2d..60359a1a38 100644
--- a/bitbake/lib/bb/tinfoil.py
+++ b/bitbake/lib/bb/tinfoil.py
@@ -15,6 +15,7 @@ import atexit
15import re 15import re
16from collections import OrderedDict, defaultdict 16from collections import OrderedDict, defaultdict
17from functools import partial 17from functools import partial
18from contextlib import contextmanager
18 19
19import bb.cache 20import bb.cache
20import bb.cooker 21import bb.cooker
@@ -641,6 +642,22 @@ class Tinfoil:
641 fn = self.get_recipe_file(pn) 642 fn = self.get_recipe_file(pn)
642 return self.parse_recipe_file(fn) 643 return self.parse_recipe_file(fn)
643 644
645 @contextmanager
646 def _data_tracked_if_enabled(self):
647 """
648 A context manager to enable data tracking for a code segment if data
649 tracking was enabled for this tinfoil instance.
650 """
651 if self.tracking:
652 # Enable history tracking just for the operation
653 self.run_command('enableDataTracking')
654
655 # Here goes the operation with the optional data tracking
656 yield
657
658 if self.tracking:
659 self.run_command('disableDataTracking')
660
644 def finalizeData(self): 661 def finalizeData(self):
645 """ 662 """
646 Run anonymous functions and expand keys 663 Run anonymous functions and expand keys
@@ -659,10 +676,7 @@ class Tinfoil:
659 appendlist: optional list of bbappend files to apply, if you 676 appendlist: optional list of bbappend files to apply, if you
660 want to filter them 677 want to filter them
661 """ 678 """
662 if self.tracking: 679 with self._data_tracked_if_enabled():
663 # Enable history tracking just for the parse operation
664 self.run_command('enableDataTracking')
665 try:
666 if appends and appendlist == []: 680 if appends and appendlist == []:
667 appends = False 681 appends = False
668 if config_data: 682 if config_data:
@@ -674,9 +688,6 @@ class Tinfoil:
674 return self._reconvert_type(dscon, 'DataStoreConnectionHandle') 688 return self._reconvert_type(dscon, 'DataStoreConnectionHandle')
675 else: 689 else:
676 return None 690 return None
677 finally:
678 if self.tracking:
679 self.run_command('disableDataTracking')
680 691
681 def build_file(self, buildfile, task, internal=True): 692 def build_file(self, buildfile, task, internal=True):
682 """ 693 """