Files
rustytorch/crates/production/rtx-inference/build.rs
T
osobhandClaude Opus 4.6 02d382d5f6 style: apply rustfmt across all crates and demos
Consistent formatting pass: line wrapping, import sorting, trailing
whitespace removal, let-chain indentation, merged derive attributes,
and unsafe block reformatting.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2026-04-12 07:01:58 -07:00

52 lines
1.6 KiB
Rust

use std::env;
use std::process::Command;
fn main() {
// Set build timestamp
println!(
"cargo:rustc-env=RUSTYTORCH_BUILD_TIMESTAMP={}",
chrono::Utc::now().format("%Y-%m-%d %H:%M:%S UTC")
);
// Get git commit hash
let git_commit = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()
.and_then(|output| {
if output.status.success() {
String::from_utf8(output.stdout).ok()
} else {
None
}
})
.map_or_else(|| "unknown".to_string(), |s| s.trim().to_string());
println!("cargo:rustc-env=RUSTYTORCH_GIT_COMMIT={git_commit}");
// Get Rust version
let rustc_version = env::var("RUSTC_VERSION").unwrap_or_else(|_| {
Command::new(env::var("RUSTC").unwrap_or_else(|_| "rustc".to_string()))
.arg("--version")
.output()
.ok()
.and_then(|output| {
if output.status.success() {
String::from_utf8(output.stdout).ok()
} else {
None
}
})
.map_or_else(|| "unknown".to_string(), |s| s.trim().to_string())
});
println!("cargo:rustc-env=RUSTYTORCH_RUST_VERSION={rustc_version}");
// Get target architecture
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| "unknown".to_string());
println!("cargo:rustc-env=RUSTYTORCH_TARGET_ARCH={target_arch}");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=.git/HEAD");
}