Skip to content

Commit

Permalink
Merge pull request #35 from Rust-GPU/feature/show-commitsh
Browse files Browse the repository at this point in the history
Show git commit revision command
  • Loading branch information
schell authored Jan 8, 2025
2 parents 4c673fc + c95dcc7 commit 91b5094
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/cargo-gpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ description = "Generates shader .spv files from rust-gpu shader crates"
repository = "https://github.com/Rust-GPU/cargo-gpu"
readme = "../../README.md"
keywords = ["gpu", "compiler"]
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
12 changes: 12 additions & 0 deletions crates/cargo-gpu/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//! cargo-gpu build script.
fn main() {
let git_hash = std::process::Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.map_or_else(
|_| "unknown".to_owned(),
|output| String::from_utf8(output.stdout).unwrap_or_else(|_| "unknown".to_owned()),
);
println!("cargo:rustc-env=GIT_HASH={git_hash}");
}
5 changes: 5 additions & 0 deletions crates/cargo-gpu/src/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub enum Info {
CacheDirectory,
/// The source location of spirv-std
SpirvSource(SpirvSourceDep),
/// The git commitsh of this cli tool.
Commitsh,
}

/// `cargo gpu show`
Expand Down Expand Up @@ -48,6 +50,9 @@ impl Show {
println!("{rust_gpu_source}\n");
}
}
Info::Commitsh => {
println!("{}", std::env!("GIT_HASH"));
}
}

Ok(())
Expand Down

0 comments on commit 91b5094

Please sign in to comment.