From 4da1025f86f1ce64d92ab4e31398bfc894eaca6e Mon Sep 17 00:00:00 2001 From: Marc Fiuczynski Date: Thu, 30 Nov 2006 23:02:35 +0000 Subject: [PATCH] updated to optionally display the text that describes a config option --- configs/kompare | 9 ++++-- configs/kread.py | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 2 deletions(-) create mode 100755 configs/kread.py diff --git a/configs/kompare b/configs/kompare index 11df5e98b..8fff7f82a 100755 --- a/configs/kompare +++ b/configs/kompare @@ -5,17 +5,18 @@ # Marc E. Fiuczynski # 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 index 000000000..20bb3d813 --- /dev/null +++ b/configs/kread.py @@ -0,0 +1,83 @@ +#!/bin/env python +# +# compare: a tool to compare kernel config files +# +# Marc E. Fiuczynski +# 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) + -- 2.43.0