mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 22:11:01 +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
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
use std::path::Path;
|
|
|
|
use anyhow::Context;
|
|
use glob::glob;
|
|
|
|
use crate::result::{ErrorStatus, LogIfError};
|
|
|
|
pub(crate) fn visit_files(
|
|
path: impl AsRef<Path>,
|
|
glob_expr: &str,
|
|
mut f: impl FnMut(&Path) -> anyhow::Result<()>,
|
|
) -> ErrorStatus {
|
|
let path = path.as_ref();
|
|
let glob_expr = path.join(glob_expr);
|
|
let glob_expr = glob_expr.to_str().unwrap();
|
|
|
|
let mut status = ErrorStatus::NoFailuresFound;
|
|
glob(glob_expr)
|
|
.context("glob pattern {path:?} is invalid")
|
|
.unwrap()
|
|
.for_each(|path_res| {
|
|
if let Some(path) = path_res
|
|
.with_context(|| format!("error while iterating over glob {path:?}"))
|
|
.log_if_err_found(&mut status)
|
|
{
|
|
if path
|
|
.metadata()
|
|
.with_context(|| format!("failed to fetch metadata for {path:?}"))
|
|
.log_if_err_found(&mut status)
|
|
.map_or(false, |m| m.is_file())
|
|
{
|
|
f(&path).log_if_err_found(&mut status);
|
|
}
|
|
}
|
|
});
|
|
status
|
|
}
|