2024-04-08 22:42:40 +00:00
|
|
|
As we have multiple projects we use a workspace to manage them (it's way simpler and leads to less issues). In order
|
|
|
|
to vendor all the dependencies we need to store both the registry and the packages themselves.
|
2024-04-05 11:17:25 +00:00
|
|
|
|
2024-12-03 11:32:19 +00:00
|
|
|
Note that this includes the exact `std` dependencies for the rustc version used in CI (currently nightly-2024-12-01),
|
2024-04-09 15:15:15 +00:00
|
|
|
so you need to install `rustup component add rust-src` for the specific version.
|
|
|
|
|
|
|
|
* First step: (Re)-generate the Cargo.lock file (run under `workspace/`).
|
2024-04-05 11:17:25 +00:00
|
|
|
|
2024-04-08 22:42:40 +00:00
|
|
|
```bash
|
2024-04-09 15:15:15 +00:00
|
|
|
cargo generate-lockfile
|
2024-04-08 22:42:40 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
* Generate the local registry:
|
|
|
|
|
2024-04-09 15:15:15 +00:00
|
|
|
Note that we use both commands to vendor both registry and crates. No idea why both are necessary.
|
|
|
|
|
|
|
|
* First we need to install the tool if you don't already have it:
|
2024-04-05 11:17:25 +00:00
|
|
|
```bash
|
2024-12-03 11:32:19 +00:00
|
|
|
cargo install --version 0.2.7 cargo-local-registry
|
2024-04-05 11:17:25 +00:00
|
|
|
```
|
|
|
|
|
2024-04-09 15:15:15 +00:00
|
|
|
* Now add the local packages:
|
2024-04-05 11:17:25 +00:00
|
|
|
|
|
|
|
```bash
|
2024-04-09 15:15:15 +00:00
|
|
|
export CH_TOP_DIR=$(git rev-parse --show-toplevel)
|
|
|
|
export RUSTC_ROOT=$(rustc --print=sysroot)
|
|
|
|
|
|
|
|
cd "$CH_TOP_DIR"/rust/workspace
|
|
|
|
|
|
|
|
cargo local-registry --git --sync Cargo.lock "$CH_TOP_DIR"/contrib/rust_vendor
|
2024-12-03 11:32:19 +00:00
|
|
|
cp "$RUSTC_ROOT"/lib/rustlib/src/rust/library/Cargo.lock "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/
|
2024-04-09 15:15:15 +00:00
|
|
|
cargo local-registry --no-delete --git --sync "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/Cargo.lock "$CH_TOP_DIR"/contrib/rust_vendor
|
2024-12-03 11:32:19 +00:00
|
|
|
cp "$RUSTC_ROOT"/lib/rustlib/src/rust/library/Cargo.lock "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/
|
2024-04-09 15:15:15 +00:00
|
|
|
cargo local-registry --no-delete --git --sync "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/Cargo.lock "$CH_TOP_DIR"/contrib/rust_vendor
|
|
|
|
|
|
|
|
cargo vendor --no-delete --locked "$CH_TOP_DIR"/contrib/rust_vendor
|
|
|
|
cd "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/
|
|
|
|
cargo vendor --no-delete "$CH_TOP_DIR"/contrib/rust_vendor
|
|
|
|
cd "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/
|
|
|
|
cargo vendor --no-delete "$CH_TOP_DIR"/contrib/rust_vendor
|
|
|
|
|
2024-04-09 17:25:24 +00:00
|
|
|
# Remove windows only dependencies (which are really heavy and we don't want in the repo)
|
|
|
|
rm -rf "$CH_TOP_DIR"/contrib/rust_vendor/winapi* "$CH_TOP_DIR"/contrib/rust_vendor/windows*
|
|
|
|
|
|
|
|
# Cleanup the lock files we copied
|
2024-04-09 15:15:15 +00:00
|
|
|
rm "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/Cargo.lock "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/Cargo.lock
|
|
|
|
cd "$CH_TOP_DIR"/rust/workspace
|
2024-04-05 11:17:25 +00:00
|
|
|
```
|
2024-04-08 22:42:40 +00:00
|
|
|
|
2024-04-09 15:15:15 +00:00
|
|
|
The `rustc --print=sysroot` part includes `std` dependencies, required to build with sanitizer flags. It must be kept
|
|
|
|
in sync with the rustc version used in CI.
|