Skip to content

Commit

Permalink
Add a feature to explicitly enable "std"
Browse files Browse the repository at this point in the history
If you know you need "std", e.g. relying on default `S = RandomState`,
then you can enable this feature to force it on, bypassing target
detection. This may help scenarios where `autocfg` fails detection, like
issue indexmap-rs#144, but at the very least it will speed up the build script by
avoiding extra `rustc` invocations.
  • Loading branch information
cuviper committed Aug 6, 2020
1 parent 884a104 commit c0ebc48
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ matrix:
- rust: stable
env:
- FEATURES='rayon'
- rust: stable
env:
- FEATURES='std'
- rust: beta
- rust: nightly
env:
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ fxhash = "0.2.1"
# Serialization with serde 1.0
serde-1 = ["serde"]

# Force the use of `std`, bypassing target detection.
std = []

# for testing only, of course
test_low_transition_point = []
test_debug = []
Expand Down
7 changes: 5 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
fn main() {
let ac = autocfg::new();
ac.emit_sysroot_crate("std");
// If "std" is explicitly requested, don't bother probing the target for it.
match std::env::var_os("CARGO_FEATURE_STD") {
Some(_) => autocfg::emit("has_std"),
None => autocfg::new().emit_sysroot_crate("std"),
}
autocfg::rerun_path("build.rs");
}

0 comments on commit c0ebc48

Please sign in to comment.