-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild.rs
More file actions
31 lines (26 loc) · 1003 Bytes
/
build.rs
File metadata and controls
31 lines (26 loc) · 1003 Bytes
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
use std::env;
use vergen::*;
fn is_cargo_feature(var: (String, String)) -> Option<String> {
let (k, _v) = var;
if k.starts_with("CARGO_FEATURE_") {
Some(k.replace("CARGO_FEATURE_", "").to_lowercase())
} else {
None
}
}
fn main() {
// vergen CARGO_FEATURES extraction is bugged, so doing our own here.
let features: Vec<String> = env::vars().filter_map(is_cargo_feature).collect();
let features = features.join(",");
println!("cargo:rustc-env=VERGEN_CARGO_FEATURES={}", features);
// Force to rebuild for environment variable change.
println!("cargo:rerun-if-env-changed=AWS_ACCESS_KEY_ID");
println!("cargo:rerun-if-env-changed=AWS_SECRET_ACCESS_KEY");
// Get the target triple
println!(
"cargo:rustc-env=VERGEN_CARGO_TARGET_TRIPLE={}",
env::var("TARGET").unwrap_or_default()
);
generate_cargo_keys(ConstantsFlags::SHA | ConstantsFlags::COMMIT_DATE)
.expect("Failed to get version information");
}