diff --git a/scripts/pico_project.py b/scripts/pico_project.py index 249f9f7..62b5ec9 100644 --- a/scripts/pico_project.py +++ b/scripts/pico_project.py @@ -583,9 +583,9 @@ def GenerateCMake(folder, params): "# (note this can come from environment, CMake cache etc)\n\n" ) - # if you change the do never edit headline you need to change the check for it in extension.mts + # if you change the do not edit headline you need to change the check for it in extension.mts cmake_header_us = ( - "# == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work ==\n" + "# == DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work ==\n" "if(WIN32)\n" " set(USERHOME $ENV{USERPROFILE})\n" "else()\n" diff --git a/src/extension.mts b/src/extension.mts index 15b2b76..83f276e 100644 --- a/src/extension.mts +++ b/src/extension.mts @@ -16,6 +16,7 @@ import NewProjectCommand from "./commands/newProject.mjs"; import Logger, { LoggerSource } from "./logger.mjs"; import { CMAKE_DO_NOT_EDIT_HEADER_PREFIX, + CMAKE_DO_NOT_EDIT_HEADER_PREFIX_OLD, cmakeGetSelectedBoard, cmakeGetSelectedToolchainAndSDKVersions, configureCmakeNinja, @@ -209,9 +210,14 @@ export async function activate(context: ExtensionContext): Promise { // check if it has .vscode folder and cmake donotedit header in CMakelists.txt if ( !existsSync(join(workspaceFolder.uri.fsPath, ".vscode")) || - !readFileSync(cmakeListsFilePath) - .toString("utf-8") - .includes(CMAKE_DO_NOT_EDIT_HEADER_PREFIX) + !( + readFileSync(cmakeListsFilePath) + .toString("utf-8") + .includes(CMAKE_DO_NOT_EDIT_HEADER_PREFIX) || + readFileSync(cmakeListsFilePath) + .toString("utf-8") + .includes(CMAKE_DO_NOT_EDIT_HEADER_PREFIX_OLD) + ) ) { Logger.warn( LoggerSource.extension, diff --git a/src/utils/cmakeUtil.mts b/src/utils/cmakeUtil.mts index dc589db..4c5db34 100644 --- a/src/utils/cmakeUtil.mts +++ b/src/utils/cmakeUtil.mts @@ -15,6 +15,9 @@ import { buildCMakeIncPath } from "./download.mjs"; export const CMAKE_DO_NOT_EDIT_HEADER_PREFIX = // eslint-disable-next-line max-len + "== DO NOT EDIT THE FOLLOWING LINES for the Raspberry Pi Pico VS Code Extension to work =="; +export const CMAKE_DO_NOT_EDIT_HEADER_PREFIX_OLD = +// eslint-disable-next-line max-len "== DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work =="; export async function getPythonPath(): Promise { @@ -322,7 +325,8 @@ export async function cmakeUpdateSDK( const cmakeFilePath = join(folder.fsPath, "CMakeLists.txt"); // This regex requires multiline (m) and dotall (s) flags to work const updateSectionRegex = new RegExp( - `^# ${CMAKE_DO_NOT_EDIT_HEADER_PREFIX}.*# =+$`, + `^# (${CMAKE_DO_NOT_EDIT_HEADER_PREFIX}` + + `|${CMAKE_DO_NOT_EDIT_HEADER_PREFIX_OLD}).*# =+$`, "ms" ); const picoBoardRegex = /^set\(PICO_BOARD\s+([^)]+)\)$/m;