Skip to content

Commit 2df5d1f

Browse files
committed
Adapt to changes in getrandom 0.3
This uses a build script to enable the `wasm_js` backend when the target is exactly `wasm32-unknown-unknown` and the `wasm` feature of `gix-diff` is enabled. The recently added step in the CI `wasm` job to enable it for subsequent steps of that job is accordingly removed. If successful, this creates a situation roughly similar to what we had before: authors of crates that use `gix-diff` will not have to set anything, beyond enabling the `wasm` feature. I don't know if that is ideal or not; see discussion in #2092. However, it seems like it is at least as good as how `gix-diff` used `getrandom` 0.2.
1 parent 037cb8c commit 2df5d1f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,6 @@ jobs:
457457
for feature in progress parallel io-pipe crc32 zlib cache-efficiency-debug; do
458458
cargo build -p gix-features --features "$feature" --target "$TARGET"
459459
done
460-
- name: enable wasm_js backend
461-
if: matrix.target == 'wasm32-unknown-unknown'
462-
run: echo RUSTFLAGS='--cfg getrandom_backend="wasm_js"' >> "$GITHUB_ENV"
463460
- name: crates with 'wasm' feature
464461
run: |
465462
set -x

gix-diff/build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use std::env::var_os;
2+
3+
fn main() {
4+
if var_os("TARGET") == Some("wasm32-unknown-unknown") && var_os("CARGO_FEATURE_WASM") == Some("1") {
5+
println!("cargo:rustc-cfg=getrandom_backend=\"wasm_js\"");
6+
}
7+
}

0 commit comments

Comments
 (0)