Skip to content

Commit

Permalink
add custom cache dir location and remove cache dir after install
Browse files Browse the repository at this point in the history
  • Loading branch information
dankmeme01 committed Sep 13, 2024
1 parent 4a9afe1 commit a67d0d3
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use reqwest::header::{AUTHORIZATION, USER_AGENT};
use semver::{Prerelease, Version};
use serde::Deserialize;
use std::env;
use std::ffi::OsStr;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
Expand Down Expand Up @@ -813,6 +814,8 @@ fn install_linux(
let get_winsdk = !splat_path.exists() || force_update_winsdk;

if get_winsdk {
let cache_path = splat_path.parent().unwrap().join(".xwin-cache");

info!("Installing Windows SDK to {splat_path:?}");

let _ = std::fs::remove_dir_all(&splat_path);
Expand All @@ -821,26 +824,29 @@ fn install_linux(

cmd.arg("--accept-license");
cmd.args(["--arch", &arch]);

// this argument must come before `splat`

// these arguments must come before `splat`

if let Some(winsdk_version) = winsdk_version {
cmd.args(["--sdk-version", &winsdk_version]);
}

cmd.args([OsStr::new("--cache-dir"), cache_path.as_os_str()]);

cmd.arg("splat");
cmd.args([
"--output",
splat_path
.to_str()
.nice_unwrap("Failed to convert path to str"),
]);
cmd.args([OsStr::new("--output"), splat_path.as_os_str()]);
cmd.arg("--include-debug-libs");

let status = cmd.status().nice_unwrap("Failed to execute xwin");

if !status.success() {
fatal!("xwin failed with code {}", status.code().unwrap_or_default());
fatal!(
"xwin failed with code {}",
status.code().unwrap_or_default()
);
}

let _ = std::fs::remove_dir_all(cache_path);
}

if toolchain_path.exists() {
Expand Down

0 comments on commit a67d0d3

Please sign in to comment.