Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to parse linux kconfig #12

Open
rossburton opened this issue Jan 23, 2025 · 0 comments
Open

Fails to parse linux kconfig #12

rossburton opened this issue Jan 23, 2025 · 0 comments

Comments

@rossburton
Copy link

rossburton commented Jan 23, 2025

Maybe I'm doing something stupid, but I can't seem to parse the linux kconfig. With a minimal piece of code placed in the kernel tree:

import os, kconfiglib
# set environment as expected
os.environ["KERNELVERSION"] = "6.12.2"
os.environ["srctree"] = "/home/rosbur01/Code/drive-by/linux/"
os.environ["SRCARCH"] = "arm64"
os.environ["ARCH"] = "arm64"
os.environ["CC"] = "gcc"
os.environ["LD"] = "ld"

kconf = kconfiglib.Kconfig("Kconfig")

This gives:

Traceback (most recent call last):
  File "/home/rosbur01/Code/drive-by/linux/./argh.py", line 16, in <module>
    kconf = kconfiglib.Kconfig("Kconfig")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rosbur01/.local/lib/python3.12/site-packages/kconfiglib.py", line 947, in __init__
    self._init(filename, warn, warn_to_stderr, encoding)
  File "/home/rosbur01/.local/lib/python3.12/site-packages/kconfiglib.py", line 1085, in _init
    self._parse_block(None, self.top_node, self.top_node).next = None
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rosbur01/.local/lib/python3.12/site-packages/kconfiglib.py", line 2989, in _parse_block
    prev = self._parse_block(None, parent, prev)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rosbur01/.local/lib/python3.12/site-packages/kconfiglib.py", line 2989, in _parse_block
    prev = self._parse_block(None, parent, prev)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rosbur01/.local/lib/python3.12/site-packages/kconfiglib.py", line 3091, in _parse_block
    self._parse_error(
  File "/home/rosbur01/.local/lib/python3.12/site-packages/kconfiglib.py", line 3879, in _parse_error
    raise KconfigError("{}error: couldn't parse '{}': {}".format(
kconfiglib.KconfigError: kernel/module/Kconfig:4: error: couldn't parse 'modules': unrecognized construct

kernel/module/Kconfig looks like this:

# SPDX-License-Identifier: GPL-2.0-only
menuconfig MODULES
        bool "Enable loadable module support"
        modules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant