VSCode KConfig extension fails with fragments in a subdirectory

My prj.conf was growing quite large so I split it into several `prj-<section>.conf files for sections that I wasn't working on and moved them to a "config" subdirectory

Example: `config/prj-zephyr.conf`

# Logging (Core)
CONFIG_LOG=y
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_BUFFER_SIZE=16384
CONFIG_LOG_BACKEND_UART=y # Log through UART0
CONFIG_LOG_BACKEND_RTT=n
# Shell disabled because it interferes with logging
CONFIG_SHELL=n

CONFIG_MAIN_STACK_SIZE=4096
# Some command handlers require a large stack.
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

Fragments are added to the build using the "Kconfig fragments" list in the VSCode build configuration (OVERLAY_CONFIG on command line) and are listed under "input files" in the editor

However the Kconfig extension shows "no context" when I open any of these fragment files and prj.conf shows warnings whenever I set an option there that depends on the fragments (e.g. attempting to over-ride a log level). The latter may actually be intended as it seems fragments are added after prj.conf based on the .config output

What I would like to see here is fragments being supported in editor (because a multi-page conf file is a PITA to use) and also a way to add fragments before prj.conf (so prj.conf can over-write). I believe based on the docs the Zephyr CONF_FILE variable accepts a list of files so maybe the editor could support that and order could be managed that way?

  • Hi,

    However the Kconfig extension shows "no context" when I open any of these fragment files and prj.conf shows warnings whenever I set an option there that depends on the fragments (e.g. attempting to over-ride a log level). The latter may actually be intended as it seems fragments are added after prj.conf based on the .config output

    Could you please show all steps both when you open some fragment file and see "no context" and when you open prj.conf and see warnings? Do you have a small sample that I could use to test this?

    Best regards,
    Dejan

  • kconfig-fragments.zip

    Attached the basic hello world project with three additional fragments

    • ./config/prj-fragment1.conf
    • ./prj-fragment2.conf
    • ./overlay.conf

    There is a preset that adds all of them to the build

    Opening any .conf file that is not prj.conf causes the "no context" error to trigger until the next rebuild. There is no suggestions or tooltips in any of the fragments

    There is also no way to add any of the fragments before prj.conf because the PRJ_CONF variable doesn't accept a list of files in the editor. I would like to split prj.conf and use that file only for active development (e.g. over-riding log levels) while settled configuration exists in several fragments (config/prj-<fragment>.conf). This would require those fragments to be added prior to prj.conf

    Also worth noting: fragments added inside CMakeLists.txt (using list(APPEND ...)) do not show in the GUI list of input files at all

  • Hi,

    I have run your sample project in VS Code and I could not see any issues with it. I did not see any problem of specifying any other file than prj.conf in the "CONF_FILE" of your preset. It is just important to add all needed Kconfig fragments to the "OVERLAY_CONFIG".

    In VS Code, I could see that all files were merged successfully both in case when prj.conf was specified in "CONF_FILE" and when it was specified in "OVERLAY_CONFIG". This is how it looked like when prj.conf was specified as an overlay file.

    Merged configuration .../prj-fragment2.conf
    Merged configuration .../config/prj-fragment1.conf
    Merged configuration .../overlay.conf
    Merged configuration .../prj.conf


    Best regards,
    Dejan

  • clearly I railroaded myself a little there. Including prj.conf as the last overlay works perfectly

    As for the fragments not working, I was mistaken in my understanding of the issue yesterday. After some more clicking around, it is only fragments in a subdirectory that cause "Kconfig: no context" when the file is opened. The red "no context" error in the bottom left doesn't go away  until a new build is triggered so I thought more files were affected

    It would be really great if placing fragments in a subdirectory was supported

  • Hi,

    Do you see "Kconfig no context" only during active builds?

    According to the source code, "Kconfig: no context" means "No context found for this file, the file does not belong to the active build". Is in your case that particular file used in the active build?

    Best regards,
    Dejan

Related