diff --git a/naga/xtask/src/cli.rs b/naga/xtask/src/cli.rs index cd510124c..d41b86ba2 100644 --- a/naga/xtask/src/cli.rs +++ b/naga/xtask/src/cli.rs @@ -127,6 +127,19 @@ impl ValidateSubcommand { } } } + + pub(crate) fn all() -> impl Iterator { + [ + Self::Spirv, + Self::Metal, + Self::Glsl, + Self::Dot, + Self::Wgsl, + Self::Hlsl(ValidateHlslCommand::Dxc), + Self::Hlsl(ValidateHlslCommand::Fxc), + ] + .into_iter() + } } #[derive(Debug)] diff --git a/naga/xtask/src/validate.rs b/naga/xtask/src/validate.rs index bed71b05d..394b7b00d 100644 --- a/naga/xtask/src/validate.rs +++ b/naga/xtask/src/validate.rs @@ -144,24 +144,27 @@ fn collect_validation_jobs(jobs: &mut Vec, cmd: ValidateSubcommand) -> anyh }); } ValidateSubcommand::All => { - collect_validation_jobs(jobs, ValidateSubcommand::Wgsl)?; - collect_validation_jobs(jobs, ValidateSubcommand::Spirv)?; - collect_validation_jobs(jobs, ValidateSubcommand::Glsl)?; - collect_validation_jobs(jobs, ValidateSubcommand::Dot)?; - - #[cfg(any(target_os = "macos", target_os = "ios"))] - collect_validation_jobs(jobs, ValidateSubcommand::Metal)?; - - // The FXC compiler is only available on Windows. - // - // The DXC compiler can be built and run on any platform, - // but they don't make Linux releases and it's not clear - // what Git commit actually works on Linux, so restrict - // that to Windows as well. - #[cfg(windows)] - { - collect_validation_jobs(jobs, ValidateSubcommand::Hlsl(ValidateHlslCommand::Dxc))?; - collect_validation_jobs(jobs, ValidateSubcommand::Hlsl(ValidateHlslCommand::Fxc))?; + for subcmd in ValidateSubcommand::all() { + let should_validate = match &subcmd { + ValidateSubcommand::Wgsl + | ValidateSubcommand::Spirv + | ValidateSubcommand::Glsl + | ValidateSubcommand::Dot => true, + ValidateSubcommand::Metal => cfg!(any(target_os = "macos", target_os = "ios")), + // The FXC compiler is only available on Windows. + // + // The DXC compiler can be built and run on any platform, + // but they don't make Linux releases and it's not clear + // what Git commit actually works on Linux, so restrict + // that to Windows as well. + ValidateSubcommand::Hlsl( + ValidateHlslCommand::Dxc | ValidateHlslCommand::Fxc, + ) => cfg!(os = "windows"), + ValidateSubcommand::All => continue, + }; + if should_validate { + collect_validation_jobs(jobs, subcmd)?; + } } } };