fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
285c36a6
patching
files
| empty_wasi/ | |
| forked_getrandom/ | |
| src/ | |
| vendor/ | |
| .gitignore | 156 B |
| BUILD.bazel | 731 B |
| Cargo.lock | 1.4 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 neccesary 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 our build. When using local vendoring,crate_universerunscargo vendorwhich isn't aware of which targets you're using. Thewasicrate is only conditionally depended on 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 codebases or libraries with conflicting licenses that aren't used in your build graph.
The result of our getrandom patching is that our 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.