-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.rs
32 lines (29 loc) · 1.32 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
// SPDX-License-Identifier: MIT OR Apache-2.0
// SPDX-FileCopyrightText: 2022-2023 1BitSquared <[email protected]>
// SPDX-FileContributor: Written by Mikaela Szekely <[email protected]>
//! To whomever might be reading this, understandably skeptical of build scripts:
//! This build script is *optional*, and exists only to set *default* options under
//! circumstances under which they are supported. Actually, all this build script does
//! is detect if we are running nightly Rust, and enable backtrace support for errors
//! if we are.
use rustc_version::{version_meta, Channel};
fn main()
{
// Statically link the Visual C runtime on Windows.
static_vcruntime::metabuild();
// If detect-backtrace is enabled (default), detect if we're on nightly or not.
// If we're on nightly, enable backtraces automatically.
if let Some(_val) = std::env::var_os("CARGO_FEATURE_DETECT_BACKTRACE") {
match version_meta() {
Ok(version_meta) => {
if version_meta.channel == Channel::Nightly {
// Tell Cargo to enable backtraces.
println!("cargo:rustc-cfg=feature=\"backtrace\"");
}
},
Err(e) => {
println!("cargo:warning=error detecting rustc version: {}", e);
}
}
}
}