2005-08-31 10:47:56 +00:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
"""
|
|
|
|
BitBake Smart Dictionary Implementation
|
|
|
|
|
|
|
|
Functions for interacting with the data structure used by the
|
|
|
|
BitBake build tools.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2007-01-08 23:53:01 +00:00
|
|
|
# Copyright (C) 2003, 2004 Chris Larson
|
|
|
|
# Copyright (C) 2004, 2005 Seb Frankengul
|
|
|
|
# Copyright (C) 2005, 2006 Holger Hans Peter Freyther
|
|
|
|
# Copyright (C) 2005 Uli Luckas
|
|
|
|
# Copyright (C) 2005 ROAD GmbH
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
# Based on functions from the base bb module, Copyright 2003 Holger Schurig
|
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
import copy, re, sys, traceback
|
2010-04-13 01:56:25 +00:00
|
|
|
from collections import MutableMapping
|
2010-06-10 17:35:31 +00:00
|
|
|
import logging
|
2012-02-23 13:47:13 +00:00
|
|
|
import hashlib
|
2011-01-01 23:55:54 +00:00
|
|
|
import bb, bb.codeparser
|
2010-04-08 17:22:29 +00:00
|
|
|
from bb import utils
|
2010-03-24 23:56:12 +00:00
|
|
|
from bb.COW import COWDictBase
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-06-10 17:35:31 +00:00
|
|
|
logger = logging.getLogger("BitBake.Data")
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-03-24 23:56:12 +00:00
|
|
|
__setvar_keyword__ = ["_append", "_prepend"]
|
2012-08-03 09:24:32 +00:00
|
|
|
__setvar_regexp__ = re.compile('(?P<base>.*?)(?P<keyword>_append|_prepend)(_(?P<add>.*))?$')
|
2005-08-31 10:47:56 +00:00
|
|
|
__expand_var_regexp__ = re.compile(r"\${[^{}]+}")
|
2010-05-22 23:36:08 +00:00
|
|
|
__expand_python_regexp__ = re.compile(r"\${@.+?}")
|
2005-08-31 10:47:56 +00:00
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
def infer_caller_details(loginfo, parent = False, varval = True):
|
|
|
|
"""Save the caller the trouble of specifying everything."""
|
|
|
|
# Save effort.
|
|
|
|
if 'ignore' in loginfo and loginfo['ignore']:
|
|
|
|
return
|
|
|
|
# If nothing was provided, mark this as possibly unneeded.
|
|
|
|
if not loginfo:
|
|
|
|
loginfo['ignore'] = True
|
|
|
|
return
|
|
|
|
# Infer caller's likely values for variable (var) and value (value),
|
|
|
|
# to reduce clutter in the rest of the code.
|
|
|
|
if varval and ('variable' not in loginfo or 'detail' not in loginfo):
|
|
|
|
try:
|
|
|
|
raise Exception
|
|
|
|
except Exception:
|
|
|
|
tb = sys.exc_info()[2]
|
|
|
|
if parent:
|
|
|
|
above = tb.tb_frame.f_back.f_back
|
|
|
|
else:
|
|
|
|
above = tb.tb_frame.f_back
|
|
|
|
lcls = above.f_locals.items()
|
|
|
|
for k, v in lcls:
|
|
|
|
if k == 'value' and 'detail' not in loginfo:
|
|
|
|
loginfo['detail'] = v
|
|
|
|
if k == 'var' and 'variable' not in loginfo:
|
|
|
|
loginfo['variable'] = v
|
|
|
|
# Infer file/line/function from traceback
|
|
|
|
if 'file' not in loginfo:
|
|
|
|
depth = 3
|
|
|
|
if parent:
|
|
|
|
depth = 4
|
|
|
|
file, line, func, text = traceback.extract_stack(limit = depth)[0]
|
|
|
|
loginfo['file'] = file
|
|
|
|
loginfo['line'] = line
|
|
|
|
if func not in loginfo:
|
|
|
|
loginfo['func'] = func
|
2011-01-01 23:55:54 +00:00
|
|
|
|
2010-08-25 13:26:37 +00:00
|
|
|
class VariableParse:
|
|
|
|
def __init__(self, varname, d, val = None):
|
|
|
|
self.varname = varname
|
|
|
|
self.d = d
|
|
|
|
self.value = val
|
|
|
|
|
|
|
|
self.references = set()
|
2010-08-02 09:20:20 +00:00
|
|
|
self.execs = set()
|
2010-08-25 13:26:37 +00:00
|
|
|
|
|
|
|
def var_sub(self, match):
|
|
|
|
key = match.group()[2:-1]
|
|
|
|
if self.varname and key:
|
|
|
|
if self.varname == key:
|
|
|
|
raise Exception("variable %s references itself!" % self.varname)
|
2012-03-03 10:41:41 +00:00
|
|
|
var = self.d.getVar(key, True)
|
2010-08-25 13:26:37 +00:00
|
|
|
if var is not None:
|
|
|
|
self.references.add(key)
|
|
|
|
return var
|
|
|
|
else:
|
|
|
|
return match.group()
|
|
|
|
|
|
|
|
def python_sub(self, match):
|
|
|
|
code = match.group()[3:-1]
|
|
|
|
codeobj = compile(code.strip(), self.varname or "<expansion>", "eval")
|
|
|
|
|
2011-11-04 18:59:46 +00:00
|
|
|
parser = bb.codeparser.PythonParser(self.varname, logger)
|
2010-08-25 13:26:37 +00:00
|
|
|
parser.parse_python(code)
|
2011-11-04 18:59:46 +00:00
|
|
|
if self.varname:
|
|
|
|
vardeps = self.d.getVarFlag(self.varname, "vardeps", True)
|
|
|
|
if vardeps is None:
|
|
|
|
parser.log.flush()
|
|
|
|
else:
|
|
|
|
parser.log.flush()
|
2010-08-25 13:26:37 +00:00
|
|
|
self.references |= parser.references
|
2010-08-02 09:20:20 +00:00
|
|
|
self.execs |= parser.execs
|
2010-08-25 13:26:37 +00:00
|
|
|
|
2011-01-01 23:55:54 +00:00
|
|
|
value = utils.better_eval(codeobj, DataContext(self.d))
|
2010-08-25 13:26:37 +00:00
|
|
|
return str(value)
|
|
|
|
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2011-01-01 23:55:54 +00:00
|
|
|
class DataContext(dict):
|
2010-10-06 02:35:23 +00:00
|
|
|
def __init__(self, metadata, **kwargs):
|
|
|
|
self.metadata = metadata
|
|
|
|
dict.__init__(self, **kwargs)
|
|
|
|
self['d'] = metadata
|
|
|
|
|
|
|
|
def __missing__(self, key):
|
|
|
|
value = self.metadata.getVar(key, True)
|
|
|
|
if value is None or self.metadata.getVarFlag(key, 'func'):
|
|
|
|
raise KeyError(key)
|
|
|
|
else:
|
|
|
|
return value
|
|
|
|
|
2011-02-23 13:13:31 +00:00
|
|
|
class ExpansionError(Exception):
|
|
|
|
def __init__(self, varname, expression, exception):
|
|
|
|
self.expression = expression
|
|
|
|
self.variablename = varname
|
|
|
|
self.exception = exception
|
2012-05-30 16:17:14 +00:00
|
|
|
if varname:
|
2012-09-25 14:17:17 +00:00
|
|
|
if expression:
|
|
|
|
self.msg = "Failure expanding variable %s, expression was %s which triggered exception %s: %s" % (varname, expression, type(exception).__name__, exception)
|
|
|
|
else:
|
|
|
|
self.msg = "Failure expanding variable %s: %s: %s" % (varname, type(exception).__name__, exception)
|
2012-05-30 16:17:14 +00:00
|
|
|
else:
|
|
|
|
self.msg = "Failure expanding expression %s which triggered exception %s: %s" % (expression, type(exception).__name__, exception)
|
2011-02-23 13:13:31 +00:00
|
|
|
Exception.__init__(self, self.msg)
|
|
|
|
self.args = (varname, expression, exception)
|
|
|
|
def __str__(self):
|
|
|
|
return self.msg
|
|
|
|
|
2013-01-18 11:45:22 +00:00
|
|
|
class IncludeHistory(object):
|
|
|
|
def __init__(self, parent = None, filename = '[TOP LEVEL]'):
|
|
|
|
self.parent = parent
|
|
|
|
self.filename = filename
|
|
|
|
self.children = []
|
|
|
|
self.current = self
|
|
|
|
|
|
|
|
def copy(self):
|
|
|
|
new = IncludeHistory(self.parent, self.filename)
|
|
|
|
for c in self.children:
|
|
|
|
new.children.append(c)
|
|
|
|
return new
|
|
|
|
|
|
|
|
def include(self, filename):
|
|
|
|
newfile = IncludeHistory(self.current, filename)
|
|
|
|
self.current.children.append(newfile)
|
|
|
|
self.current = newfile
|
|
|
|
return self
|
|
|
|
|
|
|
|
def __enter__(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def __exit__(self, a, b, c):
|
|
|
|
if self.current.parent:
|
|
|
|
self.current = self.current.parent
|
|
|
|
else:
|
|
|
|
bb.warn("Include log: Tried to finish '%s' at top level." % filename)
|
|
|
|
return False
|
|
|
|
|
|
|
|
def emit(self, o, level = 0):
|
|
|
|
"""Emit an include history file, and its children."""
|
|
|
|
if level:
|
|
|
|
spaces = " " * (level - 1)
|
|
|
|
o.write("# %s%s" % (spaces, self.filename))
|
|
|
|
if len(self.children) > 0:
|
|
|
|
o.write(" includes:")
|
|
|
|
else:
|
|
|
|
o.write("#\n# INCLUDE HISTORY:\n#")
|
|
|
|
level = level + 1
|
|
|
|
for child in self.children:
|
|
|
|
o.write("\n")
|
|
|
|
child.emit(o, level)
|
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
class VariableHistory(object):
|
|
|
|
def __init__(self, dataroot):
|
|
|
|
self.dataroot = dataroot
|
|
|
|
self.variables = COWDictBase.copy()
|
|
|
|
|
|
|
|
def copy(self):
|
|
|
|
new = VariableHistory(self.dataroot)
|
|
|
|
new.variables = self.variables.copy()
|
|
|
|
return new
|
|
|
|
|
|
|
|
def record(self, *kwonly, **loginfo):
|
|
|
|
if not self.dataroot._tracking:
|
|
|
|
return
|
|
|
|
if len(kwonly) > 0:
|
|
|
|
raise TypeError
|
|
|
|
infer_caller_details(loginfo, parent = True)
|
|
|
|
if 'ignore' in loginfo and loginfo['ignore']:
|
|
|
|
return
|
|
|
|
if 'op' not in loginfo or not loginfo['op']:
|
|
|
|
loginfo['op'] = 'set'
|
|
|
|
if 'detail' in loginfo:
|
|
|
|
loginfo['detail'] = str(loginfo['detail'])
|
|
|
|
if 'variable' not in loginfo or 'file' not in loginfo:
|
|
|
|
raise ValueError("record() missing variable or file.")
|
|
|
|
var = loginfo['variable']
|
|
|
|
|
|
|
|
if var not in self.variables:
|
|
|
|
self.variables[var] = []
|
|
|
|
self.variables[var].append(loginfo.copy())
|
|
|
|
|
|
|
|
def variable(self, var):
|
|
|
|
if var in self.variables:
|
|
|
|
return self.variables[var]
|
|
|
|
else:
|
|
|
|
return []
|
|
|
|
|
|
|
|
def emit(self, var, oval, val, o):
|
|
|
|
history = self.variable(var)
|
|
|
|
commentVal = re.sub('\n', '\n#', str(oval))
|
|
|
|
if history:
|
|
|
|
if len(history) == 1:
|
|
|
|
o.write("#\n# $%s\n" % var)
|
|
|
|
else:
|
|
|
|
o.write("#\n# $%s [%d operations]\n" % (var, len(history)))
|
|
|
|
for event in history:
|
|
|
|
# o.write("# %s\n" % str(event))
|
|
|
|
if 'func' in event:
|
|
|
|
# If we have a function listed, this is internal
|
|
|
|
# code, not an operation in a config file, and the
|
|
|
|
# full path is distracting.
|
|
|
|
event['file'] = re.sub('.*/', '', event['file'])
|
|
|
|
display_func = ' [%s]' % event['func']
|
|
|
|
else:
|
|
|
|
display_func = ''
|
|
|
|
if 'flag' in event:
|
|
|
|
flag = '[%s] ' % (event['flag'])
|
|
|
|
else:
|
|
|
|
flag = ''
|
|
|
|
o.write("# %s %s:%s%s\n# %s\"%s\"\n" % (event['op'], event['file'], event['line'], display_func, flag, re.sub('\n', '\n# ', event['detail'])))
|
|
|
|
if len(history) > 1:
|
|
|
|
o.write("# computed:\n")
|
|
|
|
o.write('# "%s"\n' % (commentVal))
|
|
|
|
else:
|
|
|
|
o.write("#\n# $%s\n# [no history recorded]\n#\n" % var)
|
|
|
|
o.write('# "%s"\n' % (commentVal))
|
|
|
|
|
2013-01-25 14:10:12 +00:00
|
|
|
def get_variable_files(self, var):
|
|
|
|
"""Get the files where operations are made on a variable"""
|
|
|
|
var_history = self.variable(var)
|
|
|
|
files = []
|
|
|
|
for event in var_history:
|
|
|
|
files.append(event['file'])
|
|
|
|
return files
|
|
|
|
|
|
|
|
def get_variable_lines(self, var, f):
|
|
|
|
"""Get the line where a operation is made on a variable in file f"""
|
|
|
|
var_history = self.variable(var)
|
|
|
|
lines = []
|
|
|
|
for event in var_history:
|
|
|
|
if f== event['file']:
|
|
|
|
line = event['line']
|
|
|
|
lines.append(line)
|
|
|
|
return lines
|
|
|
|
|
|
|
|
def del_var_history(self, var):
|
|
|
|
if var in self.variables:
|
|
|
|
self.variables[var] = []
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
|
2010-04-13 01:56:25 +00:00
|
|
|
class DataSmart(MutableMapping):
|
2006-11-16 15:02:15 +00:00
|
|
|
def __init__(self, special = COWDictBase.copy(), seen = COWDictBase.copy() ):
|
2005-08-31 10:47:56 +00:00
|
|
|
self.dict = {}
|
|
|
|
|
2013-01-18 11:45:22 +00:00
|
|
|
self.inchistory = IncludeHistory()
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
self.varhistory = VariableHistory(self)
|
|
|
|
self._tracking = False
|
2013-01-18 11:45:22 +00:00
|
|
|
|
2006-05-09 15:44:08 +00:00
|
|
|
# cookie monster tribute
|
2006-11-16 15:02:15 +00:00
|
|
|
self._special_values = special
|
|
|
|
self._seen_overrides = seen
|
|
|
|
|
|
|
|
self.expand_cache = {}
|
2006-05-09 15:44:08 +00:00
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
def enableTracking(self):
|
|
|
|
self._tracking = True
|
|
|
|
|
|
|
|
def disableTracking(self):
|
|
|
|
self._tracking = False
|
|
|
|
|
2010-08-25 13:26:37 +00:00
|
|
|
def expandWithRefs(self, s, varname):
|
2010-05-22 23:36:08 +00:00
|
|
|
|
2010-04-12 15:14:11 +00:00
|
|
|
if not isinstance(s, basestring): # sanity check
|
2010-08-25 13:26:37 +00:00
|
|
|
return VariableParse(varname, self, s)
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2006-11-16 15:02:15 +00:00
|
|
|
if varname and varname in self.expand_cache:
|
|
|
|
return self.expand_cache[varname]
|
|
|
|
|
2010-08-25 13:26:37 +00:00
|
|
|
varparse = VariableParse(varname, self)
|
|
|
|
|
2006-11-27 09:15:20 +00:00
|
|
|
while s.find('${') != -1:
|
2005-08-31 10:47:56 +00:00
|
|
|
olds = s
|
|
|
|
try:
|
2010-08-25 13:26:37 +00:00
|
|
|
s = __expand_var_regexp__.sub(varparse.var_sub, s)
|
|
|
|
s = __expand_python_regexp__.sub(varparse.python_sub, s)
|
2010-04-20 22:54:42 +00:00
|
|
|
if s == olds:
|
|
|
|
break
|
2011-02-23 13:13:31 +00:00
|
|
|
except ExpansionError:
|
2005-08-31 10:47:56 +00:00
|
|
|
raise
|
2012-12-14 12:33:01 +00:00
|
|
|
except bb.parse.SkipPackage:
|
|
|
|
raise
|
2011-02-23 13:13:31 +00:00
|
|
|
except Exception as exc:
|
|
|
|
raise ExpansionError(varname, s, exc)
|
2006-11-16 15:02:15 +00:00
|
|
|
|
2010-08-25 13:26:37 +00:00
|
|
|
varparse.value = s
|
|
|
|
|
2006-11-16 15:02:15 +00:00
|
|
|
if varname:
|
2010-08-25 13:26:37 +00:00
|
|
|
self.expand_cache[varname] = varparse
|
|
|
|
|
|
|
|
return varparse
|
2006-11-16 15:02:15 +00:00
|
|
|
|
2011-11-25 14:57:53 +00:00
|
|
|
def expand(self, s, varname = None):
|
2010-08-25 13:26:37 +00:00
|
|
|
return self.expandWithRefs(s, varname).value
|
2011-01-01 23:55:54 +00:00
|
|
|
|
2005-08-31 10:47:56 +00:00
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
def finalize(self, parent = False):
|
2010-04-08 22:43:47 +00:00
|
|
|
"""Performs final steps upon the datastore, including application of overrides"""
|
2010-04-21 23:47:10 +00:00
|
|
|
|
|
|
|
overrides = (self.getVar("OVERRIDES", True) or "").split(":") or []
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
finalize_caller = {
|
|
|
|
'op': 'finalize',
|
|
|
|
}
|
|
|
|
infer_caller_details(finalize_caller, parent = parent, varval = False)
|
2010-04-08 22:43:47 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Well let us see what breaks here. We used to iterate
|
|
|
|
# over each variable and apply the override and then
|
|
|
|
# do the line expanding.
|
|
|
|
# If we have bad luck - which we will have - the keys
|
|
|
|
# where in some order that is so important for this
|
|
|
|
# method which we don't have anymore.
|
|
|
|
# Anyway we will fix that and write test cases this
|
|
|
|
# time.
|
|
|
|
|
|
|
|
#
|
|
|
|
# First we apply all overrides
|
|
|
|
# Then we will handle _append and _prepend
|
|
|
|
#
|
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
# We only want to report finalization once per variable overridden.
|
|
|
|
finalizes_reported = {}
|
|
|
|
|
2010-04-08 22:43:47 +00:00
|
|
|
for o in overrides:
|
|
|
|
# calculate '_'+override
|
2010-04-21 23:47:10 +00:00
|
|
|
l = len(o) + 1
|
2010-04-08 22:43:47 +00:00
|
|
|
|
|
|
|
# see if one should even try
|
2010-04-12 00:03:55 +00:00
|
|
|
if o not in self._seen_overrides:
|
2010-04-08 22:43:47 +00:00
|
|
|
continue
|
|
|
|
|
2011-05-31 22:52:50 +00:00
|
|
|
vars = self._seen_overrides[o].copy()
|
2010-04-08 22:43:47 +00:00
|
|
|
for var in vars:
|
|
|
|
name = var[:-l]
|
|
|
|
try:
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
# Report only once, even if multiple changes.
|
|
|
|
if name not in finalizes_reported:
|
|
|
|
finalizes_reported[name] = True
|
|
|
|
finalize_caller['variable'] = name
|
|
|
|
finalize_caller['detail'] = 'was: ' + str(self.getVar(name, False))
|
|
|
|
self.varhistory.record(**finalize_caller)
|
|
|
|
# Copy history of the override over.
|
|
|
|
for event in self.varhistory.variable(var):
|
|
|
|
loginfo = event.copy()
|
|
|
|
loginfo['variable'] = name
|
|
|
|
loginfo['op'] = 'override[%s]:%s' % (o, loginfo['op'])
|
|
|
|
self.varhistory.record(**loginfo)
|
|
|
|
self.setVar(name, self.getVar(var, False), op = 'finalize', file = 'override[%s]' % o, line = '')
|
2011-05-31 22:52:50 +00:00
|
|
|
self.delVar(var)
|
2010-04-09 21:01:11 +00:00
|
|
|
except Exception:
|
2010-06-10 17:35:31 +00:00
|
|
|
logger.info("Untracked delVar")
|
2010-04-08 22:43:47 +00:00
|
|
|
|
|
|
|
# now on to the appends and prepends
|
2010-12-07 12:25:24 +00:00
|
|
|
for op in __setvar_keyword__:
|
|
|
|
if op in self._special_values:
|
|
|
|
appends = self._special_values[op] or []
|
|
|
|
for append in appends:
|
|
|
|
keep = []
|
|
|
|
for (a, o) in self.getVarFlag(append, op) or []:
|
2012-07-04 15:47:52 +00:00
|
|
|
match = True
|
|
|
|
if o:
|
|
|
|
for o2 in o.split("_"):
|
|
|
|
if not o2 in overrides:
|
|
|
|
match = False
|
|
|
|
if not match:
|
2010-12-07 12:25:24 +00:00
|
|
|
keep.append((a ,o))
|
|
|
|
continue
|
|
|
|
|
2011-03-16 15:07:37 +00:00
|
|
|
if op == "_append":
|
2010-12-07 12:25:24 +00:00
|
|
|
sval = self.getVar(append, False) or ""
|
|
|
|
sval += a
|
|
|
|
self.setVar(append, sval)
|
2011-03-16 15:07:37 +00:00
|
|
|
elif op == "_prepend":
|
2010-12-07 12:25:24 +00:00
|
|
|
sval = a + (self.getVar(append, False) or "")
|
|
|
|
self.setVar(append, sval)
|
|
|
|
|
|
|
|
# We save overrides that may be applied at some later stage
|
|
|
|
if keep:
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
self.setVarFlag(append, op, keep, ignore=True)
|
2010-12-07 12:25:24 +00:00
|
|
|
else:
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
self.delVarFlag(append, op, ignore=True)
|
2010-12-06 00:39:20 +00:00
|
|
|
|
2005-08-31 10:47:56 +00:00
|
|
|
def initVar(self, var):
|
2006-11-16 15:02:15 +00:00
|
|
|
self.expand_cache = {}
|
2005-08-31 10:47:56 +00:00
|
|
|
if not var in self.dict:
|
|
|
|
self.dict[var] = {}
|
|
|
|
|
2010-03-24 23:56:12 +00:00
|
|
|
def _findVar(self, var):
|
2010-04-21 17:57:17 +00:00
|
|
|
dest = self.dict
|
|
|
|
while dest:
|
|
|
|
if var in dest:
|
|
|
|
return dest[var]
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-04-21 17:57:17 +00:00
|
|
|
if "_data" not in dest:
|
2005-08-31 10:47:56 +00:00
|
|
|
break
|
2010-04-21 17:57:17 +00:00
|
|
|
dest = dest["_data"]
|
2005-08-31 10:47:56 +00:00
|
|
|
|
|
|
|
def _makeShadowCopy(self, var):
|
|
|
|
if var in self.dict:
|
|
|
|
return
|
|
|
|
|
|
|
|
local_var = self._findVar(var)
|
|
|
|
|
|
|
|
if local_var:
|
|
|
|
self.dict[var] = copy.copy(local_var)
|
|
|
|
else:
|
|
|
|
self.initVar(var)
|
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
|
|
|
|
def setVar(self, var, value, **loginfo):
|
2013-01-25 14:10:12 +00:00
|
|
|
#print("var=" + str(var) + " val=" + str(value))
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
if 'op' not in loginfo:
|
|
|
|
loginfo['op'] = "set"
|
2006-11-16 15:02:15 +00:00
|
|
|
self.expand_cache = {}
|
2005-08-31 10:47:56 +00:00
|
|
|
match = __setvar_regexp__.match(var)
|
|
|
|
if match and match.group("keyword") in __setvar_keyword__:
|
|
|
|
base = match.group('base')
|
|
|
|
keyword = match.group("keyword")
|
|
|
|
override = match.group('add')
|
|
|
|
l = self.getVarFlag(base, keyword) or []
|
|
|
|
l.append([value, override])
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
self.setVarFlag(base, keyword, l, ignore=True)
|
|
|
|
# And cause that to be recorded:
|
|
|
|
loginfo['detail'] = value
|
|
|
|
loginfo['variable'] = base
|
|
|
|
if override:
|
|
|
|
loginfo['op'] = '%s[%s]' % (keyword, override)
|
|
|
|
else:
|
|
|
|
loginfo['op'] = keyword
|
|
|
|
self.varhistory.record(**loginfo)
|
2006-11-16 15:02:15 +00:00
|
|
|
# todo make sure keyword is not __doc__ or __module__
|
2006-05-09 15:44:08 +00:00
|
|
|
# pay the cookie monster
|
|
|
|
try:
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
self._special_values[keyword].add(base)
|
2010-04-09 21:01:11 +00:00
|
|
|
except KeyError:
|
2009-05-12 15:53:22 +00:00
|
|
|
self._special_values[keyword] = set()
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
self._special_values[keyword].add(base)
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2005-08-31 10:47:56 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
if not var in self.dict:
|
|
|
|
self._makeShadowCopy(var)
|
|
|
|
|
2006-05-09 15:44:08 +00:00
|
|
|
# more cookies for the cookie monster
|
|
|
|
if '_' in var:
|
2013-06-21 11:31:32 +00:00
|
|
|
self._setvar_update_overrides(var)
|
2006-05-09 15:44:08 +00:00
|
|
|
|
2005-08-31 10:47:56 +00:00
|
|
|
# setting var
|
2012-08-21 16:16:25 +00:00
|
|
|
self.dict[var]["_content"] = value
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
self.varhistory.record(**loginfo)
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2013-06-21 11:31:32 +00:00
|
|
|
def _setvar_update_overrides(self, var):
|
|
|
|
# aka pay the cookie monster
|
|
|
|
override = var[var.rfind('_')+1:]
|
|
|
|
if len(override) > 0:
|
|
|
|
if override not in self._seen_overrides:
|
|
|
|
self._seen_overrides[override] = set()
|
|
|
|
self._seen_overrides[override].add( var )
|
|
|
|
|
2011-07-05 10:02:04 +00:00
|
|
|
def getVar(self, var, expand=False, noweakdefault=False):
|
2012-08-21 16:16:25 +00:00
|
|
|
value = self.getVarFlag(var, "_content", False, noweakdefault)
|
2011-08-29 07:33:58 +00:00
|
|
|
|
|
|
|
# Call expand() separately to make use of the expand cache
|
|
|
|
if expand and value:
|
|
|
|
return self.expand(value, var)
|
|
|
|
return value
|
2005-08-31 10:47:56 +00:00
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
def renameVar(self, key, newkey, **loginfo):
|
2007-08-16 09:55:21 +00:00
|
|
|
"""
|
2010-03-24 23:56:12 +00:00
|
|
|
Rename the variable key to newkey
|
2007-08-16 09:55:21 +00:00
|
|
|
"""
|
|
|
|
val = self.getVar(key, 0)
|
2009-12-15 22:13:52 +00:00
|
|
|
if val is not None:
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
loginfo['variable'] = newkey
|
|
|
|
loginfo['op'] = 'rename from %s' % key
|
|
|
|
loginfo['detail'] = val
|
|
|
|
self.varhistory.record(**loginfo)
|
|
|
|
self.setVar(newkey, val, ignore=True)
|
2007-08-16 09:55:21 +00:00
|
|
|
|
|
|
|
for i in ('_append', '_prepend'):
|
2009-12-15 22:13:52 +00:00
|
|
|
src = self.getVarFlag(key, i)
|
|
|
|
if src is None:
|
|
|
|
continue
|
|
|
|
|
2007-08-16 09:55:21 +00:00
|
|
|
dest = self.getVarFlag(newkey, i) or []
|
|
|
|
dest.extend(src)
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
self.setVarFlag(newkey, i, dest, ignore=True)
|
2010-03-24 23:56:12 +00:00
|
|
|
|
2010-04-12 00:03:55 +00:00
|
|
|
if i in self._special_values and key in self._special_values[i]:
|
2007-08-16 09:55:21 +00:00
|
|
|
self._special_values[i].remove(key)
|
|
|
|
self._special_values[i].add(newkey)
|
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
loginfo['variable'] = key
|
|
|
|
loginfo['op'] = 'rename (to)'
|
|
|
|
loginfo['detail'] = newkey
|
|
|
|
self.varhistory.record(**loginfo)
|
|
|
|
self.delVar(key, ignore=True)
|
|
|
|
|
|
|
|
def appendVar(self, var, value, **loginfo):
|
|
|
|
loginfo['op'] = 'append'
|
|
|
|
self.varhistory.record(**loginfo)
|
|
|
|
newvalue = (self.getVar(var, False) or "") + value
|
|
|
|
self.setVar(var, newvalue, ignore=True)
|
|
|
|
|
|
|
|
def prependVar(self, var, value, **loginfo):
|
|
|
|
loginfo['op'] = 'prepend'
|
|
|
|
self.varhistory.record(**loginfo)
|
|
|
|
newvalue = value + (self.getVar(var, False) or "")
|
|
|
|
self.setVar(var, newvalue, ignore=True)
|
|
|
|
|
|
|
|
def delVar(self, var, **loginfo):
|
|
|
|
loginfo['detail'] = ""
|
|
|
|
loginfo['op'] = 'del'
|
|
|
|
self.varhistory.record(**loginfo)
|
2006-11-16 15:02:15 +00:00
|
|
|
self.expand_cache = {}
|
2005-08-31 10:47:56 +00:00
|
|
|
self.dict[var] = {}
|
2011-06-17 16:34:52 +00:00
|
|
|
if '_' in var:
|
|
|
|
override = var[var.rfind('_')+1:]
|
|
|
|
if override and override in self._seen_overrides and var in self._seen_overrides[override]:
|
|
|
|
self._seen_overrides[override].remove(var)
|
2005-08-31 10:47:56 +00:00
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
def setVarFlag(self, var, flag, value, **loginfo):
|
|
|
|
if 'op' not in loginfo:
|
|
|
|
loginfo['op'] = "set"
|
|
|
|
loginfo['flag'] = flag
|
|
|
|
self.varhistory.record(**loginfo)
|
2005-08-31 10:47:56 +00:00
|
|
|
if not var in self.dict:
|
|
|
|
self._makeShadowCopy(var)
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
self.dict[var][flag] = value
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2013-06-21 11:31:32 +00:00
|
|
|
if flag == "defaultval" and '_' in var:
|
|
|
|
self._setvar_update_overrides(var)
|
|
|
|
|
2011-07-05 10:02:04 +00:00
|
|
|
def getVarFlag(self, var, flag, expand=False, noweakdefault=False):
|
2005-08-31 10:47:56 +00:00
|
|
|
local_var = self._findVar(var)
|
2010-12-10 15:30:30 +00:00
|
|
|
value = None
|
2005-08-31 10:47:56 +00:00
|
|
|
if local_var:
|
|
|
|
if flag in local_var:
|
2010-12-10 15:30:30 +00:00
|
|
|
value = copy.copy(local_var[flag])
|
2012-08-21 16:16:25 +00:00
|
|
|
elif flag == "_content" and "defaultval" in local_var and not noweakdefault:
|
2011-02-23 11:48:01 +00:00
|
|
|
value = copy.copy(local_var["defaultval"])
|
2010-12-10 01:14:48 +00:00
|
|
|
if expand and value:
|
2010-12-10 15:30:30 +00:00
|
|
|
value = self.expand(value, None)
|
|
|
|
return value
|
2005-08-31 10:47:56 +00:00
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
def delVarFlag(self, var, flag, **loginfo):
|
2005-08-31 10:47:56 +00:00
|
|
|
local_var = self._findVar(var)
|
|
|
|
if not local_var:
|
|
|
|
return
|
|
|
|
if not var in self.dict:
|
|
|
|
self._makeShadowCopy(var)
|
|
|
|
|
|
|
|
if var in self.dict and flag in self.dict[var]:
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
loginfo['detail'] = ""
|
|
|
|
loginfo['op'] = 'delFlag'
|
|
|
|
loginfo['flag'] = flag
|
|
|
|
self.varhistory.record(**loginfo)
|
2011-11-08 18:02:15 +00:00
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
del self.dict[var][flag]
|
2011-11-08 18:02:15 +00:00
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
def appendVarFlag(self, var, flag, value, **loginfo):
|
|
|
|
loginfo['op'] = 'append'
|
|
|
|
loginfo['flag'] = flag
|
|
|
|
self.varhistory.record(**loginfo)
|
|
|
|
newvalue = (self.getVarFlag(var, flag, False) or "") + value
|
|
|
|
self.setVarFlag(var, flag, newvalue, ignore=True)
|
|
|
|
|
|
|
|
def prependVarFlag(self, var, flag, value, **loginfo):
|
|
|
|
loginfo['op'] = 'prepend'
|
|
|
|
loginfo['flag'] = flag
|
|
|
|
self.varhistory.record(**loginfo)
|
|
|
|
newvalue = value + (self.getVarFlag(var, flag, False) or "")
|
|
|
|
self.setVarFlag(var, flag, newvalue, ignore=True)
|
|
|
|
|
|
|
|
def setVarFlags(self, var, flags, **loginfo):
|
|
|
|
infer_caller_details(loginfo)
|
2005-08-31 10:47:56 +00:00
|
|
|
if not var in self.dict:
|
|
|
|
self._makeShadowCopy(var)
|
|
|
|
|
2009-06-11 20:10:04 +00:00
|
|
|
for i in flags:
|
2012-08-21 16:16:25 +00:00
|
|
|
if i == "_content":
|
2005-08-31 10:47:56 +00:00
|
|
|
continue
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
loginfo['flag'] = i
|
|
|
|
loginfo['detail'] = flags[i]
|
|
|
|
self.varhistory.record(**loginfo)
|
2005-08-31 10:47:56 +00:00
|
|
|
self.dict[var][i] = flags[i]
|
|
|
|
|
2010-03-24 23:56:12 +00:00
|
|
|
def getVarFlags(self, var):
|
2005-08-31 10:47:56 +00:00
|
|
|
local_var = self._findVar(var)
|
|
|
|
flags = {}
|
|
|
|
|
|
|
|
if local_var:
|
2009-06-11 20:10:04 +00:00
|
|
|
for i in local_var:
|
2012-08-21 16:16:26 +00:00
|
|
|
if i.startswith("_"):
|
2005-08-31 10:47:56 +00:00
|
|
|
continue
|
2008-03-03 22:01:45 +00:00
|
|
|
flags[i] = local_var[i]
|
2005-08-31 10:47:56 +00:00
|
|
|
|
|
|
|
if len(flags) == 0:
|
|
|
|
return None
|
|
|
|
return flags
|
|
|
|
|
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
def delVarFlags(self, var, **loginfo):
|
2005-08-31 10:47:56 +00:00
|
|
|
if not var in self.dict:
|
|
|
|
self._makeShadowCopy(var)
|
|
|
|
|
|
|
|
if var in self.dict:
|
|
|
|
content = None
|
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
loginfo['op'] = 'delete flags'
|
|
|
|
self.varhistory.record(**loginfo)
|
|
|
|
|
2005-08-31 10:47:56 +00:00
|
|
|
# try to save the content
|
2012-08-21 16:16:25 +00:00
|
|
|
if "_content" in self.dict[var]:
|
|
|
|
content = self.dict[var]["_content"]
|
2005-08-31 10:47:56 +00:00
|
|
|
self.dict[var] = {}
|
2012-08-21 16:16:25 +00:00
|
|
|
self.dict[var]["_content"] = content
|
2005-08-31 10:47:56 +00:00
|
|
|
else:
|
|
|
|
del self.dict[var]
|
|
|
|
|
|
|
|
|
|
|
|
def createCopy(self):
|
|
|
|
"""
|
|
|
|
Create a copy of self by setting _data to self
|
|
|
|
"""
|
|
|
|
# we really want this to be a DataSmart...
|
2006-11-16 15:02:15 +00:00
|
|
|
data = DataSmart(seen=self._seen_overrides.copy(), special=self._special_values.copy())
|
2005-08-31 10:47:56 +00:00
|
|
|
data.dict["_data"] = self.dict
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
data.varhistory = self.varhistory.copy()
|
|
|
|
data.varhistory.datasmart = data
|
2013-01-18 11:45:22 +00:00
|
|
|
data.inchistory = self.inchistory.copy()
|
2005-08-31 10:47:56 +00:00
|
|
|
|
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 <peter.seebach@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18 11:47:34 +00:00
|
|
|
data._tracking = self._tracking
|
|
|
|
|
2005-08-31 10:47:56 +00:00
|
|
|
return data
|
|
|
|
|
2010-12-17 19:15:48 +00:00
|
|
|
def expandVarref(self, variable, parents=False):
|
|
|
|
"""Find all references to variable in the data and expand it
|
|
|
|
in place, optionally descending to parent datastores."""
|
|
|
|
|
|
|
|
if parents:
|
|
|
|
keys = iter(self)
|
|
|
|
else:
|
|
|
|
keys = self.localkeys()
|
|
|
|
|
|
|
|
ref = '${%s}' % variable
|
|
|
|
value = self.getVar(variable, False)
|
|
|
|
for key in keys:
|
|
|
|
referrervalue = self.getVar(key, False)
|
2011-01-01 23:55:54 +00:00
|
|
|
if referrervalue and ref in referrervalue:
|
2010-12-17 19:15:48 +00:00
|
|
|
self.setVar(key, referrervalue.replace(ref, value))
|
|
|
|
|
|
|
|
def localkeys(self):
|
|
|
|
for key in self.dict:
|
|
|
|
if key != '_data':
|
|
|
|
yield key
|
|
|
|
|
2010-04-13 01:56:25 +00:00
|
|
|
def __iter__(self):
|
2011-06-10 16:23:33 +00:00
|
|
|
def keylist(d):
|
|
|
|
klist = set()
|
|
|
|
for key in d:
|
|
|
|
if key == "_data":
|
|
|
|
continue
|
2011-06-17 16:32:21 +00:00
|
|
|
if not d[key]:
|
|
|
|
continue
|
2011-06-10 16:23:33 +00:00
|
|
|
klist.add(key)
|
|
|
|
|
2005-08-31 10:47:56 +00:00
|
|
|
if "_data" in d:
|
2011-06-10 16:23:33 +00:00
|
|
|
klist |= keylist(d["_data"])
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2011-06-10 16:23:33 +00:00
|
|
|
return klist
|
|
|
|
|
|
|
|
for k in keylist(self.dict):
|
|
|
|
yield k
|
2010-04-13 01:56:25 +00:00
|
|
|
|
|
|
|
def __len__(self):
|
|
|
|
return len(frozenset(self))
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-03-24 23:56:12 +00:00
|
|
|
def __getitem__(self, item):
|
2010-10-06 03:19:31 +00:00
|
|
|
value = self.getVar(item, False)
|
|
|
|
if value is None:
|
|
|
|
raise KeyError(item)
|
|
|
|
else:
|
|
|
|
return value
|
2005-08-31 10:47:56 +00:00
|
|
|
|
2010-04-13 01:56:25 +00:00
|
|
|
def __setitem__(self, var, value):
|
|
|
|
self.setVar(var, value)
|
|
|
|
|
|
|
|
def __delitem__(self, var):
|
|
|
|
self.delVar(var)
|
2012-02-23 13:47:13 +00:00
|
|
|
|
|
|
|
def get_hash(self):
|
2012-04-17 08:21:37 +00:00
|
|
|
data = {}
|
2012-11-29 10:29:06 +00:00
|
|
|
d = self.createCopy()
|
|
|
|
bb.data.expandKeys(d)
|
|
|
|
bb.data.update_data(d)
|
|
|
|
|
|
|
|
config_whitelist = set((d.getVar("BB_HASHCONFIG_WHITELIST", True) or "").split())
|
|
|
|
keys = set(key for key in iter(d) if not key.startswith("__"))
|
2012-02-23 13:47:13 +00:00
|
|
|
for key in keys:
|
2012-02-27 14:37:32 +00:00
|
|
|
if key in config_whitelist:
|
2012-02-23 13:47:13 +00:00
|
|
|
continue
|
2012-11-29 10:29:06 +00:00
|
|
|
value = d.getVar(key, False) or ""
|
2012-04-17 08:21:37 +00:00
|
|
|
data.update({key:value})
|
2012-02-23 13:47:13 +00:00
|
|
|
|
2013-06-20 20:53:14 +00:00
|
|
|
varflags = d.getVarFlags(key)
|
|
|
|
if not varflags:
|
|
|
|
continue
|
|
|
|
for f in varflags:
|
|
|
|
data.update({'%s[%s]' % (key, f):varflags[f]})
|
|
|
|
|
2013-05-03 14:37:17 +00:00
|
|
|
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":
|
|
|
|
for i in bb_list:
|
|
|
|
value = d.getVar(i, True) or ""
|
|
|
|
data.update({i:value})
|
|
|
|
|
2012-04-17 08:21:37 +00:00
|
|
|
data_str = str([(k, data[k]) for k in sorted(data.keys())])
|
|
|
|
return hashlib.md5(data_str).hexdigest()
|