espressif / vscode-esp-idf-extension

Visual Studio Code extension for ESP-IDF projects
Apache License 2.0
1.03k stars 300 forks source link

Multi config and IntelliSense configuration issues (VSC-1475) #1283

Closed executer-uno closed 1 month ago

executer-uno commented 1 month ago

OS

Windows

Operating System version

Windows 10 Pro

Visual Studio Code version

1.92.2

ESP-IDF version

5.1.4

Python version

3.11.7

Doctor command output

---------------------------------------------- ESP-IDF Extension for Visual Studio Code report --------------------------------------------- OS win32 x64 10.0.19045 System environment variable IDF_PYTHON_ENV_PATH undefined System environment variable PATH C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\IVI Foundation\VISA\Win64\bin;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\bin;C:\Program Files (x86)\IVI Foundation\IVI\bin;C:\Program Files\IVI Foundation\IVI\bin;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\;C:\Program Files\IVI Foundation\VISA\Win64\Bin\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\msys64\mingw64\bin;C:\AppData\Local\Microsoft\WindowsApps;C:\AppData\Local\Programs\Microsoft VS Code\bin;C:\CMake\bin;D:\Downloads\make-3.81-bin\bin; System environment variable PYTHON undefined Visual Studio Code version 1.92.2 Visual Studio Code language en Visual Studio Code shell C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe ESP-IDF Extension version 1.8.0 Workspace folder d:\Documents\VSC_Workspace\IDF_multi_config2\multi_config ---------------------------------------------------- Extension configuration settings ------------------------------------------------------ ESP-ADF Path (idf.espAdfPath) ${env:ADF_PATH} ESP-IDF Path (idf.espIdfPath) c:\esp\v5.1\esp-idf ESP-MDF Path (idf.espMdfPath) ${env:MDF_PATH} ESP-Matter Path (idf.espMatterPath) ${env:ESP_MATTER_PATH} ESP-HomeKit-SDK Path (idf.espHomeKitSdkPath) ${env:HOMEKIT_PATH} Custom extra paths (idf.customExtraPaths) c:\esp-idf5.1\tools\xtensa-esp-elf-gdb\12.1_20231023\xtensa-esp-elf-gdb\bin;c:\esp-idf5.1\tools\riscv32-esp-elf-gdb\12.1_20231023\riscv32-esp-elf-gdb\bin;c:\esp-idf5.1\tools\xtensa-esp32-elf\esp-12.2.0_20230208\xtensa-esp32-elf\bin;c:\esp-idf5.1\tools\xtensa-esp32s2-elf\esp-12.2.0_20230208\xtensa-esp32s2-elf\bin;c:\esp-idf5.1\tools\xtensa-esp32s3-elf\esp-12.2.0_20230208\xtensa-esp32s3-elf\bin;c:\esp-idf5.1\tools\riscv32-esp-elf\esp-12.2.0_20230208\riscv32-esp-elf\bin;c:\esp-idf5.1\tools\esp32ulp-elf\2.35_20220830\esp32ulp-elf\bin;c:\esp-idf5.1\tools\cmake\3.24.0\bin;c:\esp-idf5.1\tools\openocd-esp32\v0.12.0-esp32-20240318\openocd-esp32\bin;c:\esp-idf5.1\tools\ninja\1.10.2;c:\esp-idf5.1\tools\idf-exe\1.0.3;c:\esp-idf5.1\tools\ccache\4.8\ccache-4.8-windows-x86_64;c:\esp-idf5.1\tools\dfu-util\0.11\dfu-util-0.11-win64;c:\esp-idf5.1\tools\esp-rom-elfs\20230320 Custom extra vars (idf.customExtraVars) OPENOCD_SCRIPTS: c:\esp-idf5.1\tools\openocd-esp32\v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts IDF_CCACHE_ENABLE: 1 ESP_ROM_ELF_DIR: c:\esp-idf5.1\tools\esp-rom-elfs\20230320/ Virtual env Python Path (idf.pythonBinPath) c:\esp-idf5.1\python_env\idf5.1_py3.11_env\Scripts\python.exe Serial port (idf.port) COM1 OpenOCD Configs (idf.openOcdConfigs) interface/ftdi/esp32_devkitj_v1.cfg,board/esp32-wrover.cfg ESP-IDF Tools Path (idf.toolsPath) c:\esp-idf5.1 Git Path (idf.gitPath) c:\esp-idf5.1\tools\idf-git\2.39.2\cmd\git.exe Notification Mode (idf.notificationMode) All -------------------------------------------------------- Configurations access ------------------------------------------------------------- Access to ESP-ADF Path (idf.espAdfPath) false Access to ESP-IDF Path (idf.espIdfPath) true Access to ESP-MDF Path (idf.espMdfPath) false Access to ESP-Matter Path (idf.espMatterPath) false Access to ESP-HomeKit Path (idf.espHomeKitSdkPath) false Access to ESP-IDF Custom extra paths Access to c:\esp-idf5.1\tools\xtensa-esp-elf-gdb\12.1_20231023\xtensa-esp-elf-gdb\bin: true Access to c:\esp-idf5.1\tools\riscv32-esp-elf-gdb\12.1_20231023\riscv32-esp-elf-gdb\bin: true Access to c:\esp-idf5.1\tools\xtensa-esp32-elf\esp-12.2.0_20230208\xtensa-esp32-elf\bin: true Access to c:\esp-idf5.1\tools\xtensa-esp32s2-elf\esp-12.2.0_20230208\xtensa-esp32s2-elf\bin: true Access to c:\esp-idf5.1\tools\xtensa-esp32s3-elf\esp-12.2.0_20230208\xtensa-esp32s3-elf\bin: true Access to c:\esp-idf5.1\tools\riscv32-esp-elf\esp-12.2.0_20230208\riscv32-esp-elf\bin: true Access to c:\esp-idf5.1\tools\esp32ulp-elf\2.35_20220830\esp32ulp-elf\bin: true Access to c:\esp-idf5.1\tools\cmake\3.24.0\bin: true Access to c:\esp-idf5.1\tools\openocd-esp32\v0.12.0-esp32-20240318\openocd-esp32\bin: true Access to c:\esp-idf5.1\tools\ninja\1.10.2: true Access to c:\esp-idf5.1\tools\idf-exe\1.0.3: true Access to c:\esp-idf5.1\tools\ccache\4.8\ccache-4.8-windows-x86_64: true Access to c:\esp-idf5.1\tools\dfu-util\0.11\dfu-util-0.11-win64: true Access to c:\esp-idf5.1\tools\esp-rom-elfs\20230320: true Access to Virtual env Python Path (idf.pythonBinPath) true Access to CMake in environment PATH undefined Access to Ninja in environment PATH undefined Access to ESP-IDF Tools Path (idf.toolsPath) true -------------------------------------------------------- Configurations has spaces ------------------------------------------------------------- Spaces in system environment Path true Spaces in ESP-ADF Path (idf.espAdfPath) false Spaces in ESP-IDF Path (idf.espIdfPath) false Spaces in ESP-MDF Path (idf.espMdfPath) false Spaces in ESP-Matter Path (idf.espMatterPath) false Spaces in ESP-HomeKit-SDK Path (idf.espHomeKitSdkPath) false Spaces in ESP-IDF Custom extra paths Spaces in c:\esp-idf5.1\tools\xtensa-esp-elf-gdb\12.1_20231023\xtensa-esp-elf-gdb\bin: false Spaces in c:\esp-idf5.1\tools\riscv32-esp-elf-gdb\12.1_20231023\riscv32-esp-elf-gdb\bin: false Spaces in c:\esp-idf5.1\tools\xtensa-esp32-elf\esp-12.2.0_20230208\xtensa-esp32-elf\bin: false Spaces in c:\esp-idf5.1\tools\xtensa-esp32s2-elf\esp-12.2.0_20230208\xtensa-esp32s2-elf\bin: false Spaces in c:\esp-idf5.1\tools\xtensa-esp32s3-elf\esp-12.2.0_20230208\xtensa-esp32s3-elf\bin: false Spaces in c:\esp-idf5.1\tools\riscv32-esp-elf\esp-12.2.0_20230208\riscv32-esp-elf\bin: false Spaces in c:\esp-idf5.1\tools\esp32ulp-elf\2.35_20220830\esp32ulp-elf\bin: false Spaces in c:\esp-idf5.1\tools\cmake\3.24.0\bin: false Spaces in c:\esp-idf5.1\tools\openocd-esp32\v0.12.0-esp32-20240318\openocd-esp32\bin: false Spaces in c:\esp-idf5.1\tools\ninja\1.10.2: false Spaces in c:\esp-idf5.1\tools\idf-exe\1.0.3: false Spaces in c:\esp-idf5.1\tools\ccache\4.8\ccache-4.8-windows-x86_64: false Spaces in c:\esp-idf5.1\tools\dfu-util\0.11\dfu-util-0.11-win64: false Spaces in c:\esp-idf5.1\tools\esp-rom-elfs\20230320: false Spaces in Virtual env Python Path (idf.pythonBinPath) false Spaces in ESP-IDF Tools Path (idf.toolsPath) false ----------------------------------------------------------- Executables Versions ----------------------------------------------------------- Git version 2.39.2.windows.1 ESP-IDF version 5.1.4 Python version 3.11.2 Python's pip version 24.2 -------------------------------------------------- Project configuration settings ---------------------------------------------------------- Selected configuration: prod2

