Skip to content

Commit

Permalink
Add nightly toolchain to commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Masen committed Jun 13, 2018
1 parent 74fe847 commit acd8fe8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ use PBAR;
pub fn rustup_add_wasm_target(step: &Step) -> Result<(), Error> {
let msg = format!("{}Adding WASM target...", emoji::TARGET);
let pb = PBAR.step(step, &msg);
ensure_nightly()?;
let output = Command::new("rustup")
.arg("target")
.arg("add")
.arg("wasm32-unknown-unknown")
.arg("--toolchain")
.arg("nightly")
.output()?;
pb.finish();
if !output.status.success() {
Expand All @@ -21,12 +24,29 @@ pub fn rustup_add_wasm_target(step: &Step) -> Result<(), Error> {
}
}


fn ensure_nightly() -> Result<(), Error> {
let nightly_check = Command::new("rustc").arg("+nightly").arg("-V").output()?;
if !nightly_check.status.success() {
let res = Command::new("rustup")
.arg("toolchain")
.arg("install")
.arg("nightly")
.output()?;
if !res.status.success() {
let s = String::from_utf8_lossy(&res.stderr);
return Error::cli("Adding the nightly toolchain failed", s);
}
}
Ok(())
}

pub fn cargo_build_wasm(path: &str, debug: bool, step: &Step) -> Result<(), Error> {
let msg = format!("{}Compiling to WASM...", emoji::CYCLONE);
let pb = PBAR.step(step, &msg);
let output = {
let mut cmd = Command::new("cargo");
cmd.current_dir(path).arg("build");
cmd.current_dir(path).arg("+nightly").arg("build");
if !debug {
cmd.arg("--release");
}
Expand Down
1 change: 1 addition & 0 deletions src/emoji.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pub static WARN: Emoji = Emoji("⚠️ ", ":-)");
pub static DANCERS: Emoji = Emoji("👯 ", "");
pub static ERROR: Emoji = Emoji("⛔ ", "");
pub static INFO: Emoji = Emoji("ℹ️ ", "");
pub static WRENCH: Emoji = Emoji("🔧 ", "");

0 comments on commit acd8fe8

Please sign in to comment.