summaryrefslogtreecommitdiff
path: root/README.md
blob: 89cabf79ccb98bbc572f2e4a2af30b69b83a0e2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Kconfiglib #

A Python library for doing stuff with Kconfig-based configuration systems. Can
extract information, query and set symbol values, and read and write
<i>.config</i> files. Highly compatible with the <i>scripts/kconfig/\*conf</i>
utilities in the kernel, usually invoked via make targets such as
<i>menuconfig</i> and <i>defconfig</i>.

**Update: Mar 13 2015**

Thanks to a patch from Philip Craig (https://github.com/philipc) that adds support
for the new `allnoconfig_y` option (which sets the user value of certain symbols
to `y` during `make allnoconfig` to improve coverage) and fixes an obscure issue
with `comment`s inside `choice`s (that didn't affect correctness but made outputs
differ) the testsuite now passes with Linux v4.0-rc3. Very little seems to have
changed in the C implementation over the past years, which makes me happy. :)

Despite the warnings, modules *are* supported by the way (otherwise tests would break
horribly). The warnings are related to `option modules`, which lets you select which
symbol serves as the `MODULES` symbol. (It's always `MODULES` in the kernel, and
older versions of the `Kconfig` files not set `option modules` on it -- hence the
warnings. With newer versions of the C implementation it's required.) I should add
support for `option modules` in a backwards-compatible way.

## Installation ##

Installation instructions for the Linux kernel (in the kernel root):

    $ git clone git://github.com/ulfalizer/Kconfiglib.git  
    $ git am Kconfiglib/makefile.patch

<i>(Note: The directory name Kconfiglib/ is significant.)</i>

In addition to creating a handy interface, the make targets are needed to pick
up environment variables set in the kernel makefiles which are referenced in
the Kconfig files (<i>ARCH</i>, <i>SRCARCH</i>, and <i>KERNELVERSION</i> as of
Linux v4.0-rc3).

Please tell me if the patch does not apply. It should be trivial to apply
manually.

## Documentation ##

The (extensive) documentation is generated by running

    $ pydoc kconfiglib

in the <i>Kconfiglib/</i> directory. For HTML output,
use

    $ pydoc -w kconfiglib

## Examples ##

The <i>examples/</i> directory contains simple example programs that make use
of Kconfiglib. See the documentation for how to run them.

## Test suite ##

The test suite is run with

    $ python Kconfiglib/testsuite.py

It comprises a set of selftests and a set of compatibility tests that compare
configurations generated by Kconfiglib with configurations generated by
<i>scripts/kconfig/conf</i> for a number of cases. You might want to use the
"speedy" option; see testsuite.py.

## Misc. notes ##

Please tell me if you miss some API instead of digging into internals. The
internal data structures and APIs, and dependency stuff in particular, are
unlikely to be exactly what you want as a user (hence why they're internal :).
Patches are welcome too of course. ;)

<b>Note</b>: To make the API more consistent and intuitive, some methods have been
renamed as follows:

<table>
  <tr><th>From                            </th><th>To                        </th></tr>
  <tr><td>Symbol.calc_value()             </td><td>Symbol.get_value()        </td></tr>
  <tr><td>Choice.calc_mode()              </td><td>Choice.get_mode()         </td></tr>
  <tr><td>Symbol.set_value()              </td><td>Symbol.set_user_value()   </td></tr>
  <tr><td>Choice.get_actual_items()       </td><td>Choice.get_symbols()      </td></tr>
  <tr><td>Symbol.is_choice_item()         </td><td>Symbol.is_choice_symbol() </td></tr>
  <tr><td>Symbol.reset()                  </td><td>Symbol.unset_user_value() </td></tr>
  <tr><td>Config.reset()                  </td><td>Config.unset_user_values()</td></tr>
  <tr><td>Menu.get_depends_on_visibility()</td><td>Menu.get_visibility()     </td></tr>
</table>


The test suite failures (should be the only ones) for the following Blackfin
defconfigs on e.g. Linux 3.7.0-rc8 are due to
[a bug in the C implementation](https://lkml.org/lkml/2012/12/5/458):

 * arch/blackfin/configs/CM-BF537U\_defconfig  
 * arch/blackfin/configs/BF548-EZKIT\_defconfig  
 * arch/blackfin/configs/BF527-EZKIT\_defconfig  
 * arch/blackfin/configs/BF527-EZKIT-V2\_defconfig  
 * arch/blackfin/configs/TCM-BF537\_defconfig

## License (ISC) ##

Copyright (c) 2011-2015, Ulf Magnusson <ulfalizer@gmail.com>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.