| Serge Bazanski | cbf1fa9 | 2021-07-02 17:28:50 +0200 | [diff] [blame^] | 1 | Rust dependency management |
| 2 | ========================== |
| 3 | |
| 4 | You will need cargo-raze installed on your host operating system, as currently building cargo-raze with Bazel [seems to be broken](https://github.com/google/cargo-raze/issues/423) (and pulls in _a lot_ of transitive dependencies). |
| 5 | |
| 6 | $ cargo install cargo-raze |
| 7 | |
| 8 | Dependencies are defined in Cargo.toml. Raze is used to lock these into concrete versions (in `//third_party/rust/cargo/Cargo.raze.lock`) and to generate BUILDfiles (in `//third_party/rust/cargo/remote/...` and `//third_party/rust/BUILD.bazel`). |
| 9 | |
| 10 | In contrast to Gazelle/go dependencies, the BUILD files for external packages are actually commited into the repository instead of being generated on demand during analysis phase. This makes Raze a bit more noisy in Git history, but vastly speeds up analysis phase, and doesn't rely on an early, pre-analysis Go toolchain that Gazelle relies on. |
| 11 | |
| 12 | To relock dependencies and regenerate BUILDfiles: |
| 13 | |
| 14 | $ cd third_party/rust/ |
| 15 | $ cargo raze |
| 16 | |
| 17 | For more information on the process, consult the official [cargo-raze documentation](https://github.com/google/cargo-raze). |