Skip to content

Commit 6299130

Browse files
committed
spirv-builder: check and clippy shortcuts
1 parent a30bd43 commit 6299130

File tree

1 file changed

+18
-0
lines changed
  • crates/spirv-builder/src

1 file changed

+18
-0
lines changed

crates/spirv-builder/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,24 @@ impl SpirvBuilder {
675675
self
676676
}
677677

678+
/// Shortcut for `cargo check`
679+
pub fn check(&mut self) -> Result<CompileResult, SpirvBuilderError> {
680+
self.run_cargo_cmd("check")
681+
}
682+
683+
/// Shortcut for `cargo clippy`
684+
pub fn clippy(&mut self) -> Result<CompileResult, SpirvBuilderError> {
685+
self.run_cargo_cmd("clippy")
686+
}
687+
688+
/// Run the supplied cargo cmd, and ensure to reset the state so [`Self::build`] still works as normal
689+
fn run_cargo_cmd(&mut self, cmd: &str) -> Result<CompileResult, SpirvBuilderError> {
690+
let old = self.cargo_cmd.replace(cmd.into());
691+
let result = self.build();
692+
self.cargo_cmd = old;
693+
result
694+
}
695+
678696
/// Builds the module. If `print_metadata` is [`MetadataPrintout::Full`], you usually don't have to inspect the path
679697
/// in the result, as the environment variable for the path to the module will already be set.
680698
pub fn build(&self) -> Result<CompileResult, SpirvBuilderError> {

0 commit comments

Comments
 (0)