Skip to content

Commit e7e447a

Browse files
committed
spirv-builder: check and clippy shortcuts
1 parent 7a0b4b3 commit e7e447a

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
@@ -719,6 +719,24 @@ impl SpirvBuilder {
719719
self
720720
}
721721

722+
/// Shortcut for `cargo check`
723+
pub fn check(&mut self) -> Result<CompileResult, SpirvBuilderError> {
724+
self.run_cargo_cmd("check")
725+
}
726+
727+
/// Shortcut for `cargo clippy`
728+
pub fn clippy(&mut self) -> Result<CompileResult, SpirvBuilderError> {
729+
self.run_cargo_cmd("clippy")
730+
}
731+
732+
/// Run the supplied cargo cmd, and ensure to reset the state so [`Self::build`] still works as normal
733+
fn run_cargo_cmd(&mut self, cmd: &str) -> Result<CompileResult, SpirvBuilderError> {
734+
let old = self.cargo_cmd.replace(cmd.into());
735+
let result = self.build();
736+
self.cargo_cmd = old;
737+
result
738+
}
739+
722740
/// Builds the module
723741
pub fn build(&self) -> Result<CompileResult, SpirvBuilderError> {
724742
let metadata_file = invoke_rustc(self)?;

0 commit comments

Comments
 (0)