diff mbox

[U-Boot,2/3] moveconfig: Allow control of which implying configs are shown

Message ID 20170616033933.21607-3-sjg@chromium.org
State Accepted
Commit 9b2a2e87d2404dad62e4c2f350fd07324bfdadc3
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass June 16, 2017, 3:39 a.m. UTC
Sometimes it is useful to display CONFIG_TARGET or CONFIG_CMD configs. Add
an option to control this.

Also we generally ignore implying configs which affect fewer than 5
boards. But sometimes it is useful to show those those, so add an option
that reduces the minimum to two.

ERRATUM configs are never useful for implying things, so ignore those.

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

 tools/moveconfig.py | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

Comments

Simon Glass July 6, 2017, 2:51 p.m. UTC | #1
Sometimes it is useful to display CONFIG_TARGET or CONFIG_CMD configs. Add
an option to control this.

Also we generally ignore implying configs which affect fewer than 5
boards. But sometimes it is useful to show those those, so add an option
that reduces the minimum to two.

ERRATUM configs are never useful for implying things, so ignore those.

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

 tools/moveconfig.py | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 4295b47d7c..f9c16d484a 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -1466,7 +1466,15 @@  def move_config(configs, options, db_queue):
     slots.show_failed_boards()
     slots.show_suspicious_boards()
 
-def imply_config(config_list, find_superset=False):
+(IMPLY_MIN_2, IMPLY_TARGET, IMPLY_CMD) = (1, 2, 4)
+
+IMPLY_FLAGS = {
+    'min2': [IMPLY_MIN_2, 'Show options which imply >2 boards (normally >5)'],
+    'target': [IMPLY_TARGET, 'Allow CONFIG_TARGET_... options to imply'],
+    'cmd': [IMPLY_CMD, 'Allow CONFIG_CMD_... to imply'],
+};
+
+def do_imply_config(config_list, imply_flags, find_superset=False):
     """Find CONFIG options which imply those in the list
 
     Some CONFIG options can be implied by others and this can help to reduce
@@ -1491,6 +1499,8 @@  def imply_config(config_list, find_superset=False):
 
     Params:
         config_list: List of CONFIG options to check (each a string)
+        imply_flags: Flags which control which implying configs are allowed
+           (IMPLY_...)
         find_superset: True to look for configs which are a superset of those
             already found. So for example if CONFIG_EXYNOS5 implies an option,
             but CONFIG_EXYNOS covers a larger set of defconfigs and also
@@ -1551,8 +1561,14 @@  def imply_config(config_list, find_superset=False):
 
         # Look at every possible config, except the target one
         for imply_config in rest_configs:
-            if 'CONFIG_TARGET' in imply_config:
+            if 'ERRATUM' in imply_config:
                 continue
+            if not (imply_flags & IMPLY_CMD):
+                if 'CONFIG_CMD' in imply_config:
+                    continue
+            if not (imply_flags & IMPLY_TARGET):
+                if 'CONFIG_TARGET' in imply_config:
+                    continue
 
             # Find set of defconfigs that have this config
             imply_defconfig = defconfig_db[imply_config]
@@ -1599,7 +1615,7 @@  def imply_config(config_list, find_superset=False):
             num_common = len(imply_configs[config])
 
             # Don't bother if there are less than 5 defconfigs affected.
-            if num_common < 5:
+            if num_common < (2 if imply_flags & IMPLY_MIN_2 else 5):
                 continue
             missing = defconfigs - imply_configs[config]
             missing_str = ', '.join(missing) if missing else 'all'
@@ -1628,6 +1644,8 @@  def main():
                       "or '-' to read from stdin")
     parser.add_option('-i', '--imply', action='store_true', default=False,
                       help='find options which imply others')
+    parser.add_option('-I', '--imply-flags', type='string', default='',
+                      help="control the -i option ('help' for help")
     parser.add_option('-n', '--dry-run', action='store_true', default=False,
                       help='perform a trial run (show log with no changes)')
     parser.add_option('-e', '--exit-on-error', action='store_true',
@@ -1664,7 +1682,17 @@  def main():
     check_top_directory()
 
     if options.imply:
-        imply_config(configs)
+        imply_flags = 0
+        for flag in options.imply_flags.split():
+            if flag == 'help' or flag not in IMPLY_FLAGS:
+                print "Imply flags: (separate with ',')"
+                for name, info in IMPLY_FLAGS.iteritems():
+                    print ' %-15s: %s' % (name, info[1])
+                parser.print_usage()
+                sys.exit(1)
+            imply_flags |= IMPLY_FLAGS[flag][0]
+
+        do_imply_config(configs, imply_flags)
         return
 
     config_db = {}