From 8639f69a61b47971dba47ab5ed72e47436729bb1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 4 Aug 2017 03:30:30 -0600 Subject: 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 --- tools/buildman/kconfiglib.py | 22 ++++++++++++++++------ tools/genboardscfg.py | 7 +++++-- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'tools') diff --git a/tools/buildman/kconfiglib.py b/tools/buildman/kconfiglib.py index d28bbf0b49a..352ad438eed 100644 --- a/tools/buildman/kconfiglib.py +++ b/tools/buildman/kconfiglib.py @@ -204,6 +204,7 @@ class Config(object): self.print_warnings = print_warnings self.print_undef_assign = print_undef_assign + self._warnings = [] # For parsing routines that stop when finding a line belonging to a # different construct, these holds that line and the tokenized version @@ -398,8 +399,12 @@ class Config(object): need to refer to the top-level kernel directory with "$srctree". replace (default: True): True if the configuration should replace the - old configuration; False if it should add to it.""" + old configuration; False if it should add to it. + Returns a list or warnings (hopefully empty) + """ + + self._warnings = [] # Put this first so that a missing file doesn't screw up our state filename = os.path.expandvars(filename) line_feeder = _FileFeed(filename) @@ -449,7 +454,7 @@ class Config(object): while 1: line = line_feeder.get_next() if line is None: - return + return self._warnings line = line.rstrip() @@ -1763,8 +1768,10 @@ class Config(object): def _warn(self, msg, filename=None, linenr=None): """For printing warnings to stderr.""" + msg = _build_msg("warning: " + msg, filename, linenr) if self.print_warnings: - _stderr_msg("warning: " + msg, filename, linenr) + sys.stderr.write(msg + "\n") + self._warnings.append(msg) class Item(object): @@ -3369,10 +3376,13 @@ def _clean_up_path(path): path = path[2:] return path.rstrip("/") -def _stderr_msg(msg, filename, linenr): +def _build_msg(msg, filename, linenr): if filename is not None: - sys.stderr.write("{0}:{1}: ".format(_clean_up_path(filename), linenr)) - sys.stderr.write(msg + "\n") + msg = "{0}:{1}: ".format(_clean_up_path(filename), linenr) + msg + return msg + +def _stderr_msg(msg, filename, linenr): + sys.stderr.write(_build_msg(msg, filename, linenr) + "\n") def _tokenization_error(s, filename, linenr): loc = "" if filename is None else "{0}:{1}: ".format(filename, linenr) diff --git a/tools/genboardscfg.py b/tools/genboardscfg.py index 2e871feaf4f..2345a197984 100755 --- a/tools/genboardscfg.py +++ b/tools/genboardscfg.py @@ -124,7 +124,7 @@ class KconfigScanner: os.environ['srctree'] = os.getcwd() os.environ['UBOOTVERSION'] = 'dummy' os.environ['KCONFIG_OBJDIR'] = '' - self._conf = kconfiglib.Config() + self._conf = kconfiglib.Config(print_warnings=False) def __del__(self): """Delete a leftover temporary file before exit. @@ -166,7 +166,10 @@ class KconfigScanner: else: f.write(line[colon + 1:]) - self._conf.load_config(self._tmpfile) + warnings = self._conf.load_config(self._tmpfile) + if warnings: + for warning in warnings: + print '%s: %s' % (defconfig, warning) try_remove(self._tmpfile) self._tmpfile = None -- cgit v1.2.3 From c79d18c4b40d10c0a95b56e51f4517aca4515364 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 13 Aug 2017 16:02:54 -0600 Subject: moveconfig: Use fd.write() instead of print >> Adjust this code so that it can work with Python 2 and 3. Fixes: d73fcb1 (moveconfig: Support building a simple config database) Reported-by: Chris Packham Signed-off-by: Simon Glass --- lib/libfdt/pylibfdt/libfdt.i | 2 ++ tools/moveconfig.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/lib/libfdt/pylibfdt/libfdt.i b/lib/libfdt/pylibfdt/libfdt.i index 3b11bb0c951..146f4b942aa 100644 --- a/lib/libfdt/pylibfdt/libfdt.i +++ b/lib/libfdt/pylibfdt/libfdt.i @@ -8,6 +8,8 @@ %module libfdt +%include + %{ #define SWIG_FILE_WITH_INIT #include "libfdt.h" diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 8a038501929..6f549a51c16 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -1877,10 +1877,10 @@ def main(): if options.build_db: with open(CONFIG_DATABASE, 'w') as fd: for defconfig, configs in config_db.iteritems(): - print >>fd, '%s' % defconfig + fd.write('%s\n' % defconfig) for config in sorted(configs.keys()): - print >>fd, ' %s=%s' % (config, configs[config]) - print >>fd + fd.write(' %s=%s\n' % (config, configs[config])) + fd.write('\n') if __name__ == '__main__': main() -- cgit v1.2.3 From e11aa602abd3e8007dfd3ed23ebb829101abcfec Mon Sep 17 00:00:00 2001 From: Chris Packham Date: Fri, 1 Sep 2017 20:57:53 +1200 Subject: patman: add support for omitting bouncing addresses Add support for reading a list of bouncing addresses from a in-tree file (doc/bounces) and from the ~/.patman config file. These addresses are stripped from the Cc list. Signed-off-by: Chris Packham Reviewed-by: Simon Glass Reviewed-by: Philipp Tomsich > --- doc/bounces | 3 +++ tools/patman/README | 12 ++++++++++++ tools/patman/series.py | 5 +++++ tools/patman/settings.py | 18 ++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 doc/bounces (limited to 'tools') diff --git a/doc/bounces b/doc/bounces new file mode 100644 index 00000000000..d1c5f0d246e --- /dev/null +++ b/doc/bounces @@ -0,0 +1,3 @@ +# List of addresses picked up by patman/get_maintainer.pl that are known to +# bounce. Addresses are listed one per line and need to match the author +# information recorded in git. diff --git a/tools/patman/README b/tools/patman/README index e36857dedea..8582ed6ba12 100644 --- a/tools/patman/README +++ b/tools/patman/README @@ -84,6 +84,18 @@ Aliases are recursive. The checkpatch.pl in the U-Boot tools/ subdirectory will be located and used. Failing that you can put it into your path or ~/bin/checkpatch.pl +If you want to avoid sending patches to email addresses that are picked up +by patman but are known to bounce you can add a [bounces] section to your +.patman file. Unlike the [alias] section these are simple key: value pairs +that are not recursive. + +>>> + +[bounces] +gonefishing: Fred Bloggs + +<<< + If you want to change the defaults for patman's command-line arguments, you can add a [settings] section to your .patman file. This can be used diff --git a/tools/patman/series.py b/tools/patman/series.py index d3947a7c2ac..73ee3944861 100644 --- a/tools/patman/series.py +++ b/tools/patman/series.py @@ -10,6 +10,7 @@ import os import get_maintainer import gitutil +import settings import terminal # Series-xxx tags that we understand @@ -218,6 +219,7 @@ class Series(dict): Return: Filename of temp file created """ + col = terminal.Color() # Look for commit tags (of the form 'xxx:' at the start of the subject) fname = '/tmp/patman.%d' % os.getpid() fd = open(fname, 'w') @@ -233,6 +235,9 @@ class Series(dict): cc += add_maintainers elif add_maintainers: cc += get_maintainer.GetMaintainer(commit.patch) + for x in set(cc) & set(settings.bounces): + print(col.Color(col.YELLOW, 'Skipping "%s"' % x)) + cc = set(cc) - set(settings.bounces) cc = [m.encode('utf-8') if type(m) != str else m for m in cc] all_ccs += cc print(commit.patch, ', '.join(set(cc)), file=fd) diff --git a/tools/patman/settings.py b/tools/patman/settings.py index 5f207f5ef1c..d735ff9ba3c 100644 --- a/tools/patman/settings.py +++ b/tools/patman/settings.py @@ -269,6 +269,19 @@ def _ReadAliasFile(fname): if bad_line: print(bad_line) +def _ReadBouncesFile(fname): + """Read in the bounces file if it exists + + Args: + fname: Filename to read. + """ + if os.path.exists(fname): + with open(fname) as fd: + for line in fd: + if line.startswith('#'): + continue + bounces.add(line.strip()) + def Setup(parser, project_name, config_fname=''): """Set up the settings module by reading config files. @@ -293,10 +306,15 @@ def Setup(parser, project_name, config_fname=''): for name, value in config.items('alias'): alias[name] = value.split(',') + _ReadBouncesFile('doc/bounces') + for name, value in config.items('bounces'): + bounces.add(value) + _UpdateDefaults(parser, config) # These are the aliases we understand, indexed by alias. Each member is a list. alias = {} +bounces = set() if __name__ == "__main__": import doctest -- cgit v1.2.3