forked from JelteF/derive_more
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
34 lines (27 loc) · 877 Bytes
/
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
extern crate rustc_version;
#[cfg(feature = "generate-parsing-rs")]
extern crate peg;
use rustc_version::{version_meta, Channel};
#[cfg(not(feature = "generate-parsing-rs"))]
fn main() {
if version_meta().unwrap().channel == Channel::Nightly {
println!("cargo:rustc-cfg=feature=\"nightly\"");
}
}
#[cfg(feature = "generate-parsing-rs")]
fn main() {
if version_meta().unwrap().channel == Channel::Nightly {
println!("cargo:rustc-cfg=feature=\"nightly\"");
}
let contents = match ::std::fs::read_to_string("src/parsing.rustpeg") {
Ok(contents) => contents,
Err(e) => panic!("{}", e),
};
let compiled = match ::peg::compile(&contents) {
Ok(compiled) => compiled,
Err(e) => panic!("{}", e),
};
if let Err(e) = ::std::fs::write("src/parsing.rs", compiled) {
panic!("{}", e);
}
}