diff --git a/scripts/pico_project.py b/scripts/pico_project.py index fe9bd40..a18e352 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 cb3309f..96e4f84 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, @@ -207,9 +208,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 8608c30..41927fd 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 { @@ -333,7 +336,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;