2024-11-11 20:42:16 +00:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
use git2::Repository;
|
|
|
|
|
|
|
|
fn main() {
|
2024-11-20 14:00:17 +00:00
|
|
|
if let Ok(repo) = Repository::open(".") {
|
|
|
|
let head = repo.head().expect("should get git HEAD");
|
|
|
|
let commit = head.peel_to_commit().expect("should get git HEAD commit");
|
|
|
|
println!("cargo::rustc-env=GIT_REV={}", commit.id());
|
|
|
|
}
|
2024-11-11 20:42:16 +00:00
|
|
|
|
|
|
|
let os = env::var("CARGO_CFG_TARGET_OS").expect("should get CARGO_CFG_TARGET_OS");
|
2024-11-20 14:00:17 +00:00
|
|
|
println!("cargo::rustc-env=TARGET_OS={os}");
|
2024-11-11 20:42:16 +00:00
|
|
|
|
2024-11-20 14:00:17 +00:00
|
|
|
let env = env::var("CARGO_CFG_TARGET_ENV").expect("should get CARGO_CFG_TARGET_ENV");
|
|
|
|
println!("cargo::rustc-env=TARGET_ENV={env}");
|
2024-11-11 20:42:16 +00:00
|
|
|
|
2024-11-20 14:00:17 +00:00
|
|
|
let arch = env::var("CARGO_CFG_TARGET_ARCH").expect("should get CARGO_CFG_TARGET_ARCH");
|
|
|
|
println!("cargo::rustc-env=TARGET_ARCH={arch}");
|
2024-11-11 20:42:16 +00:00
|
|
|
}
|