A simple and extensible build system for wesl-rs, the compiler for WESL (WGSL Extended) shaders.
cargo add wesl_build --buildIn build.rs:
use wesl_build::{build_shader_dir, WeslBuildError};
use wesl_build::{extensions, extension::WeslBuildExtension};
fn main() {
build_shader_dir("src/shaders", extensions![/* Extension::new() */]).expect("Building shaders failed");
}Now all shaders in src/shaders will be compiled with subdirectories accting as modules, which can be nested
logging- enables logging of builds along with logging in the built-in extensionswgpu_bindings_ext(default) - enables an extension that useswgsl_to_wgputo generate binding modules for your shaders. Note this requires you use thewgpuversion expected bywgsl_to_wgpumath_consts_ext(default) - enables an extension that adds math and type specific consts at compile-time toconstants
Consts:{u32, i32, f32}_{MAX, MIN},{f32, f64}_{MIN_POSITIVE, EPSILON}, and all stable rust math f64 constants, note:FRAC_1_*becomesINV_*wgsl_minifier_ext- enables an extension that minifies shaders, optionally only in release builds
Note: features post-fixed with _ext enable one or more implementors of WeslBuildExtension
For faster builds add this to your Cargo.toml, it will speed up builds after the first one:
[profile.dev.package."wesl"]
opt-level = 3
[profile.dev.package."naga"]
opt-level = 3
# optional
[profile.dev.package."wesl_build"]
opt-level = 3