forked from bolcom/unFTP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
41 lines (36 loc) · 1.29 KB
/
build.rs
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
39
40
41
use std::env;
use std::process::Command;
fn main() {
let version = match env::var("BUILD_VERSION") {
Ok(v) => v,
_ => Command::new("git")
.args(["describe", "--tags"])
.output()
.map(|o| String::from_utf8(o.stdout).unwrap())
.unwrap_or_else(|_| ">unknown<".to_string()),
};
println!("cargo:rustc-env=BUILD_VERSION={}", version);
println!(
"cargo:rustc-env=PROJ_WEB_DIR={}/web",
std::env::var("CARGO_MANIFEST_DIR").unwrap(),
);
// Didn't quite get that to work yet.
// #[cfg(feature = "static")]
// {
// println!("cargo:rustc-link-lib=static=pam");
// }
generate_build_info();
}
// uses the 'built' crate to generate a build.rs file with a bunch of build information. We then
// include this file in the app module.
fn generate_build_info() {
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let src = std::path::Path::new(&manifest_dir);
let dst = std::path::Path::new(&env::var("OUT_DIR").unwrap()).join("build-info.rs");
let mut opts = built::Options::default();
opts.set_dependencies(true);
opts.set_git(true);
opts.set_time(true);
built::write_built_file_with_opts(&opts, src, &dst)
.expect("Failed to acquire build-time information");
}