How to add paths that depend on selected framework version?

(This is an old question that didn’t get a response, edited for simplicity)

In the -I paths below, the ‘espidf’ part refer to the framework version used and should be changed manuall if a different framework version is selected.

Is there a way to define paths such that they will refer to the current framework in use? E.g. using a $FRAMEWORK_DIR like variable.

(These paths are required because ‘jump to definitions’ doesn’t work in stock ESP32 projects).

; Base
[env]
platform = espressif32
board = esp32dev
framework = espidf
monitor_speed = 115200
debug_tool=esp-prog
upload_port=COM6
board_build.partitions = partitions_singleapp_large.csv
upload_speed=921600
; For IntelliSense.
build_flags =
    -I$PROJECT_CORE_DIR/packages/framework-espidf/components/driver
    -I$PROJECT_CORE_DIR/packages/framework-espidf/components/freertos

[env:release]
build_type = release

[env:debug]
build_type = debug