mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
Fix xtask wasm-bindgen install (#4944)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
parent
d7db4e5ef0
commit
a0c2b25829
@ -2,16 +2,28 @@ use anyhow::Context;
|
|||||||
|
|
||||||
use pico_args::Arguments;
|
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> {
|
pub(crate) fn run_wasm(mut args: Arguments) -> Result<(), anyhow::Error> {
|
||||||
let no_serve = args.contains("--no-serve");
|
let no_serve = args.contains("--no-serve");
|
||||||
let release = args.contains("--release");
|
let release = args.contains("--release");
|
||||||
|
|
||||||
let programs_needed: &[_] = if no_serve {
|
let programs_needed: &[_] = if no_serve {
|
||||||
&["wasm-bindgen"]
|
&[Program {
|
||||||
|
crate_name: "wasm-bindgen-cli",
|
||||||
|
binary_name: "wasm-bindgen",
|
||||||
|
}]
|
||||||
} else {
|
} 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)?;
|
check_all_programs(programs_needed)?;
|
||||||
|
@ -1,21 +1,30 @@
|
|||||||
use std::{io, process::Command};
|
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();
|
let mut failed = Vec::new();
|
||||||
for &program in programs {
|
for Program {
|
||||||
let mut cmd = Command::new(program);
|
binary_name,
|
||||||
|
crate_name,
|
||||||
|
} in programs
|
||||||
|
{
|
||||||
|
let mut cmd = Command::new(binary_name);
|
||||||
cmd.arg("--help");
|
cmd.arg("--help");
|
||||||
let output = cmd.output();
|
let output = cmd.output();
|
||||||
match output {
|
match output {
|
||||||
Ok(_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) => {
|
Err(e) if matches!(e.kind(), io::ErrorKind::NotFound) => {
|
||||||
log::error!("Checking for {program} in PATH: ❌");
|
log::error!("Checking for {binary_name} in PATH: ❌");
|
||||||
failed.push(program);
|
failed.push(*crate_name);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Checking for {program} in PATH: ❌");
|
log::error!("Checking for {binary_name} in PATH: ❌");
|
||||||
panic!("Unknown IO error: {:?}", e);
|
panic!("Unknown IO error: {:?}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user