-
-
Notifications
You must be signed in to change notification settings - Fork 836
Expand file tree
/
Copy pathbuild.rs
More file actions
21 lines (17 loc) · 659 Bytes
/
build.rs
File metadata and controls
21 lines (17 loc) · 659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::env;
use std::fs;
use std::path::Path;
use std::time::{SystemTime, UNIX_EPOCH};
fn main() {
// Embed build timestamp as seconds since Unix epoch
let timestamp = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs();
// Write timestamp to a file in OUT_DIR so cargo detects the change
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("build_timestamp.txt");
fs::write(&dest_path, timestamp.to_string()).unwrap();
println!("cargo:rustc-env=BUILD_TIMESTAMP={}", timestamp);
// Always rerun build script (no rerun-if-changed means always run)
}