Updated PicoSDK template. Using compile commands instead of manual directory enumeration and macro definitions.

This commit is contained in:
Ulysse Cura 2026-10-16 22:08:16 +02:00
parent f3dba05939
commit e58ff49233
5 changed files with 79 additions and 30 deletions

View File

@ -1,2 +1 @@
build
.vscode/ccls-cache

16
C_PicoSDK/.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Linux",
"intelliSenseMode": "linux-gcc-arm",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true
},
"compileCommands": "build/compile_commands.json"
}
],
"version": 4
}

View File

@ -1,12 +1,62 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Configure",
"detail": "configure project",
"type": "shell",
"command": "cmake",
"args": [
"-H.",
"-Bbuild",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
},
{
"label": "Build",
"detail": "Build project",
"dependsOn": [
"Configure"
],
"type": "shell",
"command": "cmake -H. -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=YES && make -j$(nproc) -C build",
"command": "make",
"args": [
"-C",
"build",
"-j$(nproc)"
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
},
{
"label": "Flash",
"detail": "Build and flash",
"type": "shell",
"dependsOn": [
"Configure"
],
"command": "make",
"args": [
"-C",
"build",
"-j$(nproc)",
"Flash"
],
"group": "build",
"presentation": {
@ -22,8 +72,10 @@
"label": "Clean",
"detail": "Clean build directory and executable",
"type": "shell",
"command": "rm -rf build",
"command": "rm",
"args": [
"-rf",
"build"
],
"group": "build",
"presentation": {
@ -34,24 +86,6 @@
"showReuseMessage": false,
"clear": true
}
},
{
"label": "Flash",
"detail": "Flash executable",
"type": "shell",
"dependsOn": "Build",
"command": "cd build && make Flash",
"args": [
],
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
}
]
}

View File

@ -15,21 +15,22 @@ set(CMAKE_CXX_STANDARD 17)
pico_sdk_init()
add_executable(PicoSDKProject
add_executable(PicoSDKExec)
target_sources(PicoSDKExec PUBLIC
src/main.c
)
target_link_libraries(PicoSDKProject
target_link_libraries(PicoSDKExec
pico_stdlib
)
# Stdio configuration
pico_enable_stdio_usb(PicoSDKProject 1)
pico_enable_stdio_uart(PicoSDKProject 1)
pico_enable_stdio_usb(PicoSDKExec 1)
pico_enable_stdio_uart(PicoSDKExec 1)
pico_add_extra_outputs(PicoSDKProject)
pico_add_extra_outputs(PicoSDKExec)
add_custom_target(Flash
DEPENDS PicoSDKProject
COMMAND picotool load -f ${PROJECT_BINARY_DIR}/PicoSDKProject.uf2
DEPENDS PicoSDKExec
COMMAND picotool load -f ${PROJECT_BINARY_DIR}/PicoSDKExec.uf2
)

View File

@ -1 +0,0 @@
build/compile_commands.json