Commit 8639f69a61b47971dba47ab5ed72e47436729bb1

Authored by Simon Glass
1 parent ee3e520dad

genconfig.py: Print defconfig next to warnings

At present we sometimes see warnings of the form:

/tmp/tmpMA89kB:36: warning: overriding the value of CMD_SPL.
	Old value: "y", new value: "y".

This is not very useful as it does not show whch defconfig file it relates
to. Update the tool to show this.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 21 additions and 8 deletions Side-by-side Diff

tools/buildman/kconfiglib.py
... ... @@ -204,6 +204,7 @@
204 204  
205 205 self.print_warnings = print_warnings
206 206 self.print_undef_assign = print_undef_assign
  207 + self._warnings = []
207 208  
208 209 # For parsing routines that stop when finding a line belonging to a
209 210 # different construct, these holds that line and the tokenized version
210 211  
... ... @@ -398,8 +399,12 @@
398 399 need to refer to the top-level kernel directory with "$srctree".
399 400  
400 401 replace (default: True): True if the configuration should replace the
401   - old configuration; False if it should add to it."""
  402 + old configuration; False if it should add to it.
402 403  
  404 + Returns a list or warnings (hopefully empty)
  405 + """
  406 +
  407 + self._warnings = []
403 408 # Put this first so that a missing file doesn't screw up our state
404 409 filename = os.path.expandvars(filename)
405 410 line_feeder = _FileFeed(filename)
... ... @@ -449,7 +454,7 @@
449 454 while 1:
450 455 line = line_feeder.get_next()
451 456 if line is None:
452   - return
  457 + return self._warnings
453 458  
454 459 line = line.rstrip()
455 460  
456 461  
... ... @@ -1763,8 +1768,10 @@
1763 1768  
1764 1769 def _warn(self, msg, filename=None, linenr=None):
1765 1770 """For printing warnings to stderr."""
  1771 + msg = _build_msg("warning: " + msg, filename, linenr)
1766 1772 if self.print_warnings:
1767   - _stderr_msg("warning: " + msg, filename, linenr)
  1773 + sys.stderr.write(msg + "\n")
  1774 + self._warnings.append(msg)
1768 1775  
1769 1776 class Item(object):
1770 1777  
1771 1778  
... ... @@ -3369,10 +3376,13 @@
3369 3376 path = path[2:]
3370 3377 return path.rstrip("/")
3371 3378  
3372   -def _stderr_msg(msg, filename, linenr):
  3379 +def _build_msg(msg, filename, linenr):
3373 3380 if filename is not None:
3374   - sys.stderr.write("{0}:{1}: ".format(_clean_up_path(filename), linenr))
3375   - sys.stderr.write(msg + "\n")
  3381 + msg = "{0}:{1}: ".format(_clean_up_path(filename), linenr) + msg
  3382 + return msg
  3383 +
  3384 +def _stderr_msg(msg, filename, linenr):
  3385 + sys.stderr.write(_build_msg(msg, filename, linenr) + "\n")
3376 3386  
3377 3387 def _tokenization_error(s, filename, linenr):
3378 3388 loc = "" if filename is None else "{0}:{1}: ".format(filename, linenr)
tools/genboardscfg.py
... ... @@ -124,7 +124,7 @@
124 124 os.environ['srctree'] = os.getcwd()
125 125 os.environ['UBOOTVERSION'] = 'dummy'
126 126 os.environ['KCONFIG_OBJDIR'] = ''
127   - self._conf = kconfiglib.Config()
  127 + self._conf = kconfiglib.Config(print_warnings=False)
128 128  
129 129 def __del__(self):
130 130 """Delete a leftover temporary file before exit.
... ... @@ -166,7 +166,10 @@
166 166 else:
167 167 f.write(line[colon + 1:])
168 168  
169   - self._conf.load_config(self._tmpfile)
  169 + warnings = self._conf.load_config(self._tmpfile)
  170 + if warnings:
  171 + for warning in warnings:
  172 + print '%s: %s' % (defconfig, warning)
170 173  
171 174 try_remove(self._tmpfile)
172 175 self._tmpfile = None