-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.rs
20 lines (16 loc) · 903 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/// This build.rs script is used to generate build-time information and set environment variables for the build process.
/// It retrieves the Rust compiler version and sets it as the `RUSTC_VERSION` environment variable.
/// It also sets the `BUILD_VERSION` environment variable to the value of `NEARCORE_VERSION` defined in the project.
/// Additionally, it prints messages to indicate which files should trigger a rebuild when changed.
fn get_rustc_version() -> anyhow::Result<String> {
let version = rustc_version::version()?;
Ok(version.to_string())
}
fn main() -> anyhow::Result<()> {
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/index");
println!("cargo:rustc-env=BUILD_VERSION={}", env!("NEARCORE_VERSION"));
let rustc_version = get_rustc_version()?;
println!("cargo:rustc-env=RUSTC_VERSION={}", rustc_version);
Ok(())
}