Re: [PATCH] [ANNOUNCE] kconfig: Kconfiglib: a flexible PythonKconfig parser

From: Ulf Magnusson
Date: Tue Feb 01 2011 - 21:02:44 EST


On Tue, Feb 01, 2011 at 07:47:14PM -0500, Arnaud Lacombe wrote:
> Hi,
>
> On Tue, Feb 1, 2011 at 6:27 PM, Ulf Magnusson <ulfalizer.lkml@xxxxxxxxx> wrote:
> > Hi,
> >
> > This is the initial release of Kconfiglib: a Python library for
> > scripting, debugging, and extracting information from Kconfig-based
> > configuration systems. ÂIt can be used to programmatically generate a
> > .config when the '*conf' tools are too inflexible, to quickly find out
> > interesting information about a Kconfig configuration such as dependency
> > relations between symbols and where undefined symbols are referenced,
> > and in applications that need to parse and extract information from
> > Kconfig files.
> >
> Does that mean that when a kconfig-language change will happen, one
> will not only must have to be Lex/YaCC and C fluent, but also, perl
> and python ? That seem to be a lot of duplication to me.
>
> I'd rather see the backend be changed so that it could be used with
> SWIG to generate language bindings. I had WIP in this area, but
> changes needed are rather intrusive. That said, the testsuite might be
> interesting, I've been thinking about that for quite some time.
>
> - Arnaud
>
I originally experimented with patching the back end, but as you say the
changes would probably have to be very invasive/obfuscating in order to
extract all the information you can get out of Kconfiglib. So I instead
went the minimally invasive route with a completely stand-alone library
together with a test suite.

I'm willing to update Kconfiglib when future additions/modifications are
made to the Kconfig language so that all tests in the compatibility test
suite keep passing. I've added lots of comments and documentation to
internal methods and tried to keep the code clean and straightforward,
so it should be pretty easy for others to get into the code as well.

If by Perl you're referring to streamline_config.pl, I suspect it could
be rewritten as a smallish Kconfiglib script, though I haven't looked at
it closely. That version might also be much better at respecting symbol
dependencies.
> > For a much longer introduction including multiple examples, see
> > arch/kconfig/kconfiglib.py.
> >
> > Have fun!
> >
> > Signed-off-by: Ulf Magnusson <ulfalizer.lkml@xxxxxxxxx>
> > ---
> > Convenience links:
> >
> > Documentation, generated from kconfiglib.py with pydoc -w:
> > http://dl.dropbox.com/u/10406197/kconfiglib.html
> >
> > Examples as separate files:
> > http://dl.dropbox.com/u/10406197/kconfiglib-examples.tar.gz
> >
> >
> > The patch should be preferably be applied to a recent kernel, i.e. Linus's
> > (2.6.38-rc3 at the time of writing). ÂDue to recent Kconfig changes, the
> > kconfigtest.py test suite - which compares output character-for-character -
> > will indicate failure on older (a few months old) kernels versions even though
> > the outputs are functionally equivalent.
> >
> > ÂDocumentation/kbuild/kconfig-language.txt | Â Â5 +
> > ÂDocumentation/kbuild/kconfig.txt     Â|  Â8 +
> > ÂREADME Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â| Â 13 +
> > Âscripts/kconfig/Makefile         Â|  26 +-
> > Âscripts/kconfig/kconfiglib.py       | 3918 +++++++++++++++++++++++++++++
> > Âscripts/kconfig/kconfigtest.py      Â| Â396 +++
> > Â6 files changed, 4365 insertions(+), 1 deletions(-)
> > Âcreate mode 100644 scripts/kconfig/kconfiglib.py
> > Âcreate mode 100644 scripts/kconfig/kconfigtest.py
> > [...]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/