-
Notifications
You must be signed in to change notification settings - Fork 161
/
build.rs
24 lines (21 loc) · 1.17 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
extern crate lalrpop;
use rustc_version::{version_meta, Channel};
fn main() {
lalrpop::process_root().unwrap();
// In cases where we want to compile with support for the standard library Error type (which
// is used by all of our diagnostics, etc.), but we are compiling without the `std` feature,
// we require use of the `error_in_core` feature, which is currently unstable, and thus requires
// a nightly compiler.
//
// Exposing this as a `nightly` feature doesn't make sense, as you are either compiling with a
// nightly compiler or not, and if you aren't, then enabling nightly features will just cause
// compilation to fail unexpectedly. Instead, we detect the use of a nightly compiler, and
// conditionally enable nightly features automatically when the nightly compiler is in use.
//
// To accomplish that goal, we set a `nightly` configuration variable, which can then be
// referenced in `#[cfg]` directives, e.g. `#[cfg(nightly)]` or `#[cfg(not(nightly))]`.
println!("cargo:rustc-check-cfg=cfg(nightly)");
if let Channel::Nightly = version_meta().unwrap().channel {
println!("cargo:rustc-cfg=nightly")
}
}