diff mbox

[U-Boot,1/6] moveconfig: Support providing a path to the defconfig files

Message ID 20170515114736.17521-2-sjg@chromium.org
State Superseded
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass May 15, 2017, 11:47 a.m. UTC
It is convenient to provide the full patch to the defconfig files in some
situations, e.g. when the file was generated by a shell command (e.g.
'ls configs/zynq*').

Add support for this, and move the globbing code into a function with its
own documentation.

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

 tools/moveconfig.py | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

Comments

Masahiro Yamada May 19, 2017, 5:20 p.m. UTC | #1
>          if not matched:
> -            print >> sys.stderr, "warning: %s:%d: no defconfig matched '%s'" % \
> -                                                 (defconfigs_file, i + 1, line)
> -
> +            print >> sys.stderr, ("warning: %s:%d: no defconfig matched '%s'" %
> +                                  (defconfigs_file, i + 1, line))
>          defconfigs += matched
>
>      # use set() to drop multiple matching


This hunk is an unrelated/unneeded change.  Please drop.
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 2f674375fd..bacb2d9349 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -279,6 +279,24 @@  def get_make_cmd():
         sys.exit('GNU Make not found')
     return ret[0].rstrip()
 
+def get_matched_defconfig(line):
+    """Get the defconfig files that match a pattern
+
+    Args:
+        line: Path or filename to match, e.g. 'configs/snow_defconfig' or
+            'k2*_defconfig'. If no directory is provided, 'configs/' is
+            prepended
+
+    Returns:
+        a list of matching defconfig files
+    """
+    dirname = os.path.dirname(line)
+    if dirname:
+        pattern = line
+    else:
+        pattern = os.path.join('configs', line)
+    return glob.glob(pattern) + glob.glob(pattern + '_defconfig')
+
 def get_matched_defconfigs(defconfigs_file):
     """Get all the defconfig files that match the patterns in a file."""
     defconfigs = []
@@ -286,12 +304,10 @@  def get_matched_defconfigs(defconfigs_file):
         line = line.strip()
         if not line:
             continue # skip blank lines silently
-        pattern = os.path.join('configs', line)
-        matched = glob.glob(pattern) + glob.glob(pattern + '_defconfig')
+        matched = get_matched_defconfig(line)
         if not matched:
-            print >> sys.stderr, "warning: %s:%d: no defconfig matched '%s'" % \
-                                                 (defconfigs_file, i + 1, line)
-
+            print >> sys.stderr, ("warning: %s:%d: no defconfig matched '%s'" %
+                                  (defconfigs_file, i + 1, line))
         defconfigs += matched
 
     # use set() to drop multiple matching