|
| 1 | +As we have multiple projects we use a workspace to manage them (it's way simpler and leads to less issues). In order |
| 2 | +to vendor all the dependencies we need to store both the registry and the packages themselves. |
| 3 | + |
| 4 | +Note that this includes the exact `std` dependencies for the rustc version used in CI (currently nightly-2024-12-01), |
| 5 | +so you need to install `rustup component add rust-src` for the specific version. |
| 6 | + |
| 7 | +* First step: (Re)-generate the Cargo.lock file (run under `workspace/`). |
| 8 | + |
| 9 | +```bash |
| 10 | +cargo generate-lockfile |
| 11 | +``` |
| 12 | + |
| 13 | +* Generate the local registry: |
| 14 | + |
| 15 | +Note that we use both commands to vendor both registry and crates. No idea why both are necessary. |
| 16 | + |
| 17 | + * First we need to install the tool if you don't already have it: |
| 18 | +```bash |
| 19 | +cargo install --version 0.2.7 cargo-local-registry |
| 20 | +``` |
| 21 | + |
| 22 | + * Now add the local packages: |
| 23 | + |
| 24 | +```bash |
| 25 | +export CH_TOP_DIR=$(git rev-parse --show-toplevel) |
| 26 | +export RUSTC_ROOT=$(rustc --print=sysroot) |
| 27 | +# Currently delta-lake is built outside the workspace (TODO) |
| 28 | +export DELTA_LAKE_DIR="$CH_TOP_DIR"/contrib/delta-kernel-rs |
| 29 | + |
| 30 | +# Clean the vendor repo |
| 31 | +rm -rf "$CH_TOP_DIR"/contrib/rust_vendor/* |
| 32 | + |
| 33 | +cd "$CH_TOP_DIR"/rust/workspace |
| 34 | +cargo local-registry --git --sync Cargo.lock "$CH_TOP_DIR"/contrib/rust_vendor |
| 35 | + |
| 36 | +# Now handle delta-lake |
| 37 | +cd "$DELTA_LAKE_DIR" |
| 38 | +cargo local-registry --no-delete --git --sync "$DELTA_LAKE_DIR/Cargo.lock" "$CH_TOP_DIR"/contrib/rust_vendor |
| 39 | + |
| 40 | +# Standard library deps |
| 41 | +cp "$RUSTC_ROOT"/lib/rustlib/src/rust/library/Cargo.lock "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/ |
| 42 | +cargo local-registry --no-delete --git --sync "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/Cargo.lock "$CH_TOP_DIR"/contrib/rust_vendor |
| 43 | +cp "$RUSTC_ROOT"/lib/rustlib/src/rust/library/Cargo.lock "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/ |
| 44 | +cargo local-registry --no-delete --git --sync "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/Cargo.lock "$CH_TOP_DIR"/contrib/rust_vendor |
| 45 | + |
| 46 | +# Now we vendor the modules themselves |
| 47 | +cd "$CH_TOP_DIR"/rust/workspace |
| 48 | +cargo vendor --no-delete --locked "$CH_TOP_DIR"/contrib/rust_vendor |
| 49 | +cd "$DELTA_LAKE_DIR" |
| 50 | +cargo vendor --no-delete --locked "$CH_TOP_DIR"/contrib/rust_vendor |
| 51 | +cd "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/ |
| 52 | +cargo vendor --no-delete "$CH_TOP_DIR"/contrib/rust_vendor |
| 53 | +cd "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/ |
| 54 | +cargo vendor --no-delete "$CH_TOP_DIR"/contrib/rust_vendor |
| 55 | + |
| 56 | +# Remove windows only dependencies (which are really heavy and we don't want in the repo) |
| 57 | +rm -rf "$CH_TOP_DIR"/contrib/rust_vendor/winapi* "$CH_TOP_DIR"/contrib/rust_vendor/windows* |
| 58 | + |
| 59 | +# Cleanup the lock files we copied |
| 60 | +rm "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/Cargo.lock "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/Cargo.lock |
| 61 | +cd "$CH_TOP_DIR"/rust/workspace |
| 62 | +``` |
| 63 | + |
| 64 | +The `rustc --print=sysroot` part includes `std` dependencies, required to build with sanitizer flags. It must be kept |
| 65 | +in sync with the rustc version used in CI. |
0 commit comments