Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix xtask wasm-bindgen install #4944

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions xtask/src/run_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@ use anyhow::Context;

use pico_args::Arguments;

use crate::util::check_all_programs;
use crate::util::{check_all_programs, Program};

pub(crate) fn run_wasm(mut args: Arguments) -> Result<(), anyhow::Error> {
let no_serve = args.contains("--no-serve");
let release = args.contains("--release");

let programs_needed: &[_] = if no_serve {
&["wasm-bindgen"]
&[Program {
crate_name: "wasm-bindgen-cli",
binary_name: "wasm-bindgen",
}]
} else {
&["wasm-bindgen", "simple-http-server"]
&[
Program {
crate_name: "wasm-bindgen-cli",
binary_name: "wasm-bindgen",
},
Program {
crate_name: "simple-http-server",
binary_name: "simple-http-server",
},
]
};

check_all_programs(programs_needed)?;
Expand Down
23 changes: 16 additions & 7 deletions xtask/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
use std::{io, process::Command};

pub(crate) fn check_all_programs(programs: &[&str]) -> anyhow::Result<()> {
pub(crate) struct Program {
pub binary_name: &'static str,
pub crate_name: &'static str,
}

pub(crate) fn check_all_programs(programs: &[Program]) -> anyhow::Result<()> {
let mut failed = Vec::new();
for &program in programs {
let mut cmd = Command::new(program);
for Program {
binary_name,
crate_name,
} in programs
{
let mut cmd = Command::new(binary_name);
cmd.arg("--help");
let output = cmd.output();
match output {
Ok(_output) => {
log::info!("Checking for {program} in PATH: ✅");
log::info!("Checking for {binary_name} in PATH: ✅");
}
Err(e) if matches!(e.kind(), io::ErrorKind::NotFound) => {
log::error!("Checking for {program} in PATH: ❌");
failed.push(program);
log::error!("Checking for {binary_name} in PATH: ❌");
failed.push(*crate_name);
}
Err(e) => {
log::error!("Checking for {program} in PATH: ❌");
log::error!("Checking for {binary_name} in PATH: ❌");
panic!("Unknown IO error: {:?}", e);
}
}
Expand Down
Loading