From: "Chris Li" <lkml@chrisli.org>
To: "Takashi Iwai" <tiwai@suse.de>
Cc: "Giacomo A. Catenazzi" <cate@cateee.net>,
"Mauro Carvalho Chehab" <mchehab@infradead.org>,
"Steven Rostedt" <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org
Subject: Re: diet-kconfig: a script to trim unneeded kconfigs
Date: Fri, 19 Sep 2008 16:57:28 -0700 [thread overview]
Message-ID: <70318cbf0809191657l351f9770w1ad57c7a1888eb70@mail.gmail.com> (raw)
In-Reply-To: <70318cbf0809191655m89e4b4fo68c3693487afed98@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 331 bytes --]
On Fri, Sep 19, 2008 at 4:55 PM, Chris Li <lkml@chrisli.org> wrote:
> Incidentally, I wrote such a script as well. In 64 lines of python code.
> I attach the script in question in the mail. I use a approach very
> similar to yours. But I work around some of the nasty part.
Oops, I forget to attach the script. Here it is.
Chris
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: minmod.py --]
[-- Type: text/x-python-script; name=minmod.py, Size: 1739 bytes --]
#!/usr/bin/python
import re
import os
class Kbuild:
def __init__(self, root):
self.root = root
self.confs = {} # dict of lists
self.modules = {}
self.read_kbuild()
def all_kbuild(self):
cmd = 'find . '\
' -regex "%s/[a-z].*/\\(Makefile\\|Kbuild\\)"' \
' -not -regex ".*/\(' \
'arch\|Documents\|firmware\|scripts\|raid6test\)/.*"' \
% self.root
return os.popen(cmd).read().split()
def read_kbuild(self):
allfile = [open(f).read() for f in self.all_kbuild()]
data = "\n".join(allfile)
data = re.sub(r"(?m)^ifeq\s+\(\$\((CONFIG_\S+)\s*\),\s*m\).*",
r"obj-$(\1) \\", data)
data = re.sub(r"(?m)\\\n\s*|obj-m ", '', data)
all = re.findall( r"(?m)obj-\$\((CONFIG_\S+)\)\s*[:+]=(.*)", data)
self.data = data
for (conf, modules) in all:
mods = re.findall(r"(\S+)\.o", modules)
for m in mods:
m = re.sub("-","_",m)
#print conf, "->", m
self.confs.setdefault(conf, []).append(m)
self.modules.setdefault(m, []).append(conf)
def read_modules(self):
data = open("/proc/modules").read()
return re.findall(r"(?m)^\S+", data)
def test_module(self, m):
all, conf = m.group(0,1)
if conf in self.confs:
return "# %s is not set"%conf
return all
def filter(self, config):
#print self.data
for m in self.read_modules():
if not self.modules.has_key(m):
print m,": Uknown module, may be firemware?"
continue
for c in self.modules[m]:
if c in self.confs:
del self.confs[c]
data = open(config).read()
data = re.sub(r"(?m)^(CONFIG_\S+)=m", self.test_module, data)
out = config + ".min"
print "Writing new config to:", out
open(out, "w").write(data)
def main():
kbuild = Kbuild(".")
kbuild.filter(".config")
main()
next prev parent reply other threads:[~2008-09-19 23:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-16 23:55 Takashi Iwai
2008-09-18 14:01 ` Giacomo A. Catenazzi
2008-09-18 20:09 ` Takashi Iwai
2008-09-18 15:25 ` Mauro Carvalho Chehab
2008-09-18 15:43 ` Giacomo A. Catenazzi
2008-09-18 16:27 ` Mauro Carvalho Chehab
2008-09-19 9:12 ` Giacomo A. Catenazzi
2008-09-19 16:01 ` Takashi Iwai
2008-09-19 23:55 ` Chris Li
2008-09-19 23:57 ` Chris Li [this message]
2008-09-22 10:01 ` Takashi Iwai
2008-09-22 13:39 ` Giacomo A. Catenazzi
2008-09-22 15:41 ` Steven Rostedt
2008-09-22 15:50 ` Takashi Iwai
2008-09-22 19:25 ` Chris Li
2008-09-23 11:31 ` Takashi Iwai
2008-09-23 18:15 ` Chris Li
2008-09-23 18:50 ` Takashi Iwai
2008-09-23 19:40 ` Chris Li
2008-09-18 20:20 ` Takashi Iwai
2008-09-18 20:17 ` Takashi Iwai
2008-09-18 21:09 ` Valdis.Kletnieks
2008-09-18 22:14 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=70318cbf0809191657l351f9770w1ad57c7a1888eb70@mail.gmail.com \
--to=lkml@chrisli.org \
--cc=cate@cateee.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®