We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c6f0815 commit 265ab3bCopy full SHA for 265ab3b
build.rs
@@ -1,9 +1,21 @@
1
+use std::env;
2
+use std::ffi::OsString;
3
+use std::process;
4
+
5
fn main() {
6
println!("cargo:rerun-if-changed=build.rs");
7
8
println!("cargo:rustc-check-cfg=cfg(exhaustive)");
9
println!("cargo:rustc-check-cfg=cfg(prettyplease_debug)");
10
println!("cargo:rustc-check-cfg=cfg(prettyplease_debug_indent)");
11
- println!(concat!("cargo:VERSION=", env!("CARGO_PKG_VERSION")));
12
+ let pkg_version = cargo_env_var("CARGO_PKG_VERSION");
13
+ println!("cargo:VERSION={}", pkg_version.to_str().unwrap());
14
+}
15
16
+fn cargo_env_var(key: &str) -> OsString {
17
+ env::var_os(key).unwrap_or_else(|| {
18
+ eprintln!("Environment variable ${key} is not set during execution of build script");
19
+ process::exit(1);
20
+ })
21
}
0 commit comments