trunk
Last change
on this file since 52c2f6a6 was 6043559, checked in by Xi Ruoyao <xry111@…>, 15 months ago |
Add kernel-config infrastructure
The kernel-config.py script takes a toml file containing a set of
kernel configuration key-value pairs. Then it parses the Kconfig files
in a kernel source tree and render the given configuration as a
LFS-style <screen> in a separate XML file. The XML file can be used in
the book with xinclude.
Some "features":
- The lines are limited to 80 columns.
If the text of the configuration option is too long, it will be
trimmed; if the symbolic name of the option cannot fit in this line,
a separate line will be used for it.
- If a configuration option is given but it does not exist in Kconfig
files, the script will abort immediately. This helps catching
removed options.
- The script also aborts immediately if a configuration option is
illegal, for example setting an option to 'M' while it cannot be a
module.
- The infrastructure is not wired into the main Makefile. It's because
not all editors have the latest kernel tree, and even if they do the
locations of the kernel tree are still different. To update the
generated XML files, use
"make -C kernel-config KERNEL_TREE=/sources/linux-x.y.z".
Backword incompatible change:
The script no longer outputs "CONFIG_" prefix for the symbolic name. It
really does not make too much sense to waste 7 characters here because
it's a common prefix for all options!
A limitation:
The script does not really validate the configuration. Generally
validating the configuration requires to solve the 3-CNF-SAT problem,
which is NP-complete.
|
-
Property mode
set to
100755
|
File size:
752 bytes
|
Line | |
---|
1 | #!/usr/bin/env python3
|
---|
2 |
|
---|
3 | def kernel_version(path):
|
---|
4 | version = None
|
---|
5 | patchlevel = None
|
---|
6 | sublevel = None
|
---|
7 |
|
---|
8 | with open(path + 'Makefile') as f:
|
---|
9 | for line in f:
|
---|
10 | if line.startswith('VERSION ='):
|
---|
11 | version = line[len('VERSION ='):].strip()
|
---|
12 | elif line.startswith('PATCHLEVEL ='):
|
---|
13 | patchlevel = line[len('PATCHLEVEL ='):].strip()
|
---|
14 | elif line.startswith('SUBLEVEL ='):
|
---|
15 | sublevel = line[len('SUBLEVEL ='):].strip()
|
---|
16 |
|
---|
17 | assert(version and patchlevel and sublevel)
|
---|
18 | return '.'.join([version, patchlevel, sublevel])
|
---|
19 |
|
---|
20 | if __name__ == '__main__':
|
---|
21 | from sys import argv
|
---|
22 |
|
---|
23 | path = argv[1]
|
---|
24 | if path[:-1] != '/':
|
---|
25 | path += '/'
|
---|
26 |
|
---|
27 | print(kernel_version(path))
|
---|
Note:
See
TracBrowser
for help on using the repository browser.