Configuration name: currentProjectConfKey ---- Build section ---- Compile Arguments: Ninja Arguments: Build directory path: ${workspaceFolder}\build_prod2 SDKConfig defaults : sdkconfig.prod_common,sdkconfig.prod2 ---- Environment variables section ---- Flash baud rate: IDF Target: esp32 Monitor baud rate: ---- OpenOCD section ---- Debug level: 0 Configuration files: Launch arguments: ---- Tasks section ---- Pre build task: Post build task: Pre flash task: Post flash task: -------------------------------------------------- Python packages in idf.pythonBinPath ---------------------------------------------------- annotated-types version: 0.7.0 bitarray version: 2.9.2 bitstring version: 4.2.3 CacheControl version: 0.14.0 certifi version: 2024.6.2 cffi version: 1.16.0 charset-normalizer version: 3.3.2 click version: 8.1.7 colorama version: 0.4.6 construct version: 2.10.70 contextlib2 version: 21.6.0 cryptography version: 39.0.2 ecdsa version: 0.19.0 esp-coredump version: 1.11.0 esp-idf-kconfig version: 1.4.2 esp-idf-monitor version: 1.4.0 esp-idf-panic-decoder version: 1.1.0 esp-idf-size version: 1.5.0 esptool version: 4.7.0 filelock version: 3.15.4 freertos-gdb version: 1.0.3 idf-component-manager version: 1.5.3 idna version: 3.7 intelhex version: 2.3.0 jsonref version: 1.1.0 kconfiglib version: 14.1.0 markdown-it-py version: 3.0.0 mdurl version: 0.1.2 msgpack version: 1.0.8 packaging version: 24.1 pip version: 24.2 pycparser version: 2.22 pydantic version: 2.8.2 pydantic_core version: 2.20.1 pydantic-settings version: 2.4.0 pyelftools version: 0.29 pygdbmi version: 0.11.0.0 Pygments version: 2.18.0 pyparsing version: 3.0.9 pyserial version: 3.5 python-dotenv version: 1.0.1 PyYAML version: 6.0.1 reedsolo version: 1.7.0 requests version: 2.32.3 requests-file version: 1.5.1 requests-toolbelt version: 1.0.0 rich version: 13.7.1 schema version: 0.7.5 setuptools version: 70.2.0 six version: 1.16.0 tqdm version: 4.66.4 typing_extensions version: 4.12.2 urllib3 version: 1.26.19 windows-curses version: 2.3.3 ---------------------------------------------------- Check ESP-IDF python requirements.txt ------------------------------------------------- Check ESP-IDF Python packages Python requirements are satisfied. ---------------------------------------------------- Check ESP-IDF debug adapter requirements.txt ------------------------------------------ Check Debug AdapterPython packages Error ---------------------------------------------------- Visual Studio Code launch.json -------------------------------------------------------- { "version": "0.2.0", "configurations": [ { "type": "gdbtarget", "request": "attach", "name": "Eclipse CDT GDB Adapter" }, { "type": "espidf", "name": "Launch", "request": "launch" } ] } ---------------------------------------------------- Visual Studio Code c_cpp_properties.json ---------------------------------------------- { "configurations": [ { "name": "ESP-IDF", "compilerPath": "${config:idf.toolsPathWin}\tools\xtensa-esp32-elf\esp-12.2.0_20230208\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe", "compileCommands": "${config:idf.buildPath}/compile_commands.json", "includePath": [ "${config:idf.espIdfPath}/components/", "${config:idf.espIdfPathWin}/components/", "${workspaceFolder}/**" ], "browse": { "path": [ "${config:idf.espIdfPath}/components", "${config:idf.espIdfPathWin}/components", "${workspaceFolder}" ], "limitSymbolsToIncludedHeaders": true } } ], "version": 4 }

