@@ -38,6 +38,7 @@ import {
3838 githubApiUnauthorized ,
3939 HTTP_STATUS_FORBIDDEN ,
4040 HTTP_STATUS_OK ,
41+ SDK_REPOSITORY_URL ,
4142} from "./githubREST.mjs" ;
4243import { unxzFile , unzipFile } from "./downloadHelpers.mjs" ;
4344import type { Writable } from "stream" ;
@@ -52,6 +53,7 @@ import {
5253} from "./sharedConstants.mjs" ;
5354import { compareGe } from "./semverUtil.mjs" ;
5455import VersionBundlesLoader from "./versionBundles.mjs" ;
56+ import findPython , { showPythonNotFoundError } from "./pythonHelper.mjs" ;
5557
5658/// Translate nodejs platform names to ninja platform names
5759const NINJA_PLATFORMS : { [ key : string ] : string } = {
@@ -574,6 +576,8 @@ export async function downloadAndInstallSDK(
574576 ( await cloneRepository ( repositoryUrl , version , targetDirectory , gitPath ) )
575577 ) {
576578 settings . reload ( ) ;
579+
580+ // TODO: should already be done by rust project panel
577581 // check python requirements
578582 const python3Exe : string =
579583 python3Path ||
@@ -589,7 +593,10 @@ export async function downloadAndInstallSDK(
589593 "Python3 is not installed and could not be downloaded."
590594 ) ;
591595
592- void window . showErrorMessage ( "Python3 is not installed and in PATH." ) ;
596+ void window . showErrorMessage (
597+ "Python 3 was not found. " +
598+ "Please install Python 3 to complete Pico SDK setup."
599+ ) ;
593600
594601 return false ;
595602 }
@@ -1068,10 +1075,10 @@ export async function downloadAndInstallOpenOCD(
10681075 ? "-aarch64"
10691076 : "-x86_64"
10701077 : process . platform === "darwin"
1071- ? process . arch === "arm64"
1072- ? "-arm64"
1073- : "-x86_64"
1074- : ""
1078+ ? process . arch === "arm64"
1079+ ? "-arm64"
1080+ : "-x86_64"
1081+ : ""
10751082 } -${ TOOLS_PLATFORMS [ process . platform ] } .${ assetExt } `;
10761083
10771084 const extraCallback = ( ) : void => {
@@ -1327,16 +1334,66 @@ export async function installLatestRustRequirements(
13271334 return false ;
13281335 }
13291336
1330- const supportedToolchains = await getSupportedToolchains ( ) ;
1337+ // install python (if necessary)
1338+ const python3Path = await findPython ( ) ;
1339+ if ( ! python3Path ) {
1340+ Logger . error ( LoggerSource . downloader , "Failed to find Python3 executable." ) ;
1341+ showPythonNotFoundError ( ) ;
1342+
1343+ return false ;
1344+ }
13311345
13321346 let result = await window . withProgress (
1347+ {
1348+ location : ProgressLocation . Notification ,
1349+ title : "Downloading and installing SDK" ,
1350+ cancellable : false ,
1351+ } ,
1352+ async progress2 => {
1353+ const result = await downloadAndInstallSDK (
1354+ latest [ 0 ] ,
1355+ SDK_REPOSITORY_URL ,
1356+ // python3Path is only possible undefined if downloaded and
1357+ // there is already checked and returned if this happened
1358+ python3Path . replace ( HOME_VAR , homedir ( ) . replaceAll ( "\\" , "/" ) )
1359+ ) ;
1360+
1361+ if ( ! result ) {
1362+ Logger . error (
1363+ LoggerSource . downloader ,
1364+ "Failed to download and install SDK."
1365+ ) ;
1366+ progress2 . report ( {
1367+ message : "Failed - Make sure all requirements are met." ,
1368+ increment : 100 ,
1369+ } ) ;
1370+
1371+ void window . showErrorMessage (
1372+ "Failed to download and install SDK. " +
1373+ "Make sure all requirements are met."
1374+ ) ;
1375+
1376+ return false ;
1377+ }
1378+
1379+ return true ;
1380+ }
1381+ ) ;
1382+
1383+ if ( ! result ) {
1384+ return false ;
1385+ }
1386+
1387+ const supportedToolchains = await getSupportedToolchains ( ) ;
1388+
1389+ result = await window . withProgress (
13331390 {
13341391 location : ProgressLocation . Notification ,
13351392 title : `Downloading ARM Toolchain for debugging...` ,
13361393 } ,
13371394 async progress => {
13381395 const toolchain = supportedToolchains . find (
1339- t => t . version === latest . toolchain
1396+ t => t . version === latest [ 1 ] . toolchain
13401397 ) ;
13411398
13421399 if ( toolchain === undefined ) {
@@ -1374,7 +1431,7 @@ export async function installLatestRustRequirements(
13741431 } ,
13751432 async progress => {
13761433 const toolchain = supportedToolchains . find (
1377- t => t . version === latest . riscvToolchain
1434+ t => t . version === latest [ 1 ] . riscvToolchain
13781435 ) ;
13791436
13801437 if ( toolchain === undefined ) {
@@ -1437,11 +1494,14 @@ export async function installLatestRustRequirements(
14371494 async progress => {
14381495 let progressState = 0 ;
14391496
1440- return downloadAndInstallPicotool ( latest . picotool , ( prog : Progress ) => {
1441- const percent = prog . percent * 100 ;
1442- progress . report ( { increment : percent - progressState } ) ;
1443- progressState = percent ;
1444- } ) ;
1497+ return downloadAndInstallPicotool (
1498+ latest [ 1 ] . picotool ,
1499+ ( prog : Progress ) => {
1500+ const percent = prog . percent * 100 ;
1501+ progress . report ( { increment : percent - progressState } ) ;
1502+ progressState = percent ;
1503+ }
1504+ ) ;
14451505 }
14461506 ) ;
14471507 if ( ! result ) {
0 commit comments