mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-29 09:34:09 +01:00
Re-implement `naga` development workflows using [`cargo xtask`]. Convert `make` logic and shader test configuration as file with Bash variables into an `xtask` crate and YAML files, respectively. Pros: * We now have a _portable_ workflow everywhere, which means Windows folks and people who don't install `make` don't have to suffer. 😮💨 * Workflow logic is now relatively easy to inspect and change. Whew! 💁🏻♂️💦 * Contributors can use their existing Rust knowledge to contribute to developer experience. 🎉 * `cargo xtask` is a relatively well-known convention for workflows in the ecosystem. * We can do fancy things like allow folks to run at different log levels for workflows, depending on their tastes. Cons: * There's now a non-trivial compile step to project workflow. Incremental rebuilds seem to be pretty short, though! * Code is much more verbose than the (very) terse `make` implementation. [`cargo xtask`]: https://github.com/matklad/cargo-xtask
34 lines
930 B
Rust
34 lines
930 B
Rust
#[derive(Clone, Copy, Debug)]
|
|
pub(crate) enum ErrorStatus {
|
|
NoFailuresFound,
|
|
OneOrMoreFailuresFound,
|
|
}
|
|
|
|
impl ErrorStatus {
|
|
pub(crate) fn merge(self, other: Self) -> Self {
|
|
match (self, other) {
|
|
(Self::OneOrMoreFailuresFound, _) | (_, Self::OneOrMoreFailuresFound) => {
|
|
Self::OneOrMoreFailuresFound
|
|
}
|
|
(Self::NoFailuresFound, Self::NoFailuresFound) => Self::NoFailuresFound,
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(crate) trait LogIfError<T> {
|
|
fn log_if_err_found(self, status: &mut ErrorStatus) -> Option<T>;
|
|
}
|
|
|
|
impl<T> LogIfError<T> for anyhow::Result<T> {
|
|
fn log_if_err_found(self, status: &mut ErrorStatus) -> Option<T> {
|
|
match self {
|
|
Ok(t) => Some(t),
|
|
Err(e) => {
|
|
log::error!("{e:?}");
|
|
*status = status.merge(ErrorStatus::OneOrMoreFailuresFound);
|
|
None
|
|
}
|
|
}
|
|
}
|
|
}
|