-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
48 lines (45 loc) · 1.55 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#[macro_use]
extern crate cfg_if;
#[macro_use]
extern crate cargo_emit;
#[allow(unused_imports)] // used in panic_if_no_std_and_compiling_tests!()
#[macro_use]
extern crate indoc;
#[allow(dead_code)] // used in panic_if_no_std_and_compiling_tests!()
fn compiling_tests() -> bool {
option_env!("CARGO_PRIMARY_PACKAGE").is_none()
&& option_env!("CARGO_TEMPDIR_PATH").is_some()
}
macro_rules! panic_if_no_std_and_compiling_tests {
() => {
cfg_if! {
if #[cfg(all(feature = "no_std", not(feature = "ignore_no_std_tests_check")))] {
compile_error!(indoc!{"
Tests will run, but *will* link `std`! Therefore, if you are trying to test \
that your code *works* in no_std rather than just compiles, `cargo test` \
can't tell you that!
"});
}
}
}
}
fn main() {
panic_if_no_std_and_compiling_tests!();
if cfg!(feature = "no_std") {
rustc_cfg!("no_std");
} else {
rustc_cfg!("std");
}
if cfg!(any(feature = "more-serde", feature = "default")) {
rustc_cfg!("use_serde");
}
if cfg!(any(feature = "numerical-traits", feature = "default")) {
rustc_cfg!("numerical_traits");
}
if cfg!(feature = "hash") {
rustc_cfg!("with_impl_hash");
}
if cfg!(feature = "x64-backing-store") {
cargo_emit::warning!("Warning: compiling f64/i64 as IntegerOrFloat backing type. This won't work with most MFEK libraries/programs, and is meant for non-MFEK consumers.");
}
}