----------------------------------------------------------- Latest error ----------------------------------------------------------------- { "code": 1, "killed": false, "signal": null, "cmd": "c:\esp-idf5.1\python_env\idf5.1_py3.11_env\Scripts\python.exe c:\esp\v5.1\esp-idf\tools\check_python_dependencies.py -r c:\.vscode\extensions\espressif.esp-idf-extension-1.8.0\esp_debug_adapter\requirements.txt" }

----------------------------------------------------------- Logfile -----------------------------------------------------------------


Extension

No response

Description

I would like to have correct IntelliSense behaviour in my multi config project tutorial/multiple_config for reference. So, when I change current configuration IntelliSense would proceeds correctly

It is no working out of the box. What I suspects that Intellisense founds all the build folders and could not determine exactly one bundle of files to use. I think so, becouse in my example, in main\multi_config_example_main.c if I Ctrl+Click on "CONFIG_EXAMPLE_PRODUCT_NAME" definition - it shows two sdkconfig files to choose to go to, build_prod1\config\sdkconfig.h and build_prod2\config\sdkconfig.h with different values defined. One more suspect .vscode\c_cpp_properties.json reference to ${config:idf.buildPath} contains standart ${workspaceFolder}/build path, not the one I sated in esp_idf_project_configuration.json (either build_prod1 or build_prod2 should be referenced one at a time). Just a fuzzy prooves: .vscode\c_cpp_properties.json line "compileCommands": "${config:idf.buildPath}/compile_commands.json" should help IntelliSense to find compile_commands.json for current selected config, but I think I need to provide it myself via command "Select IntelliSense Configuration...", and obviously it not follows selected configuration. Also idf.py save-defconfig still dont see neither build_prod1 nor build_prod2 exist folders and just creates its own "build" folder.

