Skip to content

Commit 95db93b

Browse files
authored
Update detection to use pico_sdk_init() (#178)
Update project detection to use pico_sdk_init() instead of pico_sdk_import.cmake Fixes #177
1 parent 4cedc72 commit 95db93b

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/extension.mts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,12 @@ export async function activate(context: ExtensionContext): Promise<void> {
176176

177177
const workspaceFolder = workspace.workspaceFolders?.[0];
178178

179-
// check if is a pico project
180-
if (
181-
workspaceFolder === undefined ||
182-
!existsSync(join(workspaceFolder.uri.fsPath, "pico_sdk_import.cmake"))
183-
) {
179+
// check if there is a workspace folder
180+
if (workspaceFolder === undefined) {
184181
// finish activation
185182
Logger.warn(
186183
LoggerSource.extension,
187-
"No workspace folder or Pico project found."
184+
"No workspace folder found."
188185
);
189186
await commands.executeCommand(
190187
"setContext",
@@ -210,6 +207,25 @@ export async function activate(context: ExtensionContext): Promise<void> {
210207
return;
211208
}
212209

210+
// check for pico_sdk_init() in CMakeLists.txt
211+
if (
212+
!readFileSync(cmakeListsFilePath)
213+
.toString("utf-8")
214+
.includes("pico_sdk_init()")
215+
) {
216+
Logger.warn(
217+
LoggerSource.extension,
218+
"No pico_sdk_init() in CMakeLists.txt found."
219+
);
220+
await commands.executeCommand(
221+
"setContext",
222+
ContextKeys.isPicoProject,
223+
false
224+
);
225+
226+
return;
227+
}
228+
213229
// check if it has .vscode folder and cmake donotedit header in CMakelists.txt
214230
if (
215231
!existsSync(join(workspaceFolder.uri.fsPath, ".vscode")) ||

0 commit comments

Comments
 (0)