Skip to content

Release Version 0.2 #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
6057367
Only impl std traits if feature is specified (#106)
josephlr Sep 20, 2019
add45a3
Remove dummy implementation (#107)
josephlr Sep 22, 2019
1f1f964
Merge branch 'master' into 0.2
josephlr Oct 24, 2019
cf2d81b
Improve src/lib.rs cfgs (#119)
josephlr Oct 25, 2019
8096bac
0.2: Error and Testing improvements (#120)
josephlr Oct 28, 2019
0f14f2a
Merge branch 'master' into 0.2
josephlr Jan 8, 2020
d6b75d1
log: Remove optional log dependancy (#131)
josephlr Jan 9, 2020
448bcac
custom: Add support for Custom RNGs
josephlr Oct 26, 2019
3d7a7b5
Remove built-in support for wasm32-unknown-unknown
josephlr Oct 26, 2019
7d558f1
custom: Add custom RNG for stdweb
josephlr Oct 26, 2019
8365277
custom: Add Custom RNG for wasm-bindgen
josephlr Oct 26, 2019
4263ac6
custom: Allow no_std custom RNG handlers
josephlr Feb 19, 2020
cd84484
target: Drop support for some x86_64 targets
josephlr Feb 19, 2020
ff6299d
cpu: Add support for CPU-based randomness
josephlr Feb 19, 2020
1375181
tests: Improve testing infrastructure
josephlr Feb 19, 2020
52e7e9f
tests: Test CPU-based RNG on all x86 targets
josephlr Feb 19, 2020
2e39004
rdrand: Add 32-bit x86 support
josephlr Feb 19, 2020
c25d0a8
travis: Fix wasm32 CI
josephlr Apr 25, 2020
3d17318
Merge pull request #141 from josephlr/travis
dhardy Apr 26, 2020
d1a84db
error: Make internal_error! a function
josephlr Feb 25, 2020
b3d3fbc
assert: Make use of asserts consistent
josephlr Feb 26, 2020
afcfcd1
build: Remove getrandom_uwp cfg
josephlr Feb 26, 2020
138d903
ios: Don't use SecRandom type
josephlr Feb 26, 2020
74eca5e
fmt: Use consistent include style
josephlr Feb 26, 2020
c7862af
travis: Allow nightly builds to fail
josephlr Apr 27, 2020
717b5cc
Merge pull request #145 from josephlr/nightly
dhardy Apr 27, 2020
7bfdabf
wasm-bindgen: Added support for Internet Explorer 11
zer0x64 Apr 24, 2020
ec4a3e1
Fixing Webpack require warning
Pauan Mar 30, 2020
8191d7f
Merge pull request #143 from josephlr/fixing-webpack-warning
dhardy Apr 28, 2020
7631f75
ci: Pin the Cross binary to avoid breaking the CI
josephlr May 23, 2020
10df558
AppVeyor: Run CI on 0.2 branch
josephlr May 25, 2020
a29180a
wasm32: Unify error codes an implementations
josephlr May 22, 2020
618593c
cpu: Have "cpu" feature take precedence over "custom"
josephlr May 28, 2020
6aba12c
Rename "cpu" feature to "rdrand"
josephlr May 29, 2020
eacffd5
wasm: Move JS-based Custom RNGs back into the main crate
josephlr May 28, 2020
11b4f9e
wasm: Update testing framework
josephlr May 28, 2020
706a429
stdweb: Remove CI runs with cargo-web
josephlr Jul 21, 2020
f6af828
ci: Remove old reference to wasm-bindgen-getrandom
josephlr Jul 21, 2020
2b03b0e
Remove workaround for older Linux kernels
newpavlov Jul 19, 2020
fc83790
rustfmt: Run cargo fmt
josephlr Jul 22, 2020
24e5886
bsd_arandom: Read only 256 bytes at a time
josephlr Aug 14, 2020
2723e7f
travis: Apply #157 to 0.2 branch
josephlr Sep 8, 2020
0a5017e
Update MSRV to 1.34
josephlr Sep 8, 2020
c36dc82
travis: Stop pinning nightly on 0.2
josephlr Sep 8, 2020
4d750dd
travis: Enable Firefox testing
josephlr Sep 9, 2020
99260df
Update docs for 0.2
josephlr May 25, 2020
4f4009a
Format compile_error!
josephlr Sep 8, 2020
e8ff222
docs: Update wasm32 support section
josephlr Sep 8, 2020
b416060
docs: Clarify when/where to use custom implementations
josephlr Sep 8, 2020
bf6d124
travis: Make sure to run docs tests for all features
josephlr Sep 9, 2020
a6fa63c
docs: Update section headers
josephlr Sep 9, 2020
1ebd2ce
docs: Clarify intended usage for Custom RNGs
josephlr Sep 9, 2020
b8c0c8d
custom: Add check for function type
josephlr Sep 9, 2020
e0c155e
docs: Clarify deps of root binary crate
josephlr Sep 9, 2020
b929998
docs: add target triple to docs table
josephlr Sep 10, 2020
5f4886b
Merge branch 'master' into 0.2
josephlr Sep 10, 2020
5d2a4a2
Update Changelog for 0.2
josephlr Sep 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 58 additions & 75 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
language: rust
sudo: false
os: linux
dist: focal

matrix:
env:
global:
# All of the supported x86 Linux targets
- LINUX_TARGETS="x86_64-unknown-linux-gnu x86_64-unknown-linux-musl i686-unknown-linux-gnu i686-unknown-linux-musl"
# Targets that we just build (rather than run and test)
- STD_TARGETS="x86_64-sun-solaris x86_64-unknown-freebsd x86_64-fuchsia x86_64-unknown-netbsd x86_64-unknown-redox x86_64-fortanix-unknown-sgx"
- NO_STD_TARGETS="x86_64-unknown-cloudabi x86_64-unknown-uefi x86_64-unknown-hermit x86_64-unknown-l4re-uclibc x86_64-uwp-windows-gnu x86_64-wrs-vxworks"

jobs:
include:
- name: "Linux, 1.32.0"
rust: 1.32.0
os: linux
- name: "Linux, 1.34.0"
rust: 1.34.0

- name: "OSX, 1.32.0"
rust: 1.32.0
- name: "OSX, 1.34.0"
rust: 1.34.0
os: osx

- name: "Linux, stable"
Expand All @@ -22,7 +29,6 @@ matrix:
- rustup target add aarch64-apple-ios
script:
- cargo test
- cargo test --examples
- cargo build --target aarch64-apple-ios

- name: "Linux, beta"
Expand All @@ -37,13 +43,13 @@ matrix:
- rustup target add wasm32-unknown-unknown
- rustup target add wasm32-wasi
# Get latest geckodriver
# - export VERSION=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | jq -r ".tag_name")
# - wget -O geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/$VERSION/geckodriver-$VERSION-linux64.tar.gz
# - tar -xzf geckodriver.tar.gz
- export VERSION=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | jq -r ".tag_name")
- wget -O geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/$VERSION/geckodriver-$VERSION-linux64.tar.gz
- tar -xzf geckodriver.tar.gz -C $HOME
# Get latest chromedirver
- export VERSION=$(wget -q -O - https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
- wget -O chromedriver.zip https://chromedriver.storage.googleapis.com/$VERSION/chromedriver_linux64.zip
- unzip chromedriver.zip
- unzip chromedriver.zip -d $HOME
# Get cargo-web
# - export VERSION=0.6.26 # Pin version for stability
# - wget -O cargo-web.gz https://github.com/koute/cargo-web/releases/download/$VERSION/cargo-web-x86_64-unknown-linux-gnu.gz
Expand All @@ -60,17 +66,17 @@ matrix:
# Place the runner binaries in our PATH
- mv wasmtime wasm-bindgen-test-runner $HOME/.cargo/bin
script:
# wasi tests
- cargo test --target wasm32-wasi
# stdweb tests (Node, Chrome)
# stdweb (wasm32-unknown-unknown) tests are currently broken (see https://github.com/koute/cargo-web/issues/243)
# - cargo web test --nodejs --target=wasm32-unknown-unknown --features=stdweb
# - cargo web test --target=wasm32-unknown-unknown --features=stdweb
# wasm-bindgen tests (Node, Firefox, Chrome)
- cargo test --target wasm32-unknown-unknown --features=wasm-bindgen
# Firefox is broken, see https://github.com/rustwasm/wasm-bindgen/issues/2261
# - GECKODRIVER=$PWD/geckodriver cargo test --target wasm32-unknown-unknown --features=test-in-browser
- CHROMEDRIVER=$PWD/chromedriver cargo test --target wasm32-unknown-unknown --features=test-in-browser
# - cargo web test --features js --nodejs
# - cargo web test --features js
- cargo build --features js
# wasm-bindgen (wasm32-unknown-unknown) tests (Node, Firefox, Chrome)
- cargo test --target wasm32-unknown-unknown --features js
- GECKODRIVER=$HOME/geckodriver
cargo test --target wasm32-unknown-unknown --features js,test-in-browser
- CHROMEDRIVER=$HOME/chromedriver
cargo test --target wasm32-unknown-unknown --features js,test-in-browser

- name: "WASM via Emscripten"
rust: stable
Expand All @@ -90,85 +96,63 @@ matrix:
# Prevent 'wasm2js does not support source maps yet' error.
- RUSTFLAGS='-C debuginfo=0' cargo test --target asmjs-unknown-emscripten

- name: "Linux, nightly, docs"

- &nightly_and_docs
name: "Linux, nightly, docs"
rust: nightly
os: linux
install:
- rustup target add wasm32-unknown-unknown
- cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
- cargo deadlinks -V
script:
- cargo test
- cargo test --benches
- cargo test --examples
# Check that setting various features does not break the build
- cargo build --features=std
- cargo build --features=custom
# remove cached documentation, otherwise files from previous PRs can get included
- rm -rf target/doc
- cargo doc --no-deps --all --features=std,log
- cargo doc --no-deps --features=std,custom
- cargo deadlinks --dir target/doc
# also test minimum dependency versions are usable
# Check that our tests pass in the default/minimal configuration
- cargo test --tests --benches --features=std,custom
- cargo generate-lockfile -Z minimal-versions
- cargo test
- cargo test --tests --benches

- name: "OSX, nightly, docs"
rust: nightly
- <<: *nightly_and_docs
name: "OSX, nightly, docs"
os: osx

- name: "cross-platform tests"
rust: nightly
addons:
apt:
packages:
- gcc-multilib
install:
- cargo --list | egrep "^\s*deadlinks$" -q || cargo install cargo-deadlinks
- cargo deadlinks -V
- echo $LINUX_TARGETS | xargs -n1 rustup target add
script:
- cargo test
- cargo test --benches
- cargo test --examples
# remove cached documentation, otherwise files from previous PRs can get included
- rm -rf target/doc
- cargo doc --no-deps --all --features=std,log
- cargo deadlinks --dir target/doc
# also test minimum dependency versions are usable
- cargo generate-lockfile -Z minimal-versions
- cargo test
# We run tests for all supported x86 Linux targets
- echo $LINUX_TARGETS | xargs -t -n1 cargo test --target

- name: "cross-platform build only"
rust: nightly
install:
- rustup target add x86_64-sun-solaris
- rustup target add x86_64-unknown-freebsd
- rustup target add x86_64-fuchsia
- rustup target add x86_64-unknown-netbsd
- rustup target add x86_64-unknown-redox
- rustup target add x86_64-fortanix-unknown-sgx
- echo $STD_TARGETS | xargs -n1 rustup target add
# For no_std targets
- rustup component add rust-src
- cargo install cargo-xbuild || true
- cargo --list | egrep "^\s*xbuild$" -q || cargo install cargo-xbuild
script:
- cargo build --target=x86_64-sun-solaris
- cargo build --target=x86_64-unknown-freebsd
- cargo build --target=x86_64-fuchsia
- cargo build --target=x86_64-unknown-netbsd
- cargo build --target=x86_64-unknown-redox
- cargo build --target=x86_64-fortanix-unknown-sgx
- cargo xbuild --target=x86_64-unknown-cloudabi
- cargo xbuild --target=x86_64-unknown-uefi
- cargo xbuild --target=x86_64-unknown-hermit
- cargo xbuild --target=x86_64-unknown-l4re-uclibc
- cargo xbuild --target=x86_64-wrs-vxworks
# We test that getrandom builds for all targets
- echo $STD_TARGETS | xargs -t -n1 cargo build --target
- echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=rdrand --target
# also test minimum dependency versions are usable
- cargo generate-lockfile -Z minimal-versions
- cargo build --target=x86_64-sun-solaris
- cargo build --target=x86_64-unknown-freebsd
- cargo build --target=x86_64-fuchsia
- cargo build --target=x86_64-unknown-netbsd
- cargo build --target=x86_64-unknown-redox
- cargo build --target=x86_64-fortanix-unknown-sgx
- cargo xbuild --target=x86_64-unknown-cloudabi
- cargo xbuild --target=x86_64-unknown-uefi
- cargo xbuild --target=x86_64-unknown-hermit
- cargo xbuild --target=x86_64-unknown-l4re-uclibc
- cargo xbuild --target=x86_64-uwp-windows-gnu
- echo $STD_TARGETS | xargs -t -n1 cargo build --target
- echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=rdrand --target

# Trust cross-built/emulated targets. We must repeat all non-default values.
- name: "Linux (MIPS, big-endian)"
env: TARGET=mips-unknown-linux-gnu
rust: stable
sudo: required
dist: trusty
services: docker
install:
Expand All @@ -180,7 +164,6 @@ matrix:
- name: "Android (ARMv7)"
env: TARGET=armv7-linux-androideabi
rust: stable
sudo: required
dist: trusty
services: docker
install:
Expand Down Expand Up @@ -209,7 +192,6 @@ before_script:

script:
- cargo test
- cargo test --examples

after_script: set +e

Expand All @@ -229,3 +211,4 @@ notifications:
branches:
only:
- master
- 0.2
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,42 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.0] - 2020-09-10
### Features for using getrandom on unsupported targets

The following (off by default) Cargo features have been added:
- `"rdrand"` - use the RDRAND instruction on `no_std` `x86`/`x86_64` targets [#133]
- `"js"` - use JavaScript calls on `wasm32-unknown-unknown` [#149]
- Replaces the `stdweb` and `wasm-bindgen` features (which are removed)
- `"custom"` - allows a user to specify a custom implementation [#109]

### Breaking Changes
- Unsupported targets no longer compile [#107]
- Change/Add `Error` constants [#120]
- Only impl `std` traits when the `"std"` Cargo feature is specified [#106]
- Remove offical support for Hermit, L4Re, and UEFI [#133]
- Remove optional `"log"` dependancy [#131]
- Update minimum supported Linux kernel to 2.6.32 [#153]
- Update MSRV to 1.34 [#159]

[#106]: https://github.com/rust-random/getrandom/pull/106
[#107]: https://github.com/rust-random/getrandom/pull/107
[#109]: https://github.com/rust-random/getrandom/pull/109
[#120]: https://github.com/rust-random/getrandom/pull/120
[#131]: https://github.com/rust-random/getrandom/pull/131
[#133]: https://github.com/rust-random/getrandom/pull/133
[#149]: https://github.com/rust-random/getrandom/pull/149
[#153]: https://github.com/rust-random/getrandom/pull/153
[#159]: https://github.com/rust-random/getrandom/pull/159

## [0.1.15] - 2020-09-10
### Changed
- Added support for Internet Explorer 11 [#139]
- Fix Webpack require warning with `wasm-bindgen` [#137]

[#137]: https://github.com/rust-random/getrandom/pull/137
[#139]: https://github.com/rust-random/getrandom/pull/139

## [0.1.14] - 2020-01-07
### Changed
- Remove use of spin-locks in the `use_file` module. [#125]
Expand Down
31 changes: 19 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "getrandom"
version = "0.1.14"
version = "0.2.0"
edition = "2018"
authors = ["The Rand Project Developers"]
license = "MIT OR Apache-2.0"
Expand All @@ -15,7 +15,6 @@ travis-ci = { repository = "rust-random/getrandom" }
appveyor = { repository = "rust-random/getrandom" }

[dependencies]
log = { version = "0.4", optional = true }
cfg-if = "0.1.2"

# When built as part of libstd
Expand All @@ -28,18 +27,26 @@ libc = { version = "0.2.64", default-features = false }
[target.'cfg(target_os = "wasi")'.dependencies]
wasi = "0.9"

[target.wasm32-unknown-unknown.dependencies]
wasm-bindgen = { version = "0.2.29", optional = true }
stdweb = { version = "0.4.18", optional = true }

[target.wasm32-unknown-unknown.dev-dependencies]
wasm-bindgen-test = "0.2"
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown", cargo_web))'.dependencies]
stdweb = { version = "0.4.18", default-features = false, optional = true }
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown", not(cargo_web)))'.dependencies]
wasm-bindgen = { version = "0.2.62", default-features = false, optional = true }
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown", not(cargo_web)))'.dev-dependencies]
wasm-bindgen-test = "0.3.18"

[features]
# Implement std-only traits for getrandom::Error
std = []
# Enables dummy implementation for unsupported targets
dummy = []
# Feature to enable fallback RDRAND-based implementation on x86/x86_64
rdrand = []
# Feature to enable JavaScript bindings on wasm32-unknown-unknown
js = ["stdweb", "wasm-bindgen"]
# Feature to enable custom RNG implementations
custom = []
# Unstable feature to support being a libstd dependency
rustc-dep-of-std = ["compiler_builtins", "core"]
# Unstable feature for testing
test-in-browser = ["wasm-bindgen"]
# Unstable/test-only feature to run wasm-bindgen tests in a browser
test-in-browser = []

[package.metadata.docs.rs]
features = ["std", "custom"]
34 changes: 6 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Add this to your `Cargo.toml`:

```toml
[dependencies]
getrandom = "0.1"
getrandom = "0.2"
```

Then invoke the `getrandom` function:
Expand All @@ -37,36 +37,14 @@ fn get_random_buf() -> Result<[u8; 32], getrandom::Error> {
}
```

## Features

This library is `no_std` for every supported target. However, getting randomness
usually requires calling some external system API. This means most platforms
will require linking against system libraries (i.e. `libc` for Unix,
`Advapi32.dll` for Windows, Security framework on iOS, etc...).

The `log` library is supported as an optional dependency. If enabled, error
reporting will be improved on some platforms.

For the `wasm32-unknown-unknown` target, one of the following features should be
enabled:

- [`wasm-bindgen`](https://crates.io/crates/wasm_bindgen)
- [`stdweb`](https://crates.io/crates/stdweb)

By default, compiling `getrandom` for an unsupported target will result in
a compilation error. If you want to build an application which uses `getrandom`
for such target, you can either:
- Use [`[replace]`][replace] or [`[patch]`][patch] section in your `Cargo.toml`
to switch to a custom implementation with a support of your target.
- Enable the `dummy` feature to have getrandom use an implementation that always
fails at run-time on unsupported targets.

[replace]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-replace-section
[patch]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-patch-section
For more information about supported targets, entropy sources, `no_std` targets,
crate features, WASM support and Custom RNGs see the
[`getrandom` documentation](https://docs.rs/getrandom/latest) and
[`getrandom::Error` documentation](https://docs.rs/getrandom/latest/getrandom/struct.Error.html).

## Minimum Supported Rust Version

This crate requires Rust 1.32.0 or later.
This crate requires Rust 1.34.0 or later.

# License

Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ environment:

matrix:
- TARGET: x86_64-pc-windows-msvc
CHANNEL: 1.32.0
CHANNEL: 1.34.0
- TARGET: x86_64-pc-windows-msvc
CHANNEL: stable
- TARGET: x86_64-pc-windows-msvc
Expand Down Expand Up @@ -50,3 +50,4 @@ test_script:
branches:
only:
- master
- 0.2
1 change: 0 additions & 1 deletion benches/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(test)]
extern crate getrandom;
extern crate test;

#[bench]
Expand Down
2 changes: 0 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ fn main() {
if target.contains("-uwp-windows-") {
// for BCryptGenRandom
println!("cargo:rustc-link-lib=bcrypt");
// to work around unavailability of `target_vendor` on Rust 1.33
println!("cargo:rustc-cfg=getrandom_uwp");
} else if target.contains("windows") {
// for RtlGenRandom (aka SystemFunction036)
println!("cargo:rustc-link-lib=advapi32");
Expand Down
Loading