-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Through `no_std` support, we now also support `wasm32v1-none`. - Introduced a new `std` crate feature that is enabled by default. Without it `#[no_std]` is enabled, but only on Web! This allows Web target to build without std, which is now supported by `wasm-bindgen` as well. Additionally, various changes had to be done to support `no_std`: - `no_std` does not support `thread_local!`, we use `once_cell` to polyfill this gap. `once_cell` is not a new dependency, it is already a dependency of `wasm-bindgen`. - With `feature = "std"`, we use `thread_local!` as before. - Without std and without `target_feature = "atomics"`, we use a `static mut` with `once_cell::unsync::Lazy`. - Without std and with atomics, we use [`#[thread_local]`](https://doc.rust-lang.org/1.83.0/unstable-book/language-features/thread-local.html?highlight=thread_l#thread_local) with `once_cell::unsync::Lazy`. - Some `f64` instructions are not available on `no_std` and had to be polyfilled. For this code from [`libm`](https://crates.io/crates/libm) was copied. Which is used by std as well. - `SystemTimeError` now only implements `Error` with `feature = "std"`. - `no_std` testing requires to refrain from using the default test harness. The problem was that native tests still needed to use the default test harness. To solve this, integration tests were removed from root crate and two workspace members added, that manually define all integration tests as test targets. The `tests-web` crate has `harness = false` on all tests, while `tests-native` functions regularly. This allow us to use the default test harness for native tests while disabling it for Web. Additionally, every test target requires the `run` crate feature, which are enabled by default depending on the target by the root crate. This way regular testing can function correctly for each target as long as `--all-features` is not used. E.g. `cargo test --workspace` and `cargo test --workspace --target wasm32-unknown-unknown` will work correctly. The `tests-web` library is used to implement the `panic_handler`, `global_allocator` and `critical_section`. It is always imported to reduce code duplication in all tests. - Used [`serde-json-core`](https://crates.io/crates/serde-json-core) to cover tests with `no_std` as well. - All links to std documentation had to be supplemented with manual link when `std` is not present. - Improvements to CI: - Refactored all matrices for simplification and covering `--no-default-features`. - Split regular and minimal versions building off tests. - Split doctests from regular tests. - Update Rust toolchain when testing `cargo publish`. - Test coverage improvements: - The new `wasm-bindgen` update allows us to refrain from having to pass `cfg` flags to the `wasm-bindgen` proc-macros. - Use Rust `llvm-tools` instead of the official LLVM package. - Remove invalid `script` tag from coverage report. - Retain coverage artifact instead of limiting it to one day. - Refactor large environment variables into global level ones. - Small fixes that were stumbled upon: - Expose `web_time::web` with `cfg(docsrs)` on native as well. - `Serialize` and `Deserialize` implementation are now marked with `doc(cfg(feature = "serde"))`. - Std docs.rs link unnecessarily including `stable`. - Recommendation for `-Ctarget-feature=+nontrapping-fptoint` was moved from the top-level to the "Usage" section. - The minimal version of Serde is now fully specified as v1.0.0. - Fix some typos in internal documentation.
- Loading branch information
Showing
40 changed files
with
1,726 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[target.wasm32-unknown-unknown] | ||
[target.'cfg(target_family = "wasm")'] | ||
runner = "wasm-bindgen-test-runner" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
name: | ||
Build ${{ matrix.target.description }} ${{ matrix.rust.description }} ${{ | ||
matrix.features.description }} | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- { target: x86_64-unknown-linux-gnu, description: Native } | ||
- { target: wasm32-unknown-unknown, description: Web } | ||
- { target: wasm32v1-none, description: Wasm v1 } | ||
rust: | ||
- { version: "1.60", description: MSRV, atomics: false } | ||
- { version: stable, atomics: false } | ||
- { version: nightly, atomics: false } | ||
- { | ||
version: nightly, | ||
description: with Atomics, | ||
atomics: true, | ||
component: --component rust-src, | ||
flags: "-Ctarget-feature=+atomics,+bulk-memory", | ||
build-std: true, | ||
} | ||
features: | ||
- { features: "", no_std: false } | ||
- { features: --features serde, no_std: false, description: (`serde`) } | ||
- { features: --no-default-features, no_std: true, description: (`no_std`) } | ||
- { | ||
features: --no-default-features --features serde, | ||
no_std: true, | ||
description: "(`no_std`, `serde`)", | ||
} | ||
exclude: | ||
- target: { target: x86_64-unknown-linux-gnu, description: Native } | ||
rust: { version: nightly } | ||
- target: { target: wasm32-unknown-unknown, description: Web } | ||
rust: { version: nightly, atomics: false } | ||
- target: { target: wasm32v1-none, description: Wasm v1 } | ||
rust: { version: "1.60" } | ||
- target: { target: wasm32v1-none, description: Wasm v1 } | ||
rust: { version: stable } | ||
- target: { target: wasm32v1-none, description: Wasm v1 } | ||
features: { no_std: false } | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install Rust | ||
run: | | ||
rustup toolchain install ${{ matrix.rust.version }} --profile minimal ${{ matrix.rust.component }} --target ${{ matrix.target.target }} | ||
rustup default ${{ matrix.rust.version }} | ||
- name: Set `build-std` components | ||
if: matrix.rust.build-std == true && matrix.features.no_std == false | ||
run: echo "BUILD_STD_COMPONENTS=-Zbuild-std=panic_abort,std" >> $GITHUB_ENV | ||
- name: Set `build-std` `no_std` components | ||
if: matrix.rust.build-std == true && matrix.features.no_std == true | ||
run: echo "BUILD_STD_COMPONENTS=-Zbuild-std=core,alloc" >> $GITHUB_ENV | ||
- name: Fix MSRV dependencies | ||
if: matrix.rust.version == '1.60' | ||
run: | | ||
cargo update -p bumpalo --precise 3.14.0 | ||
cargo update -p serde --precise 1.0.210 | ||
cargo update -p syn --precise 2.0.67 | ||
- name: Build | ||
env: | ||
RUSTFLAGS: ${{ matrix.rust.flags }} | ||
run: | ||
cargo build ${{ matrix.features.features }} --target ${{ matrix.target.target }} | ||
$BUILD_STD_COMPONENTS | ||
|
||
minimal-versions: | ||
name: | ||
Minimal Versions ${{ matrix.target.description }} ${{ matrix.rust.description }} ${{ | ||
matrix.features.description }} | ||
|
||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: minimal-versions | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- { target: x86_64-unknown-linux-gnu, description: Native } | ||
- { target: wasm32-unknown-unknown, description: Web } | ||
- { target: wasm32v1-none, description: Wasm v1 } | ||
rust: | ||
- { version: "1.60", description: MSRV } | ||
- { version: stable } | ||
- { version: nightly } | ||
features: | ||
- { features: "", no_std: false } | ||
- { features: --features serde, no_std: false, description: (`serde`) } | ||
- { features: --no-default-features, no_std: true, description: (`no_std`) } | ||
- { | ||
features: --no-default-features --features serde, | ||
no_std: true, | ||
description: "(`no_std`, `serde`)", | ||
} | ||
exclude: | ||
- target: { target: x86_64-unknown-linux-gnu, description: Native } | ||
rust: { version: nightly } | ||
- target: { target: wasm32-unknown-unknown, description: Web } | ||
rust: { version: nightly } | ||
- target: { target: wasm32v1-none, description: Wasm v1 } | ||
rust: { version: "1.60" } | ||
- target: { target: wasm32v1-none, description: Wasm v1 } | ||
rust: { version: stable } | ||
- target: { target: wasm32v1-none, description: Wasm v1 } | ||
features: { no_std: false } | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install Rust | ||
run: | | ||
rustup toolchain install ${{ matrix.rust.version }} --profile minimal --target ${{ matrix.target.target }} | ||
rustup default ${{ matrix.rust.version }} | ||
- name: Downgrade to minimal versions | ||
run: | | ||
rustup toolchain install nightly --profile minimal | ||
cargo +nightly update -Z minimal-versions | ||
- name: Fix Rust nightly incompatible dependencies | ||
if: matrix.rust.version == 'nightly' | ||
run: | | ||
cargo update -p proc-macro2 --precise 1.0.60 | ||
- name: Build | ||
run: cargo build ${{ matrix.features.features }} --target ${{ matrix.target.target }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.