Skip to content

Commit acd8fe8

Browse files
author
Robert Masen
committed
Add nightly toolchain to commands
1 parent 74fe847 commit acd8fe8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/build.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ use PBAR;
77
pub fn rustup_add_wasm_target(step: &Step) -> Result<(), Error> {
88
let msg = format!("{}Adding WASM target...", emoji::TARGET);
99
let pb = PBAR.step(step, &msg);
10+
ensure_nightly()?;
1011
let output = Command::new("rustup")
1112
.arg("target")
1213
.arg("add")
1314
.arg("wasm32-unknown-unknown")
15+
.arg("--toolchain")
16+
.arg("nightly")
1417
.output()?;
1518
pb.finish();
1619
if !output.status.success() {
@@ -21,12 +24,29 @@ pub fn rustup_add_wasm_target(step: &Step) -> Result<(), Error> {
2124
}
2225
}
2326

27+
28+
fn ensure_nightly() -> Result<(), Error> {
29+
let nightly_check = Command::new("rustc").arg("+nightly").arg("-V").output()?;
30+
if !nightly_check.status.success() {
31+
let res = Command::new("rustup")
32+
.arg("toolchain")
33+
.arg("install")
34+
.arg("nightly")
35+
.output()?;
36+
if !res.status.success() {
37+
let s = String::from_utf8_lossy(&res.stderr);
38+
return Error::cli("Adding the nightly toolchain failed", s);
39+
}
40+
}
41+
Ok(())
42+
}
43+
2444
pub fn cargo_build_wasm(path: &str, debug: bool, step: &Step) -> Result<(), Error> {
2545
let msg = format!("{}Compiling to WASM...", emoji::CYCLONE);
2646
let pb = PBAR.step(step, &msg);
2747
let output = {
2848
let mut cmd = Command::new("cargo");
29-
cmd.current_dir(path).arg("build");
49+
cmd.current_dir(path).arg("+nightly").arg("build");
3050
if !debug {
3151
cmd.arg("--release");
3252
}

src/emoji.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pub static WARN: Emoji = Emoji("⚠️ ", ":-)");
1212
pub static DANCERS: Emoji = Emoji("👯 ", "");
1313
pub static ERROR: Emoji = Emoji("⛔ ", "");
1414
pub static INFO: Emoji = Emoji("ℹ️ ", "");
15+
pub static WRENCH: Emoji = Emoji("🔧 ", "");

0 commit comments

Comments
 (0)