mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-02-08 07:16:31 -05:00
Fallback to curl if download_file.py fails (#373)
This commit is contained in:
parent
a9ea69b5d5
commit
d87341a7ce
1 changed files with 34 additions and 13 deletions
47
build.rs
47
build.rs
|
@ -187,6 +187,39 @@ fn static_lib_url() -> (String, String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn download_file(url: String, filename: PathBuf) {
|
||||||
|
// Try downloading with python first. Python is a V8 build dependency,
|
||||||
|
// so this saves us from adding a Rust HTTP client dependency.
|
||||||
|
println!("Downloading {}", url);
|
||||||
|
let status = Command::new("python")
|
||||||
|
.arg("./tools/download_file.py")
|
||||||
|
.arg("--url")
|
||||||
|
.arg(&url)
|
||||||
|
.arg("--filename")
|
||||||
|
.arg(&filename)
|
||||||
|
.status();
|
||||||
|
|
||||||
|
// Python is only a required dependency for `V8_FROM_SOURCE` builds.
|
||||||
|
// If python is not available, try falling back to curl.
|
||||||
|
let status = match status {
|
||||||
|
Ok(status) if status.success() => status,
|
||||||
|
_ => {
|
||||||
|
println!("Python downloader failed, trying with curl.");
|
||||||
|
Command::new("curl")
|
||||||
|
.arg("-L")
|
||||||
|
.arg("-s")
|
||||||
|
.arg("-o")
|
||||||
|
.arg(&filename)
|
||||||
|
.arg(&url)
|
||||||
|
.status()
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert!(status.success());
|
||||||
|
assert!(filename.exists());
|
||||||
|
}
|
||||||
|
|
||||||
fn download_static_lib_binaries() {
|
fn download_static_lib_binaries() {
|
||||||
let (url, static_lib_name) = static_lib_url();
|
let (url, static_lib_name) = static_lib_url();
|
||||||
println!("static lib URL: {}", url);
|
println!("static lib URL: {}", url);
|
||||||
|
@ -216,19 +249,7 @@ fn download_static_lib_binaries() {
|
||||||
println!("static lib already exists {}", filename.display());
|
println!("static lib already exists {}", filename.display());
|
||||||
println!("To re-download this file, it must be manually deleted.");
|
println!("To re-download this file, it must be manually deleted.");
|
||||||
} else {
|
} else {
|
||||||
// Using python to do the HTTP download because it's already a dependency
|
download_file(url, filename);
|
||||||
// and so we don't have to add a Rust HTTP client dependency.
|
|
||||||
println!("Downloading {}", url);
|
|
||||||
let status = Command::new("python")
|
|
||||||
.arg("./tools/download_file.py")
|
|
||||||
.arg("--url")
|
|
||||||
.arg(url)
|
|
||||||
.arg("--filename")
|
|
||||||
.arg(&filename)
|
|
||||||
.status()
|
|
||||||
.unwrap();
|
|
||||||
assert!(status.success());
|
|
||||||
assert!(filename.exists());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue