updated to optionally display the text that describes a config option
authorMarc Fiuczynski <mef@cs.princeton.edu>
Thu, 30 Nov 2006 23:02:35 +0000 (23:02 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Thu, 30 Nov 2006 23:02:35 +0000 (23:02 +0000)
configs/kompare
configs/kread.py [new file with mode: 0755]

index 11df5e9..8fff7f8 100755 (executable)
@@ -5,17 +5,18 @@
 # Marc E. Fiuczynski <mef@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id: kompare,v 1.1 2006/11/30 16:41:09 mef Exp $
+# $Id: kompare,v 1.2 2006/11/30 17:07:03 mef Exp $
 #
 
 import sys, re, os
+import kread
 
 def process(file):
     ORDER = []
     CONFIGS = {}
     for line in file.readlines():
         iline = line.lower()
-        iline.strip()
+        iline = iline.strip()
         if len(iline)==0: continue
         firstchar = iline[0]
 
@@ -73,6 +74,9 @@ for key in keys:
     n = new[key]
     if n==o and not showall: continue
     print "%6s -> %6s : %s" % (newstate.get(o,o),newstate.get(n,n),key)
+    if not showall: continue
+    helptxt=kread.gethelp(key)
+    if helptxt<>'':print helptxt
 
 # not sure we care about what options have been removed
 # from from.config file
@@ -85,3 +89,4 @@ for key in keys:
     if n == -1 and not showall:
         print "%c -> %c : %s" % (oldstate[o],oldstate[n],key)
 
+
diff --git a/configs/kread.py b/configs/kread.py
new file mode 100755 (executable)
index 0000000..20bb3d8
--- /dev/null
@@ -0,0 +1,83 @@
+#!/bin/env python
+#
+# compare: a tool to compare kernel config files
+#
+# Marc E. Fiuczynski <mef@cs.princeton.edu>
+# Copyright (C) 2006 The Trustees of Princeton University
+#
+# $Id: kompare,v 1.2 2006/11/30 17:07:03 mef Exp $
+#
+
+import sys, re, os
+
+currentconfig = ""
+configs = {}
+
+def _config(parts,fb):
+    global currentconfig
+    currentconfig = parts[1]
+
+def _help(parts,fb):
+    global currentconfig
+    helptxt = ""
+    lineno = 0
+    while True:
+        line = fb.readline()
+        lineno = lineno + 1
+        if len(line)==0 or not line[0].isspace():break
+        if len(line)>1: line = line.lstrip()
+        helptxt = helptxt+line
+
+    configs[currentconfig]=helptxt
+
+def _source(parts,fb):
+    filename = "".join(parts[1:])
+    if filename[0]=='"' or filename[0]=='\'':
+        filename=filename[1:]
+    if filename[-1]=='"' or filename[-1]=='\'':
+        filename=filename[:-1]
+    process(filename)
+
+def _noop(parts,fb):
+    pass
+
+keywords = {"config":_config,
+            "help":_help,
+            "---help---":_help,
+            "source":_source,
+            "#":_noop}
+
+def process(filename):
+    fb = open(filename)
+    lineno = 0
+    while True:
+        line = fb.readline()
+        lineno = lineno + 1
+        if len(line)==0:break
+
+        line  = line.strip()
+        parts = line.split()
+        if len(parts)==0:continue
+
+        func  = keywords.get(parts[0],_noop)
+        func(parts,fb)
+
+    fb.close()
+
+def gethelp(option):
+    if option[:len("CONFIG_")] == "CONFIG_":
+        option=option[len("CONFIG_"):]
+    helptxt = configs.get(option,"")
+    return helptxt
+
+ARCH=os.getenv("ARCH","i386")
+process("arch/%s/Kconfig" % ARCH)
+
+if __name__ == '__main__':
+    if len(sys.argv) == 1:
+        print """USAGE\n%s configoptionname""" % os.path.basename(sys.argv[0])
+    else:
+        option = sys.argv[1]
+        helptxt = gethelp(option)
+        print "CONFIG_%s:\n%s" % (option,helptxt)
+