raspberrypi / pico-vscode

The official VS Code extension for Raspberry Pi Pico development. It includes several features to simplify project creation and deployment.
https://marketplace.visualstudio.com/items?itemName=raspberry-pi.raspberry-pi-pico
Mozilla Public License 2.0
132 stars 16 forks source link

Importing creates duplicate code in CMakeLists.txt #122

Closed trautb closed 1 week ago

trautb commented 1 week ago

Expected Behavior

When importing an existing project the "preamble" in CMakeLists.txt should be recognized and used for importing.

Current Behavior

When importing an existing project the "preamble" in CMakeLists.txt gets added in front of a already present preamble resulting in duplicate code.

Steps to Reproduce

  1. Get a pico project.
  2. Import project via Pico extension.
  3. Import project via Pico extension again (simulate import on another device).

Details

Preamble after second import:

# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==
if(WIN32)
    set(USERHOME $ENV{USERPROFILE})
else()
    set(USERHOME $ENV{HOME})
endif()
set(sdkVersion 2.0.0)
set(toolchainVersion 13_3_Rel1)
set(picotoolVersion 2.0.0)
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
if (EXISTS ${picoVscode})
    include(${picoVscode})
endif()
# ====================================================================================
# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==
if(WIN32)
    set(USERHOME $ENV{USERPROFILE})
else()
    set(USERHOME $ENV{HOME})
endif()
set(sdkVersion 2.0.0)
set(toolchainVersion 13_3_Rel1)
set(picotoolVersion 2.0.0)
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
if (EXISTS ${picoVscode})
    include(${picoVscode})
endif()
# ====================================================================================

Context (Environment)

will-v-pi commented 1 week ago

The second import shouldn't be required here - when you open the project on a second device the extension should download all the required tools automatically?

trautb commented 1 week ago

Sorry for bothering... The CMakeLists.txt had an old version of the "preamble" starting with

# == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work ==

instead of

# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==

The extension did not recognize that old version, therefore the import was neccessary. With the updated CMakeLists.txt the import is not neccessary anymore, therefore no duplicated code. ;)