|
|
@ -9,6 +9,7 @@ use log::debug; |
|
|
|
use log::{info, warn}; |
|
|
|
use log::{info, warn}; |
|
|
|
use manifest::CrateData; |
|
|
|
use manifest::CrateData; |
|
|
|
use progressbar::Step; |
|
|
|
use progressbar::Step; |
|
|
|
|
|
|
|
use std::env; |
|
|
|
use std::fs; |
|
|
|
use std::fs; |
|
|
|
use std::path::{Path, PathBuf}; |
|
|
|
use std::path::{Path, PathBuf}; |
|
|
|
use std::process::Command; |
|
|
|
use std::process::Command; |
|
|
@ -101,9 +102,19 @@ pub fn cargo_install_wasm_bindgen( |
|
|
|
version: &str, |
|
|
|
version: &str, |
|
|
|
install_permitted: bool, |
|
|
|
install_permitted: bool, |
|
|
|
) -> Result<Download, failure::Error> { |
|
|
|
) -> Result<Download, failure::Error> { |
|
|
|
|
|
|
|
debug!( |
|
|
|
|
|
|
|
"Attempting to use a `cargo install`ed version of `wasm-bindgen={}`", |
|
|
|
|
|
|
|
version |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
let dirname = format!("wasm-bindgen-cargo-install-{}", version); |
|
|
|
let dirname = format!("wasm-bindgen-cargo-install-{}", version); |
|
|
|
let destination = cache.join(dirname.as_ref()); |
|
|
|
let destination = cache.join(dirname.as_ref()); |
|
|
|
if destination.exists() { |
|
|
|
if destination.exists() { |
|
|
|
|
|
|
|
debug!( |
|
|
|
|
|
|
|
"`cargo install`ed `wasm-bindgen={}` already exists at {}", |
|
|
|
|
|
|
|
version, |
|
|
|
|
|
|
|
destination.display() |
|
|
|
|
|
|
|
); |
|
|
|
return Ok(Download::at(&destination)); |
|
|
|
return Ok(Download::at(&destination)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -115,7 +126,12 @@ pub fn cargo_install_wasm_bindgen( |
|
|
|
// and ensure we don't accidentally use stale files in the future
|
|
|
|
// and ensure we don't accidentally use stale files in the future
|
|
|
|
let tmp = cache.join(format!(".{}", dirname).as_ref()); |
|
|
|
let tmp = cache.join(format!(".{}", dirname).as_ref()); |
|
|
|
drop(fs::remove_dir_all(&tmp)); |
|
|
|
drop(fs::remove_dir_all(&tmp)); |
|
|
|
fs::create_dir_all(&tmp)?; |
|
|
|
debug!( |
|
|
|
|
|
|
|
"cargo installing wasm-bindgen to tempdir: {}", |
|
|
|
|
|
|
|
tmp.display() |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
fs::create_dir_all(&tmp) |
|
|
|
|
|
|
|
.context("failed to create temp dir for `cargo install wasm-bindgen`")?; |
|
|
|
|
|
|
|
|
|
|
|
let mut cmd = Command::new("cargo"); |
|
|
|
let mut cmd = Command::new("cargo"); |
|
|
|
cmd.arg("install") |
|
|
|
cmd.arg("install") |
|
|
@ -128,7 +144,28 @@ pub fn cargo_install_wasm_bindgen( |
|
|
|
|
|
|
|
|
|
|
|
child::run(cmd, "cargo install").context("Installing wasm-bindgen with cargo")?; |
|
|
|
child::run(cmd, "cargo install").context("Installing wasm-bindgen with cargo")?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// `cargo install` will put the installed binaries in `$root/bin/*`, but we
|
|
|
|
|
|
|
|
// just want them in `$root/*` directly (which matches how the tarballs are
|
|
|
|
|
|
|
|
// laid out, and where the rest of our code expects them to be). So we do a
|
|
|
|
|
|
|
|
// little renaming here.
|
|
|
|
|
|
|
|
for f in ["wasm-bindgen", "wasm-bindgen-test-runner"].iter().cloned() { |
|
|
|
|
|
|
|
let from = tmp |
|
|
|
|
|
|
|
.join("bin") |
|
|
|
|
|
|
|
.join(f) |
|
|
|
|
|
|
|
.with_extension(env::consts::EXE_EXTENSION); |
|
|
|
|
|
|
|
let to = tmp.join(from.file_name().unwrap()); |
|
|
|
|
|
|
|
fs::rename(&from, &to).with_context(|_| { |
|
|
|
|
|
|
|
format!( |
|
|
|
|
|
|
|
"failed to move {} to {} for `cargo install`ed `wasm-bindgen`", |
|
|
|
|
|
|
|
from.display(), |
|
|
|
|
|
|
|
to.display() |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
})?; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Finally, move the `tmp` directory into our binary cache.
|
|
|
|
fs::rename(&tmp, &destination)?; |
|
|
|
fs::rename(&tmp, &destination)?; |
|
|
|
|
|
|
|
|
|
|
|
Ok(Download::at(&destination)) |
|
|
|
Ok(Download::at(&destination)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -170,7 +207,7 @@ pub fn wasm_bindgen_build( |
|
|
|
"no-modules" => "--no-modules", |
|
|
|
"no-modules" => "--no-modules", |
|
|
|
_ => "--browser", |
|
|
|
_ => "--browser", |
|
|
|
}; |
|
|
|
}; |
|
|
|
let bindgen_path = bindgen.binary("wasm-bindgen"); |
|
|
|
let bindgen_path = bindgen.binary("wasm-bindgen")?; |
|
|
|
let mut cmd = Command::new(bindgen_path); |
|
|
|
let mut cmd = Command::new(bindgen_path); |
|
|
|
cmd.arg(&wasm_path) |
|
|
|
cmd.arg(&wasm_path) |
|
|
|
.arg("--out-dir") |
|
|
|
.arg("--out-dir") |
|
|
|