-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
38 lines (32 loc) · 1.07 KB
/
build.rs
File metadata and controls
38 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use std::process::Command;
fn main() {
// Capture build timestamp
let now = chrono::Utc::now();
println!(
"cargo:rustc-env=BUILD_TIMESTAMP={}",
now.format("%Y-%m-%d %H:%M:%S UTC")
);
// Try to capture git commit hash
let git_hash = 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(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", git_hash);
// Detect enabled features
#[cfg(feature = "qdrant-backend")]
println!("cargo:rustc-env=VECTOR_DB_BACKEND=Qdrant");
#[cfg(not(feature = "qdrant-backend"))]
println!("cargo:rustc-env=VECTOR_DB_BACKEND=LanceDB");
// Rerun if git HEAD changes
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/refs/heads");
}