fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
a4c87621
cleanup
files
| empty_wasi/ | |
| forked_getrandom/ | |
| src/ | |
| vendor/ | |
| .gitignore | 107 B |
| BUILD.bazel | 741 B |
| Cargo.lock | 1.6 KiB |
| Cargo.toml | 479 B |
| README.md | 1.1 KiB |
Local vendoring with patches
This demonstrates patching out crates when using the "local" vendor mode. The
example crate just depends on rand, and we patch out two of the transitive deps:
getrandomis forked. Inforked_getrandom/BUILD.bazelthe necessary filegroups are exposed so that the generated BUILD file atvendor/getrandom-0.2.8/BUILD.bazelcan use them.wasiis "empty-patched" because it's not actually used in the build. When using local vendoring,crate_universerunscargo vendorwhich isn't aware of which target-triples you're using. Thewasicrate is only used byrandwhen you're actually targetingwasi(which we're not), so we patch it out with a stub crate to avoid downloading and vendoring the source of the that crate. This can be helpful to avoid vendoring large crates or ones with conflicting licenses that aren't used in your build graph.
The result of our getrandom patch is that the binary is always given the
same value for seeding its RNG. Therefore we can test that rand::random
returns the same value to check that the patching behavior is working correctly.