Skip to content

Commit 3b9d761

Browse files
Amanieutkaitchuckbl-ue
authored
Use a runtime-rng feature flag instead of using OS detection (#82)
* Use a runtime-rng feature flag instead of using OS detection * Use --no-default-features on WASM * Update Cargo.toml Co-authored-by: bl-ue <[email protected]> Co-authored-by: Tom Kaitchuck <[email protected]> Co-authored-by: bl-ue <[email protected]>
1 parent c0efa32 commit 3b9d761

File tree

3 files changed

+12
-33
lines changed

3 files changed

+12
-33
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,4 @@ jobs:
148148
- uses: actions-rs/cargo@v1
149149
with:
150150
command: check
151-
args: --target wasm32-unknown-unknown
151+
args: --target wasm32-unknown-unknown --no-default-features

Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@ bench = true
2222
doc = true
2323

2424
[features]
25-
default = ["std"]
25+
default = ["std", "runtime-rng"]
2626

2727
# Enabling this will enable `AHashMap` and `AHashSet`.
2828
std = []
2929

30-
# This is an alternitive to runtime key generation which does compile time key generation if getrandom is not available.
31-
# (If getrandom is available this does nothing.)
32-
# If this is on (and getrandom is off) it implies the produced binary will not be identical.
33-
# If this is disabled and gerrandom is unavailable constant keys are used.
30+
# Runtime random key generation using getrandom.
31+
runtime-rng = ["getrandom", "once_cell"]
32+
33+
# This is an alternative to runtime key generation which does compile time key generation if runtime-rng is not available.
34+
# (If runtime-rng is available this does nothing.)
35+
# If this is on (and runtime-rng is off) it implies the produced binary will not be identical.
36+
# If this is disabled and runtime-rng is unavailable constant keys are used.
3437
compile-time-rng = ["const-random"]
3538

3639
[[bench]]
@@ -64,12 +67,9 @@ codegen-units = 1
6467
[build-dependencies]
6568
version_check = "0.9"
6669

67-
[target.'cfg(any(target_os = "linux", target_os = "android", target_os = "windows", target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "dragonfly", target_os = "solaris", target_os = "illumos", target_os = "fuchsia", target_os = "redox", target_os = "cloudabi", target_os = "haiku", target_os = "vxworks", target_os = "emscripten", target_os = "wasi"))'.dependencies]
68-
getrandom = { version = "0.2.3" }
69-
const-random = { version = "0.1.12", optional = true }
70-
serde = { version = "1.0.117", optional = true }
71-
72-
[target.'cfg(not(any(target_os = "linux", target_os = "android", target_os = "windows", target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd", target_os = "dragonfly", target_os = "solaris", target_os = "illumos", target_os = "fuchsia", target_os = "redox", target_os = "cloudabi", target_os = "haiku", target_os = "vxworks", target_os = "emscripten", target_os = "wasi")))'.dependencies]
70+
[dependencies]
71+
once_cell = { version = "1.8", default-features = false, features = ["unstable", "alloc"], optional = true }
72+
getrandom = { version = "0.2.3", optional = true }
7373
const-random = { version = "0.1.12", optional = true }
7474
serde = { version = "1.0.117", optional = true }
7575

build.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,6 @@ fn main() {
1010
println!("cargo:rustc-cfg=feature=\"stdsimd\"");
1111
}
1212
}
13-
let os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS was not set");
14-
if os.eq_ignore_ascii_case("linux")
15-
|| os.eq_ignore_ascii_case("android")
16-
|| os.eq_ignore_ascii_case("windows")
17-
|| os.eq_ignore_ascii_case("macos")
18-
|| os.eq_ignore_ascii_case("ios")
19-
|| os.eq_ignore_ascii_case("freebsd")
20-
|| os.eq_ignore_ascii_case("openbsd")
21-
|| os.eq_ignore_ascii_case("dragonfly")
22-
|| os.eq_ignore_ascii_case("solaris")
23-
|| os.eq_ignore_ascii_case("illumos")
24-
|| os.eq_ignore_ascii_case("fuchsia")
25-
|| os.eq_ignore_ascii_case("redox")
26-
|| os.eq_ignore_ascii_case("cloudabi")
27-
|| os.eq_ignore_ascii_case("haiku")
28-
|| os.eq_ignore_ascii_case("vxworks")
29-
|| os.eq_ignore_ascii_case("emscripten")
30-
|| os.eq_ignore_ascii_case("wasi")
31-
{
32-
println!("cargo:rustc-cfg=feature=\"runtime-rng\"");
33-
}
3413
let arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH was not set");
3514
if arch.eq_ignore_ascii_case("x86_64")
3615
|| arch.eq_ignore_ascii_case("aarch64")

0 commit comments

Comments
 (0)