Bug 1360764 - Record warnings seen during the current operation; r?froydnj
Currently, the build monitor has a single compiler warnings database
that unions warnings from previous runs with warnings from the current
invocation. I want to introduce functionality that treats warnings
seen during the current invocation differently from "all warnings."
To facilitate this, this commit introduces a 2nd, non-persisted
warnings database to record warnings just for the current invocation.
MozReview-Commit-ID: FIY0GiarDmr
--- a/python/mozbuild/mozbuild/compilation/warnings.py
+++ b/python/mozbuild/mozbuild/compilation/warnings.py
@@ -53,16 +53,22 @@ class CompilerWarning(dict):
dict.__init__(self)
self['filename'] = None
self['line'] = None
self['column'] = None
self['message'] = None
self['flag'] = None
+ def copy(self):
+ """Returns a copy of this compiler warning."""
+ w = CompilerWarning()
+ w.update(self)
+ return w
+
# Since we inherit from dict, functools.total_ordering gets confused.
# Thus, we define a key function, a generic comparison, and then
# implement all the rich operators with those; approach is from:
# http://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/
def _cmpkey(self):
return (self['filename'], self['line'], self['column'])
def _compare(self, other, func):
--- a/python/mozbuild/mozbuild/controller/building.py
+++ b/python/mozbuild/mozbuild/controller/building.py
@@ -167,24 +167,30 @@ class BuildMonitor(MozbuildObject):
self.warnings_database = WarningsDatabase()
if os.path.exists(warnings_path):
try:
self.warnings_database.load_from_file(warnings_path)
except ValueError:
os.remove(warnings_path)
+ # Contains warnings unique to this invocation. Not populated with old
+ # warnings.
+ self.instance_warnings = WarningsDatabase()
+
def on_warning(warning):
filename = warning['filename']
if not os.path.exists(filename):
raise Exception('Could not find file containing warning: %s' %
filename)
self.warnings_database.insert(warning)
+ # Make a copy so mutations don't impact other database.
+ self.instance_warnings.insert(warning.copy())
self._warnings_collector = WarningsCollector(on_warning,
objdir=self.topobjdir)
self.build_objects = []
def start(self):
"""Record the start of the build."""