Locate platformio.ini in a subdirectory
My current folder structure places all the app (including the platformio.ini) in the "app" folder, i need to start vscode at the parent folder so i can access the .github, .vscode and documentation.
How can i make the extension locate the platformio.ini there?. I am using docker. I do not need the extension to be fair, would only use to generate that file, i'm happy using cli, but having a really bad time configuring the c_cpp_properties (esp-idf functions shows a not defined in intelissense, but code compiles fine).
My current platformio.ini
[platformio]
; Project-specific directories
workspace_dir = /workspace/app
build_dir = /workspace/.pio/build
libdeps_dir = /workspace/.pio/libdeps
include_dir = /workspace/app/include
src_dir = /workspace/app/src
lib_dir = /workspace/app/lib
; data_dir = /workspace/app/data
test_dir = /workspace/app/test
boards_dir = /workspace/app/boards
; monitor_dir = /workspace/.pio/monitor
; shared_dir = /workspace/.pio/shared
; Global PlatformIO directories
core_dir = /root/.platformio
globallib_dir = /root/.platformio/lib
platforms_dir = /root/.platformio/platforms
packages_dir = /root/.platformio/packages
cache_dir = /root/.platformio/.cache
build_cache_dir = /root/.platformio/.cache/build
[env:native]
; lib_ldf_mode = deep+ #build fast
test_framework = googletest
test_ignore = test_esp32dev
platform = native
build_flags = -D MY_PROJECT_VERSION=10
; lib_ignore =
; Arduino.h
; port_tools
; extra_scripts = scripts/build_doxygen.py
[env:esp32dev]
test_framework = googletest
test_ignore = test_native
; lib_ldf_mode = off
; lib_compat_mode = off
; lib_extra_dirs = src/
platform = espressif32
framework = arduino, espidf
platform_packages =
framework-arduinoespressif32 @ https://github.com/italocjs/arduino-esp32.git#idf-release/v4.4
board = simovatrack130
board_build.partitions = partitions.csv
build_flags =
-D MY_PROJECT_VERSION=20
; -I /root/.platformio/packages/framework-espidf/components
; -I /root/.platformio/packages/framework-arduinoespressif32/cores/esp32
; lib_deps =
; adafruit/Adafruit BME280 Library @ ^2.2.4
; adafruit/Adafruit BusIO @ ^1.15.0
; adafruit/Adafruit Unified Sensor @ ^1.1.14
; bblanchon/ArduinoJson @ ^7.0.3
; zinggjm/GxEPD2 @ ^1.5.6
upload_speed = 921600
monitor_speed = 115200
monitor_filters =
esp32_exception_decoder
send_on_enter
Note, i did try pio init --ide=vscode, it did generate a file, but had no intelissensse for anything outside my own project:
//
// !!! WARNING !!! AUTO-GENERATED FILE!
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
//
{
"configurations": [
{
"name": "PlatformIO",
"includePath": [
"/workspace/app/include",
"/workspace/app/src",
"/workspace/app/lib/Geofence/src",
"/workspace/app/lib/SmartoneC",
"/workspace/app/lib/api",
"/workspace/app/lib/cmd_processor",
"/workspace/app/lib/nimble_nus",
"/workspace/app/lib/nimble_source/src",
"/workspace/app/lib/port",
"/workspace/app/lib/sample_interface",
"/workspace/app/lib/sdcard",
""
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"path": [
"/workspace/app/include",
"/workspace/app/src",
"/workspace/app/lib/Geofence/src",
"/workspace/app/lib/SmartoneC",
"/workspace/app/lib/api",
"/workspace/app/lib/cmd_processor",
"/workspace/app/lib/nimble_nus",
"/workspace/app/lib/nimble_source/src",
"/workspace/app/lib/port",
"/workspace/app/lib/sample_interface",
"/workspace/app/lib/sdcard",
""
]
},
"defines": [
"PLATFORMIO=60114",
"MY_PROJECT_VERSION=10",
""
],
"compilerPath": "/usr/bin/gcc",
"compilerArgs": [
""
]
}
],
"version": 4
}
i did try to manually include some stuff, without success (not sure if i'm even including the right directories)
//
// !!! WARNING !!! AUTO-GENERATED FILE!
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
//
{
"configurations": [
{
"name": "PlatformIO",
"includePath": [
"/workspace/app/include",
"/workspace/app/src",
"/workspace/app/lib/Geofence/src",
"/workspace/app/lib/SmartoneC",
"/workspace/app/lib/api",
"/workspace/app/lib/cmd_processor",
"/workspace/app/lib/nimble_nus",
"/workspace/app/lib/nimble_source/src",
"/workspace/app/lib/port",
"/workspace/app/lib/sample_interface",
"/workspace/app/lib/sdcard",
"/root/.platformio/packages/framework-espidf/components/**",
"/root/.platformio/packages/framework-espidf/tools/**",
"/root/.platformio/packages/framework-arduinoespressif32/cores/esp32/**",
"/root/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/**",
""
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"path": [
"/workspace/app/include",
"/workspace/app/src",
"/workspace/app/lib/Geofence/src",
"/workspace/app/lib/SmartoneC",
"/workspace/app/lib/api",
"/workspace/app/lib/cmd_processor",
"/workspace/app/lib/nimble_nus",
"/workspace/app/lib/nimble_source/src",
"/workspace/app/lib/port",
"/workspace/app/lib/sample_interface",
"/workspace/app/lib/sdcard",
"/root/.platformio/packages/framework-espidf/components/**",
"/root/.platformio/packages/framework-espidf/tools/**",
"/root/.platformio/packages/framework-arduinoespressif32/cores/esp32/**",
"/root/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/**",
""
]
},
"defines": [
"PLATFORMIO=60114",
"MY_PROJECT_VERSION=10",
""
],
"compilerPath": "/usr/bin/gcc",
"compilerArgs": [
""
]
}
],
"version": 4
}
compiling works fine.
yay, manage to fix my intelissense by using pio init --environment esp32dev --ide vscode then using a custom script to copy it to the parent folder, hope it helps anyone with intelisense issues
#!/bin/bash
# Check if an environment name is provided
if [ -z "$1" ]; then
echo "Usage: $0 <environment_name>"
echo "Default environments are: native | esp32dev"
exit 1
fi
ENVIRONMENT_NAME=$1
# Change directory to the specified path
cd /workspace/app/ || exit
# Store the command used to initialize the environment
INIT_COMMAND="pio init --environment $ENVIRONMENT_NAME --ide vscode"
# Execute the command
$INIT_COMMAND
if [ $? -eq 0 ]; then
echo "Successfully initialized environment '$ENVIRONMENT_NAME' for VSCode."
else
echo "Failed to initialize environment '$ENVIRONMENT_NAME' for VSCode."
exit 1
fi
# Prepare a header message for the c_cpp_properties.json file using a here-document
cat > temp_header.json <<EOF
/*
This file was generated by the prepare_intelissense.sh script using the command:
$INIT_COMMAND
It is intended for setting up IntelliSense configurations for the environment: $ENVIRONMENT_NAME.
*/
EOF
# Append the original c_cpp_properties.json content to the temporary file
cat .vscode/c_cpp_properties.json >> temp_header.json
# Copy and replace the c_cpp_properties.json file with the one that includes the header
cp -f temp_header.json /workspace/.vscode/c_cpp_properties.json
if [ $? -eq 0 ]; then
echo "Successfully copied IntelliSense settings for environment '$ENVIRONMENT_NAME'."
else
echo "Failed to copy IntelliSense settings for environment '$ENVIRONMENT_NAME'."
exit 1
fi
# Clean up the temporary file
rm temp_header.json
Would love to find a way to use the extension tho.