mirror of
https://github.com/Cyrix126/gupaxx.git
synced 2025-01-03 12:39:35 +00:00
constants: use build-time COMMIT
env var
This commit is contained in:
parent
ea79447133
commit
8976641d48
2 changed files with 22 additions and 2 deletions
22
build.rs
22
build.rs
|
@ -5,6 +5,8 @@
|
|||
// pre-compiled bytes using [include_bytes!()] on the images in [images/].
|
||||
#[cfg(windows)]
|
||||
fn main() -> std::io::Result<()> {
|
||||
set_commit_env();
|
||||
|
||||
static_vcruntime::metabuild();
|
||||
let mut res = winres::WindowsResource::new();
|
||||
// This sets the icon.
|
||||
|
@ -27,4 +29,22 @@ fn main() -> std::io::Result<()> {
|
|||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn main() {}
|
||||
fn main() {
|
||||
set_commit_env();
|
||||
}
|
||||
|
||||
// Set the current git commit to the env var [COMMIT].
|
||||
fn set_commit_env() {
|
||||
println!("cargo:rerun-if-changed=.git/refs/heads/");
|
||||
|
||||
let output = std::process::Command::new("git")
|
||||
.args(["rev-parse", "HEAD"])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
let commit = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
assert!(commit.len() >= 40);
|
||||
|
||||
println!("cargo:rustc-env=COMMIT={commit}");
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
pub const GUPAX_VERSION: &str = concat!("v", env!("CARGO_PKG_VERSION")); // e.g: v1.0.0
|
||||
pub const P2POOL_VERSION: &str = "v3.7";
|
||||
pub const XMRIG_VERSION: &str = "v6.20.0";
|
||||
pub const COMMIT: &str = include_str!("../.git/refs/heads/main");
|
||||
pub const COMMIT: &str = env!("COMMIT"); // set in build.rs
|
||||
// e.g: Gupax_v1_0_0
|
||||
// Would have been [Gupax_v1.0.0] but P2Pool truncates everything after [.]
|
||||
pub const GUPAX_VERSION_UNDERSCORE: &str = concat!(
|
||||
|
|
Loading…
Reference in a new issue