1[package]
2name = "getrandom"
3version = "0.3.2"
4edition = "2021"
5rust-version = "1.63" # Sync tests.yml and README.md.
6authors = ["The Rand Project Developers"]
7license = "MIT OR Apache-2.0"
8description = "A small cross-platform library for retrieving random data from system source"
9documentation = "https://docs.rs/getrandom"
10repository = "https://github.com/rust-random/getrandom"
11categories = ["os", "no-std"]
12exclude = [".*"]
13
14[features]
15# Implement std::error::Error for getrandom::Error and
16# use std to retrieve OS error descriptions
17std = []
18# Unstable feature to support being a libstd dependency
19rustc-dep-of-std = ["dep:compiler_builtins", "dep:core"]
20
21# Optional backend: wasm_js
22# This flag enables the backend but does not select it. To use the backend, use
23# this flag *and* set getrandom_backend=wasm_js (see README).
24wasm_js = ["dep:wasm-bindgen", "dep:js-sys"]
25
26[dependencies]
27cfg-if = "1"
28
29# When built as part of libstd
30compiler_builtins = { version = "0.1", optional = true }
31core = { version = "1.0", optional = true, package = "rustc-std-workspace-core" }
32
33# getrandom / linux_android_with_fallback
34[target.'cfg(all(any(target_os = "linux", target_os = "android"), not(any(all(target_os = "linux", target_env = ""), getrandom_backend = "custom", getrandom_backend = "linux_raw", getrandom_backend = "rdrand", getrandom_backend = "rndr"))))'.dependencies]
35libc = { version = "0.2.154", default-features = false }
36
37# apple-other
38[target.'cfg(any(target_os = "ios", target_os = "visionos", target_os = "watchos", target_os = "tvos"))'.dependencies]
39libc = { version = "0.2.154", default-features = false }
40
41# efi_rng
42[target.'cfg(all(target_os = "uefi", getrandom_backend = "efi_rng"))'.dependencies]
43r-efi = { version = "5.1", default-features = false }
44
45# getentropy
46[target.'cfg(any(target_os = "macos", target_os = "openbsd", target_os = "vita", target_os = "emscripten"))'.dependencies]
47libc = { version = "0.2.154", default-features = false }
48
49# getrandom
50[target.'cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "hurd", target_os = "illumos", target_os = "cygwin", all(target_os = "horizon", target_arch = "arm")))'.dependencies]
51libc = { version = "0.2.154", default-features = false }
52
53# netbsd
54[target.'cfg(target_os = "netbsd")'.dependencies]
55libc = { version = "0.2.154", default-features = false }
56
57# solaris
58[target.'cfg(target_os = "solaris")'.dependencies]
59libc = { version = "0.2.154", default-features = false }
60
61# use_file
62[target.'cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix"))'.dependencies]
63libc = { version = "0.2.154", default-features = false }
64
65# vxworks
66[target.'cfg(target_os = "vxworks")'.dependencies]
67libc = { version = "0.2.154", default-features = false }
68
69# wasi (0.2 only)
70[target.'cfg(all(target_arch = "wasm32", target_os = "wasi", target_env = "p2"))'.dependencies]
71wasi = { version = "0.14", default-features = false }
72
73# wasm_js
74[target.'cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))'.dependencies]
75wasm-bindgen = { version = "0.2.98", default-features = false, optional = true }
76[target.'cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"), target_feature = "atomics"))'.dependencies]
77js-sys = { version = "0.3.77", default-features = false, optional = true }
78[target.'cfg(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none")))'.dev-dependencies]
79wasm-bindgen-test = "0.3"
80
81[lints.rust.unexpected_cfgs]
82level = "warn"
83check-cfg = [
84 'cfg(getrandom_backend, values("custom", "efi_rng", "rdrand", "rndr", "linux_getrandom", "linux_raw", "wasm_js"))',
85 'cfg(getrandom_msan)',
86 'cfg(getrandom_windows_legacy)',
87 'cfg(getrandom_test_linux_fallback)',
88 'cfg(getrandom_test_linux_without_fallback)',
89 'cfg(getrandom_test_netbsd_fallback)',
90 'cfg(target_os, values("cygwin"))', # TODO(MSRV 1.86): Remove this.
91]
92
93[package.metadata.docs.rs]
94features = ["std"]
95
96# workaround for https://github.com/cross-rs/cross/issues/1345
97[package.metadata.cross.target.x86_64-unknown-netbsd]
98pre-build = [
99 "mkdir -p /tmp/netbsd",
100 "curl -fO https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.3/amd64/binary/sets/base.tar.xz",
101 "tar -C /tmp/netbsd -xJf base.tar.xz",
102 "cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib",
103 "rm base.tar.xz",
104 "rm -rf /tmp/netbsd",
105]
106