From fe30cbc2cb0719092f19cba3b06a37e93260994c Mon Sep 17 00:00:00 2001 From: Peter Seebach Date: Fri, 18 Jan 2013 11:47:34 +0000 Subject: bitbake: bitbake: data_smart.py and friends: Track variable history This patch adds tracking of the history of variable assignments. The changes are predominantly localized to data_smart.py and parse/ast.py. cooker.py and data.py are altered to display the recorded data, and turn tracking on for the bitbake -e case. The data.py update_data() function warns DataSmart.finalize() to report the caller one further back up the tree. In general, d.setVar() does what it used to do. Optionally, arguments describing an operation may be appended; if none are present, the operation is implicitly ignored. If it's not ignored, it will attempt to infer missing information (name of variable, value assigned, file and line) by examining the traceback. This slightly elaborate process eliminates a category of problems in which the 'var' member of the keyword arguments dict is set, and a positional argument corresponding to 'var' is also set. It also makes calling much simpler for the common cases. The resulting output gives you a pretty good picture of what values got set, and how they got set. RP Modifications: a) Split from IncludeHistory to separate VariableHistory b) Add dedicated copy function instead of deepcopy c) Use COW for variables dict d) Remove 'value' loginfo value and just use 'details' e) Desensitise code for calling order (set 'op' before/after infer_caller_details was error prone) f) Fix bug where ?= "" wasn't shown correctly g) Log more set operations as some variables mysteriously acquired values previously h) Standardise infer_caller_details to be triggered from .record() where at all possible to reduce overhead in non-enabled cases i) Rename variable parameter names to match inference code j) Add VariableHistory emit() function to match IncludeHistory k) Fix handling of appendVar, prependVar and matching flag ops l) Use ignored=True to stop logging further events where appropriate (Bitbake rev: f00524a3729000cbcb3317fee933ac448fae5e2d) Signed-off-by: Peter Seebach Signed-off-by: Richard Purdie --- bitbake/lib/bb/data.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'bitbake/lib/bb/data.py') diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py index 2c3e905a77..7047f48934 100644 --- a/bitbake/lib/bb/data.py +++ b/bitbake/lib/bb/data.py @@ -166,9 +166,9 @@ def inheritFromOS(d, savedenv, permitted): for s in savedenv.keys(): if s in permitted: try: - d.setVar(s, getVar(s, savedenv, True)) + d.setVar(s, getVar(s, savedenv, True), op = 'from env') if s in exportlist: - d.setVarFlag(s, "export", True) + d.setVarFlag(s, "export", True, op = 'auto env export') except TypeError: pass @@ -194,8 +194,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False): return 0 if all: - commentVal = re.sub('\n', '\n#', str(oval)) - o.write('# %s=%s\n' % (var, commentVal)) + d.varhistory.emit(var, oval, val, o) if (var.find("-") != -1 or var.find(".") != -1 or var.find('{') != -1 or var.find('}') != -1 or var.find('+') != -1) and not all: return 0 @@ -274,7 +273,7 @@ def emit_func(func, o=sys.__stdout__, d = init()): def update_data(d): """Performs final steps upon the datastore, including application of overrides""" - d.finalize() + d.finalize(parent = True) def build_dependencies(key, keys, shelldeps, vardepvals, d): deps = set() -- cgit v1.2.3-54-g00ecf