Changeset 1417643


Ignore:
Timestamp:
07/31/2023 01:44:37 PM (11 months ago)
Author:
Xi Ruoyao <xry111@…>
Branches:
12.0, 12.1, ken/TL2024, ken/tuningfonts, lazarus, plabs/newcss, python3.11, rahul/power-profiles-daemon, renodr/vulkan-addition, trunk, xry111/llvm18
Children:
2fbed80
Parents:
08c3c25
git-author:
Xi Ruoyao <xry111@…> (07/31/2023 10:49:37 AM)
git-committer:
Xi Ruoyao <xry111@…> (07/31/2023 01:44:37 PM)
Message:

kernel-config: Update the script

  1. Don't throw unspecified entries too early. Doing so caused various rendering glitches. And we can now also check if an entry is selected but it's parent not.
  2. "menu"s in Kconfig can also have dependencies...

Some pre-existing .toml data files are found problematic after the
change, fix them and regenerate all rendered -kernel.xml files.

Files:
15 edited

Legend:

Unmodified
Added
Removed
  • kernel-config/kernel-config.py

    r08c3c25 r1417643  
    2525
    2626expand_var_mp = { 'SRCARCH': 'x86' }
     27main_dep = {}
    2728
    2829def expand_var(s):
     
    4041
    4142def pop_stack_while(cond):
    42     while len(stack) and cond(stack[-1][0]):
     43    while stack and cond(stack[-1][0]):
    4344        pop_stack(cond)
    4445
    4546def cur_menu():
    4647    global stack
    47     return stack[-1][3] if len(stack) else 0
     48    return stack[-1][3] if stack else 0
    4849
    4950def cur_if():
    5051    global if_stack
    51     return if_stack[-1] if len(if_stack) else []
     52    return if_stack[-1][:] if if_stack else []
    5253
    5354def clean_dep(d):
     
    6263    global ind0, ind1, stack, menu_id
    6364    is_menu = buf[0].startswith('menu')
    64     key = buf[0].split()[1].strip()
    65 
     65    is_nonconfig_menu = buf[0].startswith('menu ')
     66    key = None if is_nonconfig_menu else buf[0].split()[1].strip()
     67    title = buf[0][len('menu '):] if is_nonconfig_menu else None
    6668    deps = ['menu'] + cur_if()
    67     title = None
    6869    klass = None
     70
    6971    for line in buf[1:]:
    7072        line = line.strip()
     
    7274            new_deps = line[len('depends on '):].split('&&')
    7375            deps += [clean_dep(x) for x in new_deps]
     76        elif line.startswith('prompt'):
     77            title = line[len('prompt '):]
    7478        else:
    7579            for prefix in ['tristate', 'bool', 'string']:
     
    7781                    title = line[len(prefix) + 1:]
    7882                    klass = prefix
     83                elif line == prefix:
     84                    klass = prefix
    7985                elif line.startswith('def_' + prefix + ' '):
    8086                    klass = prefix
    81                 elif line.startswith('prompt '):
    82                     title = line[len('prompt '):]
     87                else:
     88                    continue
     89
     90                if '"' in line:
     91                    tail = line[line.rfind('"') + 1:].strip()
     92                    if tail[:3] == 'if ':
     93                        deps += [clean_dep(x) for x in tail[3:].split('&&')]
    8394
    8495    pop_stack_while(lambda x: x not in deps)
    8596
    86     if key not in known_config:
    87         return []
    88     val = known_config[key]
     97    menu_id += is_menu
     98    internal_key = key or menu_id
     99    if stack:
     100        fa = stack[-1][0]
     101        if fa == 'menu':
     102            fa = cur_menu() & ~choice_bit
     103        main_dep[internal_key] = fa
     104
     105    val = known_config.get(key)
    89106    comment = None
    90107    forced = None
     
    95112        val = val['value']
    96113
    97     assert(title and klass)
    98     title = title.strip().lstrip('"')
    99     title = title[:title.find('"')]
    100 
    101     if klass == 'string':
     114    klass = klass or 'string'
     115    if title:
     116        title = title.strip().lstrip('"')
     117        title = title[:title.find('"')]
     118
     119    if not val:
     120        pass
     121    elif klass == 'string':
    102122        val = '(' + val + ')'
    103123    else:
     
    120140
    121141    arrow = ' --->' if is_menu else ''
    122     r = [(ind0, val, ind1, title, arrow, key, cur_menu(), comment)]
    123     menu_id += is_menu
    124     stack_ent = (key, 2, 0, menu_id) if is_menu else (key, 0, 2, cur_menu())
     142    r = [ind0, val, ind1, title, arrow, internal_key, cur_menu(), comment]
     143
     144    # Don't indent for untitled (internal) entries
     145    x = 2 if title else 0
     146
     147    key = key or 'menu'
     148    stack_ent = (key, 2, 0, menu_id) if is_menu else (key, 0, x, cur_menu())
    125149    ind0 += stack_ent[1]
    126150    ind1 += stack_ent[2]
     
    136160        if line.startswith('prompt '):
    137161            title = line[len('prompt '):].strip().strip('"')
    138     r = [(ind0, "", ind1, title, ' --->', '', cur_menu(), None)]
     162
    139163    menu_id += 1
     164
     165    if stack:
     166        fa = stack[-1][0]
     167        if fa == 'menu':
     168            fa = cur_menu() & ~choice_bit
     169        main_dep[menu_id] = fa
     170
     171    r = [ind0, None, ind1, title, ' --->', menu_id, cur_menu(), None]
    140172    stack += [('menu', 2, 0, menu_id | choice_bit)]
    141173    ind0 += 2
     
    148180    with open(path + file) as f:
    149181        for line in f:
    150             if len(config_buf):
     182            if config_buf:
    151183                if not (line.startswith('\t') or line.startswith('    ')):
    152184                    if config_buf[0] == 'choice\n':
    153                         r += parse_choice(config_buf)
     185                        r += [parse_choice(config_buf)]
    154186                    else:
    155                         r += parse_config(config_buf)
     187                        r += [parse_config(config_buf)]
    156188                    config_buf = []
    157189                else:
     
    161193                sub = expand_var(line.strip().split()[1].strip('"'))
    162194                r += load_kconfig(sub)
    163             elif line.startswith('config') or line.startswith('menuconfig'):
     195            elif line.startswith('config') or line.startswith('menu'):
    164196                config_buf = [line]
    165197            elif line.startswith('choice'):
    166198                config_buf = [line]
    167             elif line.startswith("menu"):
    168                 title = expand_var(line[4:].strip().strip('"'))
    169                 r += [(ind0, "", ind1, title, ' --->', '', cur_menu(), None)]
    170                 menu_id += 1
    171                 stack += [('menu', 2, 0, menu_id)]
    172                 ind0 += 2
    173199            elif line.startswith('endmenu') or line.startswith('endchoice'):
    174200                pop_stack_while(lambda x: x != 'menu')
    175201                pop_stack(lambda x: x == 'menu')
    176                 if r[-1][1] == "":
    177                     # prune empty menu
    178                     r = r[:-1]
    179202            elif line.startswith('if '):
    180203                line = line[3:]
     
    197220    known_config = tomllib.load(f)
    198221
    199 r = load_kconfig("Kconfig")
     222r = load_kconfig('Kconfig')
     223
     224# Refcount all menus
     225
     226index_ikey = {}
     227for i in reversed(range(len(r))):
     228    index_ikey[r[i][5]] = i
     229
     230for i in reversed(range(len(r))):
     231    if r[i][1] is not None:
     232        key = r[i][5]
     233        fa = main_dep.get(key)
     234        if not fa:
     235            continue
     236        j = index_ikey[fa]
     237        if type(fa) == int:
     238            # The main dependency is a menu, just mark it used
     239            r[j][1] = ''
     240        if (r[j][1] is None) and r[j][3]:
     241            raise Exception('[%s] needs unselected [%s]' % (key, fa))
     242
     243r = [i for i in r if i[1] is not None]
    200244
    201245# Now we are going to pretty-print r
     
    204248max_val_len = {}
    205249for _, val, _, _, _, _, menu, _ in r:
    206     x = max_val_len[menu] if menu in max_val_len else 0
     250    x = max_val_len.get(menu) or 0
    207251    max_val_len[menu] = max(x, len(val))
    208252
     
    212256buf = []
    213257
    214 done = [x[5] for x in r]
     258done = [x[5] for x in r] + ['revision']
    215259for i in known_config:
    216260    if i not in done:
     
    230274    rem = max_line - len(line)
    231275
    232     if key:
    233         key = ' [' + key + ']'
     276    key = ' [' + key + ']' if type(key) == str else ''
    234277
    235278    if len(key) <= rem:
     
    238281        key = '... ' + key
    239282        line += '\n' + ' ' * (max_line - len(key)) + key
     283    if type(comment) == str:
     284        comment = [comment]
    240285    if comment:
    241         line = ' ' * i0 + '# ' + comment + ':\n' + line
     286        comment = '\n'.join([' ' * i0 + '# ' + line for line in comment])
     287        line = comment + ':\n' + line
    242288    buf += [line.replace('<', '&lt;').replace('>', '&gt;').rstrip()]
    243289
     
    245291kver = kernel_version.kernel_version(path)
    246292
    247 print('''<?xml version="1.0" encoding="ISO-8859-1"?>
     293from jinja2 import Template
     294
     295t = Template('''<?xml version="1.0" encoding="ISO-8859-1"?>
    248296<!DOCTYPE note PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
    249   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">''')
    250 print('<!-- Automatically generated by kernel-config.py')
    251 print('     DO NOT EDIT! -->')
    252 print('<screen><literal>' + '\n'.join(buf) + '</literal></screen>')
     297  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
     298<!-- Automatically generated by kernel-config.py
     299     DO NOT EDIT! -->
     300<screen{{ rev }}><literal>{{ '\n'.join(buf) }}</literal></screen>''')
     301
     302rev = known_config.get('revision')
     303rev = ' revision="%s"' % rev if rev else ''
     304print(t.render(rev = rev, buf = buf))
  • kernel-config/postlfs/filesystems/btrfs-progs-test.toml

    r08c3c25 r1417643  
     1BTRFS_FS='*M'
    12BTRFS_FS_POSIX_ACL='*'
    23REISERFS_FS='*M'
  • kernel-config/postlfs/filesystems/lvm2.toml

    r08c3c25 r1417643  
    11MD='*'
     2BLK_DEV='*'
    23BLK_DEV_DM='*M'
    34DM_CRYPT='*M'
  • kernel-config/postlfs/filesystems/uefi-bootloaders/grub-setup.toml

    r08c3c25 r1417643  
     1# forced by !EXPERT
     2BLOCK = { value = '*', forced = true }
    13EFI='*'
    24PARTITION_ADVANCED='* '
  • kernel-config/postlfs/virtualization/qemu-bridge.toml

    r08c3c25 r1417643  
    22BRIDGE='*M'
    33NETDEVICES='*'
     4NET_CORE='*'
    45TUN='*M'
  • kernel-config/x/installing/libevdev-test.toml

    r08c3c25 r1417643  
    11INPUT_MISC="*"
    22INPUT_UINPUT="*M"
     3INPUT = { value = '*', forced = '*' }
  • postlfs/filesystems/btrfs-progs-test-kernel.xml

    r08c3c25 r1417643  
    88  [*]     ReiserFS extended attributes                       [REISERFS_FS_XATTR]
    99  [*]       ReiserFS POSIX Access Control Lists          [REISERFS_FS_POSIX_ACL]
    10   [*]   Btrfs POSIX Access Control Lists                    [BTRFS_FS_POSIX_ACL]</literal></screen>
     10  &lt;*/M&gt; Btrfs filesystem support                                      [BTRFS_FS]
     11  [*]     Btrfs POSIX Access Control Lists                  [BTRFS_FS_POSIX_ACL]</literal></screen>
  • postlfs/filesystems/lvm2-kernel.xml

    r08c3c25 r1417643  
    55     DO NOT EDIT! -->
    66<screen><literal>Device Drivers ---&gt;
    7   &lt;*/M&gt; RAM block device support                                   [BLK_DEV_RAM]
    8   [*]   Multiple devices driver support (RAID and LVM) ---&gt;                 [MD]
     7  [*] Block devices ---&gt;                                               [BLK_DEV]
     8    &lt;*/M&gt; RAM block device support                                 [BLK_DEV_RAM]
     9  [*] Multiple devices driver support (RAID and LVM) ---&gt;                   [MD]
    910    &lt;*/M&gt; Device mapper support                                     [BLK_DEV_DM]
    10     &lt;*/M&gt; Crypt target support                                        [DM_CRYPT]
    11     &lt;*/M&gt; Snapshot target                                          [DM_SNAPSHOT]
    12     &lt;*/M&gt; Thin provisioning target                        [DM_THIN_PROVISIONING]
    13     &lt;*/M&gt; Cache target (EXPERIMENTAL)                                 [DM_CACHE]
    14     &lt;*/M&gt; Mirror target                                              [DM_MIRROR]
    15     &lt;*/M&gt; Zero target                                                  [DM_ZERO]
    16     &lt;*/M&gt; I/O delaying target                                         [DM_DELAY]
     11    &lt;*/M&gt;   Crypt target support                                      [DM_CRYPT]
     12    &lt;*/M&gt;   Snapshot target                                        [DM_SNAPSHOT]
     13    &lt;*/M&gt;   Thin provisioning target                      [DM_THIN_PROVISIONING]
     14    &lt;*/M&gt;   Cache target (EXPERIMENTAL)                               [DM_CACHE]
     15    &lt;*/M&gt;   Mirror target                                            [DM_MIRROR]
     16    &lt;*/M&gt;   Zero target                                                [DM_ZERO]
     17    &lt;*/M&gt;   I/O delaying target                                       [DM_DELAY]
    1718Kernel hacking ---&gt;
    1819  Generic Kernel Debugging Instruments ---&gt;
  • postlfs/filesystems/parted.xml

    r08c3c25 r1417643  
    106106
    107107    <indexterm zone="parted parted-kernel">
    108       <primary sortas="d-parted">parted</primary>
     108      <primary sortas="d-parted">parted (testing)</primary>
    109109    </indexterm>
    110110  </sect2>
  • postlfs/filesystems/uefi-bootloaders/grub-setup-kernel.xml

    r08c3c25 r1417643  
    66<screen><literal>Processor type and features ---&gt;
    77  [*] EFI runtime service support                                          [EFI]
    8 Partition Types ---&gt;
    9   [ /*] Advanced partition selection                        [PARTITION_ADVANCED]
    10   [*]   EFI GUID Partition support                               [EFI_PARTITION]
     8-*- Enable the block layer ---&gt;                                          [BLOCK]
     9  Partition Types ---&gt;
     10    [ /*] Advanced partition selection                      [PARTITION_ADVANCED]
     11    [*]     EFI GUID Partition support                           [EFI_PARTITION]
    1112Device Drivers ---&gt;
    1213  Firmware Drivers ---&gt;
  • postlfs/security/cryptsetup-kernel.xml

    r08c3c25 r1417643  
    77  [*] Multiple devices driver support (RAID and LVM) ---&gt;                   [MD]
    88    &lt;*/M&gt; Device mapper support                                     [BLK_DEV_DM]
    9     &lt;*/M&gt; Crypt target support                                        [DM_CRYPT]
     9    &lt;*/M&gt;   Crypt target support                                      [DM_CRYPT]
    1010-*- Cryptographic API ---&gt;                                              [CRYPTO]
    1111  Block ciphers ---&gt;
  • postlfs/security/iptables-kernel.xml

    r08c3c25 r1417643  
    88    [*] Network packet filtering framework (Netfilter) ---&gt;          [NETFILTER]
    99      [*] Advanced netfilter configuration                  [NETFILTER_ADVANCED]
    10         Core Netfilter Configuration ---&gt;
    11         &lt;*/M&gt;   Netfilter connection tracking support             [NF_CONNTRACK]
    12         &lt;*/M&gt;   Netfilter Xtables support (required for ip_tables)
     10      Core Netfilter Configuration ---&gt;
     11        &lt;*/M&gt; Netfilter connection tracking support               [NF_CONNTRACK]
     12        &lt;*/M&gt; Netfilter Xtables support (required for ip_tables)
    1313                                                        ...  [NETFILTER_XTABLES]
    14         &lt;*/M&gt;     LOG target support                   [NETFILTER_XT_TARGET_LOG]
     14        &lt;*/M&gt;   LOG target support                     [NETFILTER_XT_TARGET_LOG]
    1515      IP: Netfilter Configuration ---&gt;
    1616        &lt;*/M&gt; IP tables support (required for filtering/masq/NAT)
  • postlfs/virtualization/qemu-bridge-kernel.xml

    r08c3c25 r1417643  
    77  Networking options ---&gt;
    88    &lt;*/M&gt; 802.1d Ethernet Bridging                                      [BRIDGE]
    9   Device Drivers ---&gt;
    10     [*] Network device support ---&gt;                                 [NETDEVICES]
    11       &lt;*/M&gt; Universal TUN/TAP device driver support                        [TUN]</literal></screen>
     9Device Drivers ---&gt;
     10  [*] Network device support ---&gt;                                   [NETDEVICES]
     11    [*]   Network core driver support                                 [NET_CORE]
     12    &lt;*/M&gt;   Universal TUN/TAP device driver support                        [TUN]</literal></screen>
  • x/installing/libevdev-test-kernel.xml

    r08c3c25 r1417643  
    66<screen><literal>Device Drivers ---&gt;
    77  Input device support ---&gt;
    8     [*] Miscellaneous devices ---&gt;                                  [INPUT_MISC]
    9       &lt;*/M&gt; User level driver support                             [INPUT_UINPUT]</literal></screen>
     8    -*- Generic input layer (needed for keyboard, mouse, ...)            [INPUT]
     9    [*]   Miscellaneous devices ---&gt;                                [INPUT_MISC]
     10      &lt;*/M&gt;   User level driver support                           [INPUT_UINPUT]</literal></screen>
  • x/installing/x7driver-wacom-kernel.xml

    r08c3c25 r1417643  
    99      Special HID drivers ---&gt;
    1010      &lt;*/M&gt;   Wacom Intuos/Graphire tablet support (USB)             [HID_WACOM]
    11       USB HID support ---&gt;
    12       &lt;*/M&gt;   USB HID transport layer                                  [USB_HID]
     11    USB HID support ---&gt;
     12      &lt;*/M&gt; USB HID transport layer                                    [USB_HID]
    1313  [*] USB support ---&gt;                                             [USB_SUPPORT]
    1414    &lt;*/M&gt; Support for Host-side USB                                        [USB]</literal></screen>
Note: See TracChangeset for help on using the changeset viewer.