@@ -10,6 +10,7 @@ use reqwest::header::{AUTHORIZATION, USER_AGENT};
1010use semver:: { Prerelease , Version } ;
1111use serde:: Deserialize ;
1212use std:: env;
13+ use std:: ffi:: OsStr ;
1314use std:: fs;
1415use std:: path:: { Path , PathBuf } ;
1516use std:: process:: Command ;
@@ -813,6 +814,8 @@ fn install_linux(
813814 let get_winsdk = !splat_path. exists ( ) || force_update_winsdk;
814815
815816 if get_winsdk {
817+ let cache_path = splat_path. parent ( ) . unwrap ( ) . join ( ".xwin-cache" ) ;
818+
816819 info ! ( "Installing Windows SDK to {splat_path:?}" ) ;
817820
818821 let _ = std:: fs:: remove_dir_all ( & splat_path) ;
@@ -821,26 +824,29 @@ fn install_linux(
821824
822825 cmd. arg ( "--accept-license" ) ;
823826 cmd. args ( [ "--arch" , & arch] ) ;
824-
825- // this argument must come before `splat`
827+
828+ // these arguments must come before `splat`
829+
826830 if let Some ( winsdk_version) = winsdk_version {
827831 cmd. args ( [ "--sdk-version" , & winsdk_version] ) ;
828832 }
829833
834+ cmd. args ( [ OsStr :: new ( "--cache-dir" ) , cache_path. as_os_str ( ) ] ) ;
835+
830836 cmd. arg ( "splat" ) ;
831- cmd. args ( [
832- "--output" ,
833- splat_path
834- . to_str ( )
835- . nice_unwrap ( "Failed to convert path to str" ) ,
836- ] ) ;
837+ cmd. args ( [ OsStr :: new ( "--output" ) , splat_path. as_os_str ( ) ] ) ;
837838 cmd. arg ( "--include-debug-libs" ) ;
838839
839840 let status = cmd. status ( ) . nice_unwrap ( "Failed to execute xwin" ) ;
840-
841+
841842 if !status. success ( ) {
842- fatal ! ( "xwin failed with code {}" , status. code( ) . unwrap_or_default( ) ) ;
843+ fatal ! (
844+ "xwin failed with code {}" ,
845+ status. code( ) . unwrap_or_default( )
846+ ) ;
843847 }
848+
849+ let _ = std:: fs:: remove_dir_all ( cache_path) ;
844850 }
845851
846852 if toolchain_path. exists ( ) {
0 commit comments