Skip to content

Commit c0ebc48

Browse files
committed
Add a feature to explicitly enable "std"
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.
1 parent 884a104 commit c0ebc48

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ matrix:
1010
- rust: stable
1111
env:
1212
- FEATURES='rayon'
13+
- rust: stable
14+
env:
15+
- FEATURES='std'
1316
- rust: beta
1417
- rust: nightly
1518
env:

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ fxhash = "0.2.1"
5353
# Serialization with serde 1.0
5454
serde-1 = ["serde"]
5555

56+
# Force the use of `std`, bypassing target detection.
57+
std = []
58+
5659
# for testing only, of course
5760
test_low_transition_point = []
5861
test_debug = []

build.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
fn main() {
2-
let ac = autocfg::new();
3-
ac.emit_sysroot_crate("std");
2+
// If "std" is explicitly requested, don't bother probing the target for it.
3+
match std::env::var_os("CARGO_FEATURE_STD") {
4+
Some(_) => autocfg::emit("has_std"),
5+
None => autocfg::new().emit_sysroot_crate("std"),
6+
}
47
autocfg::rerun_path("build.rs");
58
}

0 commit comments

Comments
 (0)