fork of https://github.com/rustwasm/wasm-pack for the needs of NextGraph.org
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
52 lines
1.6 KiB
use console::style;
|
|
use emoji;
|
|
use progressbar;
|
|
use std::process::Command;
|
|
|
|
pub fn cargo_install_wasm_bindgen() {
|
|
let step = format!(
|
|
"{} {}Installing WASM-bindgen...",
|
|
style("[6/7]").bold().dim(),
|
|
emoji::DOWN_ARROW
|
|
);
|
|
let pb = progressbar::new(step);
|
|
let _output = Command::new("cargo")
|
|
.arg("install")
|
|
.arg("wasm-bindgen")
|
|
.output()
|
|
.unwrap_or_else(|e| panic!("{} failed to execute process: {}", emoji::ERROR, e));
|
|
pb.finish();
|
|
//if !output.status.success() {
|
|
// let s = String::from_utf8_lossy(&output.stderr);
|
|
|
|
// print!(
|
|
// "{} cargo_install_wasm_bindgen failed and stderr was:\n{}",
|
|
// emoji::ERROR,
|
|
// s
|
|
// );
|
|
// }
|
|
}
|
|
|
|
pub fn wasm_bindgen_build(path: &str, name: &str) {
|
|
let step = format!(
|
|
"{} {}Running WASM-bindgen...",
|
|
style("[7/7]").bold().dim(),
|
|
emoji::RUNNER
|
|
);
|
|
let pb = progressbar::new(step);
|
|
let binary_name = name.replace("-", "_");
|
|
let wasm_path = format!("target/wasm32-unknown-unknown/release/{}.wasm", binary_name);
|
|
let _output = Command::new("wasm-bindgen")
|
|
.current_dir(path)
|
|
.arg(&wasm_path)
|
|
.arg("--out-dir")
|
|
.arg("./pkg")
|
|
.output()
|
|
.unwrap_or_else(|e| panic!("{} failed to execute process: {}", emoji::ERROR, e));
|
|
pb.finish();
|
|
//if !output.status.success() {
|
|
// let s = String::from_utf8_lossy(&output.stderr);
|
|
|
|
// print!(" wasm_bindgen_build failed and stderr was:\n{}", emoji::ERROR, s);
|
|
//}
|
|
}
|
|
|