Skip to content

Commit 91b5094

Browse files
authored
Merge pull request #35 from Rust-GPU/feature/show-commitsh
Show git commit revision command
2 parents 4c673fc + c95dcc7 commit 91b5094

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

crates/cargo-gpu/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ description = "Generates shader .spv files from rust-gpu shader crates"
66
repository = "https://github.com/Rust-GPU/cargo-gpu"
77
readme = "../../README.md"
88
keywords = ["gpu", "compiler"]
9+
build = "build.rs"
910
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1011

1112
[dependencies]

crates/cargo-gpu/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//! cargo-gpu build script.
2+
3+
fn main() {
4+
let git_hash = std::process::Command::new("git")
5+
.args(["rev-parse", "HEAD"])
6+
.output()
7+
.map_or_else(
8+
|_| "unknown".to_owned(),
9+
|output| String::from_utf8(output.stdout).unwrap_or_else(|_| "unknown".to_owned()),
10+
);
11+
println!("cargo:rustc-env=GIT_HASH={git_hash}");
12+
}

crates/cargo-gpu/src/show.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub enum Info {
1717
CacheDirectory,
1818
/// The source location of spirv-std
1919
SpirvSource(SpirvSourceDep),
20+
/// The git commitsh of this cli tool.
21+
Commitsh,
2022
}
2123

2224
/// `cargo gpu show`
@@ -48,6 +50,9 @@ impl Show {
4850
println!("{rust_gpu_source}\n");
4951
}
5052
}
53+
Info::Commitsh => {
54+
println!("{}", std::env!("GIT_HASH"));
55+
}
5156
}
5257

5358
Ok(())

0 commit comments

Comments
 (0)