Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling of cargo-download not beeing installed #129

Merged
merged 1 commit into from
May 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions hermit-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ use target_build_utils::TargetInfo;
use walkdir::{DirEntry, WalkDir};

fn build_hermit(src_dir: &Path, target_dir_opt: Option<&Path>) {
assert!(
src_dir.exists(),
"rusty_hermit source folder does not exist"
);
let target = TargetInfo::new().expect("Could not get target info");
let profile = env::var("PROFILE").expect("PROFILE was not set");
let mut cmd = Command::new("cargo");
Expand Down Expand Up @@ -186,15 +190,20 @@ fn build() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let src_dir = out_dir.join("rusty-hermit");

let _output = Command::new("cargo")
.current_dir(out_dir)
.arg("download")
.arg("--output")
.arg(src_dir.clone().into_os_string())
.arg("--extract")
.arg("rusty-hermit")
.output()
.expect("Unable to download rusty-hermit. Please install `cargo-download`.");
if !src_dir.as_path().exists() {
let cargo_download = Command::new("cargo")
.current_dir(out_dir)
.arg("download")
.arg("--output")
.arg(src_dir.clone().into_os_string())
.arg("--extract")
.arg("rusty-hermit")
.output()
.expect("could not launch cargo download");
if !cargo_download.status.success() {
panic!("Unable to download rusty-hermit. Is `cargo-download` installed?.");
}
}

build_hermit(src_dir.as_ref(), None);
}
Expand Down