@@ -396,7 +396,12 @@ export async function downloadAndInstallRust(): Promise<string | undefined> {
396396
397397 const index = await downloadAndReadFile ( STABLE_INDEX_DOWNLOAD_URL ) ;
398398 if ( ! index ) {
399- // TODO: undo rust download
399+ try {
400+ rmSync ( targetDirectory , { recursive : true , force : true } ) ;
401+ } catch {
402+ /* */
403+ }
404+
400405 return undefined ;
401406 }
402407 Logger . debug ( LoggerSource . rustUtil , "Downloaded Rust index file" ) ;
@@ -441,14 +446,26 @@ export async function downloadAndInstallRust(): Promise<string | undefined> {
441446 ) ;
442447
443448 if ( ! result ) {
444- return undefined ;
449+ try {
450+ rmSync ( targetDirectory , { recursive : true , force : true } ) ;
451+ } catch {
452+ /* */
453+ }
454+
455+ return ;
445456 }
446457 } else {
447458 Logger . error (
448459 LoggerSource . rustUtil ,
449460 "Error parsing Rust index file: std not available"
450461 ) ;
451462
463+ try {
464+ rmSync ( targetDirectory , { recursive : true , force : true } ) ;
465+ } catch {
466+ /* */
467+ }
468+
452469 return ;
453470 }
454471
@@ -489,14 +506,26 @@ export async function downloadAndInstallRust(): Promise<string | undefined> {
489506 ) ;
490507
491508 if ( ! result ) {
492- return undefined ;
509+ try {
510+ rmSync ( targetDirectory , { recursive : true , force : true } ) ;
511+ } catch {
512+ /* */
513+ }
514+
515+ return ;
493516 }
494517 } else {
495518 Logger . error (
496519 LoggerSource . rustUtil ,
497520 "Error parsing Rust index file: analysis not available"
498521 ) ;
499522
523+ try {
524+ rmSync ( targetDirectory , { recursive : true , force : true } ) ;
525+ } catch {
526+ /* */
527+ }
528+
500529 return ;
501530 }
502531
@@ -515,7 +544,13 @@ export async function downloadAndInstallRust(): Promise<string | undefined> {
515544 ) ;
516545 // TODO: error handling
517546 if ( ! result ) {
518- return undefined ;
547+ try {
548+ rmSync ( targetDirectory , { recursive : true , force : true } ) ;
549+ } catch {
550+ /* */
551+ }
552+
553+ return ;
519554 }
520555 }
521556
@@ -533,32 +568,53 @@ export async function downloadAndInstallRust(): Promise<string | undefined> {
533568 }
534569 const hd = homedir ( ) . replaceAll ( "\\" , "/" ) ;
535570 // TODO: install cmake
536- result = await cargoInstall ( cargoExecutable , "probe-rs-tools" , true , {
537- PATH : `${ hd } /.pico-sdk/cmake/v3.28.6/bin;${ hd } /.pico-sdk/rust/latest/bin;${ hd } /.pico-sdk/msvc/latest/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/bin/10.0.19041.0/x64;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/bin/10.0.19041.0/x64/ucrt` ,
538-
539- // eslint-disable-next-line @typescript-eslint/naming-convention
540- VSCMD_ARG_HOST_ARCH : "x64" ,
541- // eslint-disable-next-line @typescript-eslint/naming-convention
542- VSCMD_ARG_TGT_ARCH : "x64" ,
543- // eslint-disable-next-line @typescript-eslint/naming-convention
544- VCToolsVersion : "14.41.34120" ,
545- // eslint-disable-next-line @typescript-eslint/naming-convention
546- WindowsSDKVersion : "10.0.19041.0" ,
547- // eslint-disable-next-line @typescript-eslint/naming-convention, max-len
548- VCToolsInstallDir : `${ hd } /.pico-sdk/msvc/latest/VC/Tools/MSVC/14.41.34120/` ,
549- // eslint-disable-next-line @typescript-eslint/naming-convention
550- WindowsSdkBinPath : `${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/bin/` ,
551- // eslint-disable-next-line @typescript-eslint/naming-convention, max-len
552- INCLUDE : `${ hd } /.pico-sdk/msvc/latest/VC/Tools/MSVC/14.41.34120/include;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Include/10.0.19041.0/ucrt;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Include/10.0.19041.0/shared;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Include/10.0.19041.0/um;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Include/10.0.19041.0/winrt;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Include/10.0.19041.0/cppwinrt` ,
553- // eslint-disable-next-line @typescript-eslint/naming-convention, max-len
554- LIB : `${ hd } /.pico-sdk/msvc/latest/VC/Tools/MSVC/14.41.34120/lib/x64;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Lib/10.0.19041.0/um/x64` ,
555- } ) ;
571+ result = await cargoInstall (
572+ cargoExecutable ,
573+ "probe-rs-tools" ,
574+ true ,
575+ // TODO: load cmake version dynamically and download if not present
576+ process . platform === "win32"
577+ ? {
578+ PATH : `${ hd } /.pico-sdk/cmake/v3.28.6/bin;${ hd } /.pico-sdk/rust/latest/bin;${ hd } /.pico-sdk/msvc/latest/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/bin/10.0.19041.0/x64;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/bin/10.0.19041.0/x64/ucrt` ,
579+
580+ // eslint-disable-next-line @typescript-eslint/naming-convention
581+ VSCMD_ARG_HOST_ARCH : "x64" ,
582+ // eslint-disable-next-line @typescript-eslint/naming-convention
583+ VSCMD_ARG_TGT_ARCH : "x64" ,
584+ // eslint-disable-next-line @typescript-eslint/naming-convention
585+ VCToolsVersion : "14.41.34120" ,
586+ // eslint-disable-next-line @typescript-eslint/naming-convention
587+ WindowsSDKVersion : "10.0.19041.0" ,
588+ // eslint-disable-next-line @typescript-eslint/naming-convention, max-len
589+ VCToolsInstallDir : `${ hd } /.pico-sdk/msvc/latest/VC/Tools/MSVC/14.41.34120/` ,
590+ // eslint-disable-next-line @typescript-eslint/naming-convention
591+ WindowsSdkBinPath : `${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/bin/` ,
592+ // eslint-disable-next-line @typescript-eslint/naming-convention, max-len
593+ INCLUDE : `${ hd } /.pico-sdk/msvc/latest/VC/Tools/MSVC/14.41.34120/include;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Include/10.0.19041.0/ucrt;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Include/10.0.19041.0/shared;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Include/10.0.19041.0/um;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Include/10.0.19041.0/winrt;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Include/10.0.19041.0/cppwinrt` ,
594+ // eslint-disable-next-line @typescript-eslint/naming-convention, max-len
595+ LIB : `${ hd } /.pico-sdk/msvc/latest/VC/Tools/MSVC/14.41.34120/lib/x64;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64;${ hd } /.pico-sdk/msvc/latest/Windows Kits/10/Lib/10.0.19041.0/um/x64` ,
596+ }
597+ : // eslint-disable-next-line @typescript-eslint/naming-convention
598+ { PATH : `${ hd } /.pico-sdk/cmake/v3.28.6/bin` }
599+ ) ;
556600 if ( ! result ) {
557- return undefined ;
601+ try {
602+ rmSync ( targetDirectory , { recursive : true , force : true } ) ;
603+ } catch {
604+ /* */
605+ }
606+
607+ return ;
558608 }
559609 result = await cargoInstall ( cargoExecutable , "elf2uf2-rs" , true , { } ) ;
560610 if ( ! result ) {
561- return undefined ;
611+ try {
612+ rmSync ( targetDirectory , { recursive : true , force : true } ) ;
613+ } catch {
614+ /* */
615+ }
616+
617+ return ;
562618 }
563619
564620 if ( existingInstallation ) {
@@ -581,6 +637,12 @@ export async function downloadAndInstallRust(): Promise<string | undefined> {
581637 unknownErrorToString ( error )
582638 ) ;
583639
584- return undefined ;
640+ try {
641+ rmSync ( targetDirectory , { recursive : true , force : true } ) ;
642+ } catch {
643+ /* */
644+ }
645+
646+ return ;
585647 }
586648}
0 commit comments