@@ -95,6 +95,7 @@ import State from "./state.mjs";
9595import { cmakeToolsForcePicoKit } from "./utils/cmakeToolsUtil.mjs" ;
9696import { NewRustProjectPanel } from "./webview/newRustProjectPanel.mjs" ;
9797import { OPENOCD_VERSION } from "./utils/sharedConstants.mjs" ;
98+ import VersionBundlesLoader from "./utils/versionBundles.mjs" ;
9899
99100export async function activate ( context : ExtensionContext ) : Promise < void > {
100101 Logger . info ( LoggerSource . extension , "Extension activation triggered" ) ;
@@ -306,6 +307,69 @@ export async function activate(context: ExtensionContext): Promise<void> {
306307 await commands . executeCommand ( "setContext" , ContextKeys . isPicoProject , true ) ;
307308
308309 if ( isRustProject ) {
310+ const vs = new VersionBundlesLoader ( context . extensionUri ) ;
311+ const latestSDK = await vs . getLatestSDK ( ) ;
312+ if ( ! latestSDK ) {
313+ Logger . error (
314+ LoggerSource . extension ,
315+ "Failed to get latest Pico SDK version for Rust project."
316+ ) ;
317+ void window . showErrorMessage (
318+ "Failed to get latest Pico SDK version for Rust project."
319+ ) ;
320+
321+ return ;
322+ }
323+
324+ const sdk = await window . withProgress (
325+ {
326+ location : ProgressLocation . Notification ,
327+ title :
328+ "Downloading and installing latest Pico SDK (" +
329+ latestSDK +
330+ "). This may take a while..." ,
331+ cancellable : false ,
332+ } ,
333+ async progress => {
334+ const result = await downloadAndInstallSDK (
335+ latestSDK ,
336+ SDK_REPOSITORY_URL
337+ ) ;
338+
339+ progress . report ( {
340+ increment : 100 ,
341+ } ) ;
342+
343+ if ( ! result ) {
344+ installSuccess = false ;
345+
346+ Logger . error (
347+ LoggerSource . extension ,
348+ "Failed to install latest SDK" ,
349+ `version: ${ latestSDK } .` ,
350+ "Make sure all requirements are met."
351+ ) ;
352+
353+ void window . showErrorMessage (
354+ "Failed to install latest SDK version for rust project."
355+ ) ;
356+
357+ return false ;
358+ } else {
359+ Logger . info (
360+ LoggerSource . extension ,
361+ "Found/installed latest SDK" ,
362+ `version: ${ latestSDK } `
363+ ) ;
364+
365+ return true ;
366+ }
367+ }
368+ ) ;
369+ if ( ! sdk ) {
370+ return ;
371+ }
372+
309373 const cargo = await window . withProgress (
310374 {
311375 location : ProgressLocation . Notification ,
0 commit comments