Skip to content

Commit d975f43

Browse files
committed
Fix #235, Zephyr CMakeLists project prefix detection
Signed-off-by: paulober <[email protected]>
1 parent 3c95db7 commit d975f43

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/extension.mts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ import { cmakeToolsForcePicoKit } from "./utils/cmakeToolsUtil.mjs";
101101
import { NewRustProjectPanel } from "./webview/newRustProjectPanel.mjs";
102102
import {
103103
CMAKELISTS_ZEPHYR_HEADER,
104+
CMAKELISTS_ZEPHYR_REGEX,
104105
OPENOCD_VERSION,
105106
SDK_REPOSITORY_URL,
106107
} from "./utils/sharedConstants.mjs";
@@ -319,8 +320,8 @@ export async function activate(context: ExtensionContext): Promise<void> {
319320
await workspace.fs.readFile(Uri.file(cmakeListsFilePath))
320321
);
321322

322-
// Check for pico_zephyr in CMakeLists.txt
323-
if (cmakeListsContents.startsWith(CMAKELISTS_ZEPHYR_HEADER)) {
323+
// Check for zephyr pico project prefix line in CMakeLists.txt
324+
if (cmakeListsContents.trimStart().match(CMAKELISTS_ZEPHYR_REGEX)) {
324325
Logger.info(LoggerSource.extension, "Project is of type: Zephyr");
325326

326327
const vb = new VersionBundlesLoader(context.extensionUri);

src/utils/sharedConstants.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const LICENSE_URL_7ZIP = "https://7-zip.org/license.txt";
3737
export const WINDOWS_X86_7ZIP_DOWNLOAD_URL = "https://www.7-zip.org/a/7zr.exe";
3838

3939
export const CMAKELISTS_ZEPHYR_HEADER = "#pico-zephyr-project";
40+
export const CMAKELISTS_ZEPHYR_REGEX = /^#\s*pico-zephyr-project\s*$/mi;
4041

4142
export const HTTP_STATUS_OK = 200;
4243
export const HTTP_STATUS_NOT_MODIFIED = 304;

0 commit comments

Comments
 (0)