Skip to content

Commit d8468bf

Browse files
committed
Add zephyr setup on opening of zephyr pico projects
Signed-off-by: paulober <[email protected]>
1 parent ac6a004 commit d8468bf

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/extension.mts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ import {
112112
} from "./utils/sharedConstants.mjs";
113113
import VersionBundlesLoader from "./utils/versionBundles.mjs";
114114
import { unknownErrorToString } from "./utils/errorHelper.mjs";
115+
import { setupZephyr } from "./utils/setupZephyr.mjs";
115116

116117
export async function activate(context: ExtensionContext): Promise<void> {
117118
Logger.info(LoggerSource.extension, "Extension activation triggered");
@@ -281,6 +282,36 @@ export async function activate(context: ExtensionContext): Promise<void> {
281282
// Check for pico_zephyr in CMakeLists.txt
282283
if (cmakeListsContents.startsWith(CMAKELISTS_ZEPHYR_HEADER)) {
283284
Logger.info(LoggerSource.extension, "Project is of type: Zephyr");
285+
286+
const vb = new VersionBundlesLoader(context.extensionUri);
287+
const latest = await vb.getLatest();
288+
if (latest === undefined) {
289+
Logger.error(
290+
LoggerSource.extension,
291+
"Failed to get latest version bundle for Zephyr project."
292+
);
293+
294+
void window.showErrorMessage(
295+
"Failed to get latest version bundle for Zephyr project."
296+
);
297+
298+
return;
299+
}
300+
301+
const result = await setupZephyr({
302+
extUri: context.extensionUri,
303+
cmakeMode: 4,
304+
cmakePath: latest[1].cmake,
305+
cmakeVersion: "",
306+
});
307+
if (result === undefined) {
308+
void window.showErrorMessage(
309+
"Failed to setup Zephyr Toolchain. See logs for details."
310+
);
311+
312+
return;
313+
}
314+
284315
await commands.executeCommand(
285316
"setContext",
286317
ContextKeys.isPicoProject,
@@ -293,9 +324,6 @@ export async function activate(context: ExtensionContext): Promise<void> {
293324
);
294325
State.getInstance().isZephyrProject = true;
295326

296-
// TODO: !!!!!!!!! IMPORTANT !!!!!!!!!
297-
// TODO: make sure zephy dependencies are installed
298-
299327
ui.showStatusBarItems(false, true);
300328

301329
// Update the board info if it can be found in tasks.json

0 commit comments

Comments
 (0)