If I would refer to current selected build folder via config:idf.buildPath I would try to follow dozen of tutrorials how to make IntelliSense work, without It I dont understand how to determine currently selected config for IntelliSense, may be there are some other internal variables for that? But usage of default variable idf.buildPath would be clear logical way, I guess.

Debug Message

not applicable

Other Steps to Reproduce

I noticed that Doctor Command shows correct, currently selected build path:

-------------------------------------------------- Project configuration settings ----------------------------------------------------------
Selected configuration: prod1

Configuration name: currentProjectConfKey
---- Build section ----
     Compile Arguments: 
     Ninja Arguments: 
     Build directory path: ${workspaceFolder}\build_prod1
-------------------------------------------------- Project configuration settings ----------------------------------------------------------
Selected configuration: prod2

Configuration name: currentProjectConfKey
---- Build section ----
     Compile Arguments: 
     Ninja Arguments: 
     Build directory path: ${workspaceFolder}\build_prod2

Did it reffers to some variable or config:idf.buildPath works fine for it somehow?

I have checked existing issues, online documentation and the Troubleshooting Guide

brianignacio5 commented 1 month ago

The issue is that c_cpp_properties.json and Intellisense is not handle by our extension. Best we can do is to update the c_cpp_properties.json file when you change from one profile to another by update compile_commands.json path.

executer-uno commented 1 month ago

So, there is no option to feed c_cpp_properties.json with some env path variable to point current compile_commands.json? I asuume that it will not work becouse Intellisense will not follow env path variable updates, sounds logical.

Ok, Thanks for that answer. It would be awesome if you provide some mechanics to make Intellisense work as it desired while configuration changed. Or just add a note about required manual operations to do after switch, not to make it hidden under lid.

So, I will check how it works if correct compile_commands.json provided in c_cpp_properties.json at least manually.

brianignacio5 commented 1 month ago

I've added the changes in #1252

Could you try this vsix installer ?

executer-uno commented 1 month ago

Works great. Intellisense follows actual configuration. :white_check_mark: ifdef codeblocks dimming :white_check_mark: unknown identifiers red underline :white_check_mark: Ctrl+Click navigation between files to exactly right destination Thank you very much!