glfs/kernel-config/kernel-config.py

303 lines
8.3 KiB
Python
Raw Normal View History

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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
#!/usr/bin/env python3
# SPDX-License-Identifier: MIT
# Copyright 2023 The LFS Editors
# Stupid script to render "mconf"-style kernel configuration
# Usage: kernel-config.py [path to kernel tree] [needed config].toml
# The toml file should be like:
# for bool and tristate:
# EXT4="*"
# DRM="*M"
# EXPERT=" "
# DRM_I915="*M"
# for choice:
# HIGHMEM64G="X"
# an entry with comment:
# DRM_I915 = { value = " *M", comment = "for i915, crocus, or iris" }
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
choice_bit = 1 << 30
ind0 = 0
ind1 = 0
menu_id = 1
stack = []
if_stack = []
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
expand_var_mp = { 'SRCARCH': 'x86' }
main_dep = {}
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
def expand_var(s):
for k in expand_var_mp:
s = s.replace('$(' + k + ')', expand_var_mp[k])
return s
def pop_stack(cond):
global ind0, ind1, stack
assert(cond(stack[-1][0]))
s, i0, i1, _ = stack[-1]
stack = stack[:-1]
ind0 -= i0
ind1 -= i1
def pop_stack_while(cond):
while stack and cond(stack[-1][0]):
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
pop_stack(cond)
def cur_menu():
global stack
return stack[-1][3] if stack else 0
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
def cur_if():
global if_stack
return if_stack[-1][:] if if_stack else []
def clean_dep(d):
d = d.strip()
if d.endswith('=y') or d.endswith('=M'):
d = d[:-2]
elif d.endswith(' != ""'):
d = d[:-6]
return d
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
def parse_config(buf):
global ind0, ind1, stack, menu_id
is_choice = buf[0].strip() == 'choice'
is_menu = buf[0].startswith('menu') or is_choice
is_nonconfig_menu = buf[0].startswith('menu ') or is_choice
key = None if is_nonconfig_menu else buf[0].split()[1].strip()
title = buf[0][len('menu '):] if is_nonconfig_menu else None
deps = ['menu'] + cur_if()
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
klass = None
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
for line in buf[1:]:
line = line.strip()
if line.startswith('depends on '):
new_deps = line[len('depends on '):].split('&&')
deps += [clean_dep(x) for x in new_deps]
elif line.startswith('prompt'):
title = line[len('prompt '):]
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
else:
for prefix in ['tristate', 'bool', 'string']:
if line.startswith(prefix + ' '):
title = line[len(prefix) + 1:]
klass = prefix
elif line == prefix:
klass = prefix
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
elif line.startswith('def_' + prefix + ' '):
klass = prefix
else:
continue
if '"' in line:
tail = line[line.rfind('"') + 1:].strip()
if tail[:3] == 'if ':
deps += [clean_dep(x) for x in tail[3:].split('&&')]
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
pop_stack_while(lambda x: x not in deps)
menu_id += is_menu
internal_key = key or menu_id
if stack:
fa = stack[-1][0]
if fa == 'menu':
fa = cur_menu() & ~choice_bit
main_dep[internal_key] = fa
val = known_config.get(key)
comment = None
forced = None
if type(val) == dict:
comment = val.get('comment')
forced = val.get('forced')
val = val['value']
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
klass = klass or 'string'
if title:
title = title.strip().lstrip('"')
title = title[:title.find('"')]
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
if not val:
pass
elif klass == 'string':
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
val = '(' + val + ')'
else:
assert((val == 'X') == bool(cur_menu() & choice_bit))
if (val == 'X'):
val = '(X)'
else:
val = list(val)
val.sort()
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
for c in val:
if c not in 'M* ' or (c == 'M' and klass != 'tristate'):
raise Exception('unknown setting %s for %s' % (c, key))
bracket = None
if klass == 'tristate' and forced != '*' :
bracket = '{}' if forced else '<>'
else:
bracket = '--' if forced else '[]'
val = bracket[0] + '/'.join(val) + bracket[1]
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
arrow = ' --->' if is_menu else ''
r = [ind0, val, ind1, title, arrow, internal_key, cur_menu(), comment]
# Don't indent for untitled (internal) entries
x = 2 if title else 0
key = key or 'menu'
menu = (menu_id if is_menu else cur_menu())
menu |= choice_bit if is_choice else 0
stack_ent = (key, 2, 0, menu) if is_menu else (key, 0, x, menu)
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
ind0 += stack_ent[1]
ind1 += stack_ent[2]
stack += [stack_ent]
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
return r
def load_kconfig(file):
global ind0, ind1, stack, path, menu_id, if_stack
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
r = []
config_buf = []
with open(path + file) as f:
for line in f:
if config_buf:
if not (line.startswith('\t') or line.startswith(' ')):
r += [parse_config(config_buf)]
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
config_buf = []
else:
config_buf += [line]
continue
if line.startswith('source') or line.startswith('\tsource'):
sub = expand_var(line.strip().split()[1].strip('"'))
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
r += load_kconfig(sub)
elif line.startswith('config') or line.startswith('menu'):
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
config_buf = [line]
elif line.startswith('choice'):
config_buf = [line]
elif line.startswith('endmenu') or line.startswith('endchoice'):
pop_stack_while(lambda x: x != 'menu')
pop_stack(lambda x: x == 'menu')
elif line.startswith('if '):
line = line[3:]
top = cur_if()
top += [x.strip() for x in line.split("&&")]
if_stack += [top]
elif line.startswith('endif'):
if_stack = if_stack[:-1]
if config_buf:
r += [parse_config(config_buf)]
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
return r
known_config = {}
def escape(x):
return x.replace('<', '&lt;').replace('>', '&gt;')
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
from sys import argv
import tomllib
path = argv[1]
if path[-1] != '/':
path += '/'
with open(argv[2], 'rb') as f:
known_config = tomllib.load(f)
r = load_kconfig('Kconfig')
# Refcount all menus
index_ikey = {}
for i in reversed(range(len(r))):
index_ikey[r[i][5]] = i
for i in reversed(range(len(r))):
if r[i][1] != None:
key = r[i][5]
fa = main_dep.get(key)
if not fa:
continue
j = index_ikey[fa]
if type(fa) == int or not r[j][3]:
# The main dependency is a menu or untitled magic entry,
# just mark it used
r[j][1] = ''
if r[j][1] is None:
raise Exception('[%s] needs unselected [%s]' % (key, fa))
r = [i for i in r if i[1] != None and i[3]]
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
# Now we are going to pretty-print r
## Calculate the maximum value length for each menu
max_val_len = {}
for _, val, _, _, _, _, menu, _ in r:
x = max_val_len.get(menu) or 0
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
max_val_len[menu] = max(x, len(val))
## Output
max_line = 80
buf = []
done = [x[5] for x in r] + ['revision']
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
for i in known_config:
if i not in done:
raise Exception("%s seems not exist" % i)
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
sep = known_config.get('separate_toplevel_menu')
for i0, val, i1, title, arrow, key, menu, comment in r:
rem = max_line
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
if val:
val += (max_val_len[menu] - len(val)) * ' '
rem -= i0 + i1 + bool(val) + len(val)
line = i0 * ' ' + escape(val) + (i1 + bool(val)) * ' '
rem -= len(arrow)
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
if len(title) > rem:
title = title[:rem - 3] + '...'
b = title.lstrip('YyMmNnHh')
a = title[:len(title) - len(b)]
b0 = "<emphasis role='blue'>" + escape(b[0]) + "</emphasis>"
line += escape(a) + b0 + escape(b[1:]) + escape(arrow)
rem -= len(title)
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
key = ' [' + key + ']' if type(key) == str else ''
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
if len(key) <= rem:
line += (rem - len(key)) * ' ' + key
else:
key = '... ' + key
line += '\n' + ' ' * (max_line - len(key)) + key
if type(comment) == str:
comment = [comment]
if comment:
comment = '\n'.join([' ' * i0 + '# ' + line for line in comment])
buf += [escape(comment) + ':']
if not menu and buf:
buf += ['']
buf += [line.rstrip()]
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
from jinja2 import Template
t = Template('''<?xml version="1.0" encoding="ISO-8859-1"?>
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": 1. 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. 2. If a configuration option is given but it does not exist in Kconfig files, the script will abort immediately. This helps catching removed options. 3. The script also aborts immediately if a configuration option is illegal, for example setting an option to 'M' while it cannot be a module. 4. 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.
2023-07-29 23:48:10 +08:00
<!DOCTYPE note PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<!-- Automatically generated by kernel-config.py
DO NOT EDIT! -->
<screen{{ rev }}>{{ '\n'.join(buf) }}</screen>''')
rev = known_config.get('revision')
rev = ' revision="%s"' % rev if rev else ''
print(t.render(rev = rev, buf = buf))