Skip to content

Commit 1d639fb

Browse files
committed
Fix directory layout of cached cargo installed wasm-bindgens
Fix #503 Fix #497
1 parent 8325d9a commit 1d639fb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/bindgen.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use log::debug;
99
use log::{info, warn};
1010
use manifest::CrateData;
1111
use progressbar::Step;
12+
use std::env;
1213
use std::fs;
1314
use std::path::{Path, PathBuf};
1415
use std::process::Command;
@@ -143,7 +144,28 @@ pub fn cargo_install_wasm_bindgen(
143144

144145
child::run(cmd, "cargo install").context("Installing wasm-bindgen with cargo")?;
145146

147+
// `cargo install` will put the installed binaries in `$root/bin/*`, but we
148+
// just want them in `$root/*` directly (which matches how the tarballs are
149+
// laid out, and where the rest of our code expects them to be). So we do a
150+
// little renaming here.
151+
for f in ["wasm-bindgen", "wasm-bindgen-test-runner"].iter().cloned() {
152+
let from = tmp
153+
.join("bin")
154+
.join(f)
155+
.with_extension(env::consts::EXE_EXTENSION);
156+
let to = tmp.join(from.file_name().unwrap());
157+
fs::rename(&from, &to).with_context(|_| {
158+
format!(
159+
"failed to move {} to {} for `cargo install`ed `wasm-bindgen`",
160+
from.display(),
161+
to.display()
162+
)
163+
})?;
164+
}
165+
166+
// Finally, move the `tmp` directory into our binary cache.
146167
fs::rename(&tmp, &destination)?;
168+
147169
Ok(Download::at(&destination))
148170
}
149171

0 commit comments

Comments
 (0)