parent
bd7d940ab0
commit
e67f835867
@ -0,0 +1,42 @@ |
|||||||
|
use std::process::Command; |
||||||
|
|
||||||
|
pub fn cargo_install_wasm_bindgen() { |
||||||
|
let output = Command::new("cargo") |
||||||
|
.arg("install") |
||||||
|
.arg("--git") |
||||||
|
.arg("https://github.com/alexcrichton/wasm-bindgen") |
||||||
|
.output() |
||||||
|
.unwrap_or_else(|e| panic!("failed to execute process: {}", e)); |
||||||
|
|
||||||
|
if output.status.success() { |
||||||
|
let s = String::from_utf8_lossy(&output.stdout); |
||||||
|
|
||||||
|
print!( |
||||||
|
"cargo_install_wasm_bindgen succeeded and stdout was:\n{}", |
||||||
|
s |
||||||
|
); |
||||||
|
} else { |
||||||
|
let s = String::from_utf8_lossy(&output.stderr); |
||||||
|
|
||||||
|
print!("cargo_install_wasm_bindgen failed and stderr was:\n{}", s); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
pub fn wasm_bindgen_build(path: &str) { |
||||||
|
let output = Command::new("wasm-bindgen") |
||||||
|
.current_dir(path) |
||||||
|
.arg("--out-dir") |
||||||
|
.arg("./pkg") |
||||||
|
.output() |
||||||
|
.unwrap_or_else(|e| panic!("failed to execute process: {}", e)); |
||||||
|
|
||||||
|
if output.status.success() { |
||||||
|
let s = String::from_utf8_lossy(&output.stdout); |
||||||
|
|
||||||
|
print!("cargo_build_wasm succeeded and stdout was:\n{}", s); |
||||||
|
} else { |
||||||
|
let s = String::from_utf8_lossy(&output.stderr); |
||||||
|
|
||||||
|
print!("cargo_build_wasm failed and stderr was:\n{}", s); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
use std::process::Command; |
||||||
|
|
||||||
|
pub fn rustup_add_wasm_target() { |
||||||
|
let output = Command::new("rustup") |
||||||
|
.arg("target") |
||||||
|
.arg("add") |
||||||
|
.arg("wasm32-unknown-unknown") |
||||||
|
.output() |
||||||
|
.unwrap_or_else(|e| panic!("failed to execute process: {}", e)); |
||||||
|
|
||||||
|
if output.status.success() { |
||||||
|
let s = String::from_utf8_lossy(&output.stdout); |
||||||
|
|
||||||
|
print!("rustup_add_wasm_target succeeded and stdout was:\n{}", s); |
||||||
|
} else { |
||||||
|
let s = String::from_utf8_lossy(&output.stderr); |
||||||
|
|
||||||
|
print!("rustup_add_wasm_target failed and stderr was:\n{}", s); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
pub fn cargo_build_wasm(path: &str) { |
||||||
|
let output = Command::new("cargo") |
||||||
|
.current_dir(path) |
||||||
|
.arg("build") |
||||||
|
.arg("--release") |
||||||
|
.arg("--target") |
||||||
|
.arg("wasm32-unknown-unknown") |
||||||
|
.output() |
||||||
|
.unwrap_or_else(|e| panic!("failed to execute process: {}", e)); |
||||||
|
|
||||||
|
if output.status.success() { |
||||||
|
let s = String::from_utf8_lossy(&output.stdout); |
||||||
|
|
||||||
|
print!("cargo_build_wasm succeeded and stdout was:\n{}", s); |
||||||
|
} else { |
||||||
|
let s = String::from_utf8_lossy(&output.stderr); |
||||||
|
|
||||||
|
print!("cargo_build_wasm failed and stderr was:\n{}", s); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue