@@ -685,6 +685,126 @@ async function checkOpenOCD(): Promise<boolean> {
685685 ) ;
686686}
687687
688+ async function fetchBinaryBlobs (
689+ westExe : string ,
690+ zephyrWorkspaceDirectory : string ,
691+ customEnv : NodeJS . ProcessEnv
692+ ) : Promise < boolean > {
693+ const sleep = ( ms : number ) : Promise < void > =>
694+ new Promise < void > ( res => setTimeout ( res , ms ) ) ;
695+
696+ const runOnce = async ( ) : Promise < boolean > =>
697+ window . withProgress (
698+ {
699+ location : ProgressLocation . Notification ,
700+ title : "Fetching Zephyr binary blobs" ,
701+ cancellable : false ,
702+ } ,
703+ async progress2 => {
704+ const westBlobsFetchCommand : string =
705+ `"${ westExe } " blobs fetch ` + "hal_infineon" ;
706+
707+ const result = await _runCommand ( westBlobsFetchCommand , {
708+ cwd : zephyrWorkspaceDirectory ,
709+ windowsHide : true ,
710+ env : customEnv ,
711+ } ) ;
712+
713+ if ( result === 0 ) {
714+ progress2 . report ( {
715+ message : "Success" ,
716+ increment : 100 ,
717+ } ) ;
718+
719+ return true ;
720+ } else {
721+ progress2 . report ( {
722+ message : "Failed" ,
723+ increment : 100 ,
724+ } ) ;
725+
726+ return false ;
727+ }
728+ }
729+ ) ;
730+
731+ // first attempt
732+ const first = await runOnce ( ) ;
733+ if ( first ) {
734+ return true ;
735+ }
736+
737+ // retry once after a brief delay
738+ await sleep ( 1000 ) ;
739+
740+ return runOnce ( ) ;
741+ }
742+
743+ async function installWestPyDeps (
744+ westExe : string ,
745+ zephyrWorkspaceDirectory : string ,
746+ customEnv : NodeJS . ProcessEnv
747+ ) : Promise < boolean > {
748+ const sleep = ( ms : number ) : Promise < void > =>
749+ new Promise < void > ( res => setTimeout ( res , ms ) ) ;
750+
751+ const runOnce = async ( ) : Promise < boolean > =>
752+ window . withProgress (
753+ {
754+ location : ProgressLocation . Notification ,
755+ title : "Installing West Python dependencies" ,
756+ cancellable : false ,
757+ } ,
758+ async progress2 => {
759+ const westPipPackagesCommand : string =
760+ `"${ westExe } " packages ` + "pip --install" ;
761+
762+ const result = await _runCommand ( westPipPackagesCommand , {
763+ cwd : zephyrWorkspaceDirectory ,
764+ windowsHide : true ,
765+ env : customEnv ,
766+ } ) ;
767+
768+ if ( result === 0 ) {
769+ Logger . debug (
770+ LoggerSource . zephyrSetup ,
771+ "West Python dependencies installed."
772+ ) ;
773+ progress2 . report ( {
774+ message : "Success" ,
775+ increment : 100 ,
776+ } ) ;
777+
778+ return true ;
779+ } else {
780+ Logger . error (
781+ LoggerSource . zephyrSetup ,
782+ "Error installing West Python dependencies."
783+ ) ;
784+ progress2 . report ( {
785+ message : "Failed" ,
786+ increment : 100 ,
787+ } ) ;
788+
789+ return false ;
790+ }
791+ }
792+ ) ;
793+
794+ const first = await runOnce ( ) ;
795+ if ( first ) {
796+ return true ;
797+ }
798+ Logger . debug (
799+ LoggerSource . zephyrSetup ,
800+ "Retrying installation of West Python dependencies..."
801+ ) ;
802+
803+ await sleep ( 1000 ) ;
804+
805+ return runOnce ( ) ;
806+ }
807+
688808export async function setupZephyr (
689809 data : ZephyrSetupValue ,
690810 gitExe ?: string
@@ -960,6 +1080,10 @@ export async function setupZephyr(
9601080 message : "Failed" ,
9611081 increment : 100 ,
9621082 } ) ;
1083+ void window . showErrorMessage (
1084+ "Failed to create Python virtual environment for Zephyr. " +
1085+ "Cannot continue Zephyr setup."
1086+ ) ;
9631087
9641088 return false ;
9651089 }
@@ -1006,6 +1130,10 @@ export async function setupZephyr(
10061130 message : "Failed" ,
10071131 increment : 100 ,
10081132 } ) ;
1133+ void window . showErrorMessage (
1134+ "Failed to install West and / or pyelftools in the Zephyr Python " +
1135+ "virtual environment. Cannot continue Zephyr setup."
1136+ ) ;
10091137
10101138 return false ;
10111139 }
@@ -1095,6 +1223,10 @@ export async function setupZephyr(
10951223 message : "Failed" ,
10961224 increment : 100 ,
10971225 } ) ;
1226+ void window . showErrorMessage (
1227+ "Failed to setup West workspace and / or download zephyr. " +
1228+ "Cannot continue Zephyr setup."
1229+ ) ;
10981230
10991231 return false ;
11001232 }
@@ -1122,94 +1254,40 @@ export async function setupZephyr(
11221254 return false ;
11231255 }
11241256
1125- installedSuccessfully = await window . withProgress (
1126- {
1127- location : ProgressLocation . Notification ,
1128- title : "Installing West Python dependencies" ,
1129- cancellable : false ,
1130- } ,
1131- async progress2 => {
1132- const westPipPackagesCommand : string =
1133- `"${ westExe } " packages ` + "pip --install" ;
1134-
1135- result = await _runCommand ( westPipPackagesCommand , {
1136- cwd : zephyrWorkspaceDirectory ,
1137- windowsHide : true ,
1138- env : customEnv ,
1139- } ) ;
1140-
1141- if ( result === 0 ) {
1142- Logger . debug (
1143- LoggerSource . zephyrSetup ,
1144- "West Python dependencies installed."
1145- ) ;
1146- progress2 . report ( {
1147- message : "Success" ,
1148- increment : 100 ,
1149- } ) ;
1150-
1151- return true ;
1152- } else {
1153- Logger . error (
1154- LoggerSource . zephyrSetup ,
1155- "Error installing West Python dependencies."
1156- ) ;
1157- progress2 . report ( {
1158- message : "Failed" ,
1159- increment : 100 ,
1160- } ) ;
1161-
1162- return false ;
1163- }
1164- }
1257+ installedSuccessfully = await installWestPyDeps (
1258+ westExe ,
1259+ zephyrWorkspaceDirectory ,
1260+ customEnv
11651261 ) ;
11661262 if ( ! installedSuccessfully ) {
11671263 progress . report ( {
11681264 message : "Failed" ,
11691265 increment : 100 ,
11701266 } ) ;
1267+ void window . showErrorMessage (
1268+ "Failed to install West Python dependencies. " +
1269+ "Cannot continue Zephyr setup. " +
1270+ "See extension host output for more details."
1271+ ) ;
11711272
11721273 return false ;
11731274 }
11741275
1175- installedSuccessfully = await window . withProgress (
1176- {
1177- location : ProgressLocation . Notification ,
1178- title : "Fetching Zephyr binary blobs" ,
1179- cancellable : false ,
1180- } ,
1181- async progress2 => {
1182- const westBlobsFetchCommand : string =
1183- `"${ westExe } " blobs fetch ` + "hal_infineon" ;
1184-
1185- result = await _runCommand ( westBlobsFetchCommand , {
1186- cwd : zephyrWorkspaceDirectory ,
1187- windowsHide : true ,
1188- env : customEnv ,
1189- } ) ;
1190-
1191- if ( result === 0 ) {
1192- progress2 . report ( {
1193- message : "Success" ,
1194- increment : 100 ,
1195- } ) ;
1196-
1197- return true ;
1198- } else {
1199- progress2 . report ( {
1200- message : "Failed" ,
1201- increment : 100 ,
1202- } ) ;
1203-
1204- return false ;
1205- }
1206- }
1276+ installedSuccessfully = await fetchBinaryBlobs (
1277+ westExe ,
1278+ zephyrWorkspaceDirectory ,
1279+ customEnv
12071280 ) ;
12081281 if ( ! installedSuccessfully ) {
12091282 progress . report ( {
12101283 message : "Failed" ,
12111284 increment : 100 ,
12121285 } ) ;
1286+ void window . showErrorMessage (
1287+ "Failed to fetch Zephyr binary blobs. " +
1288+ "Cannot continue Zephyr setup. " +
1289+ "See extension host output for more details."
1290+ ) ;
12131291
12141292 return false ;
12151293 }
0 commit comments