#!/usr/bin/env bash # Fetch a well-known Rust OSS codebase for the fold Rust-mode benchmark. # Defaults to ripgrep (~52k LOC Rust, ~100 .rs files across a Cargo workspace). # # Layout afterwards: # bench/corpora/rust-oss/ripgrep/ # Cargo.toml # crates/ # ... # # Set RUST_OSS_REPO and RUST_OSS_REF to override the target. set -euo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" REPO="${RUST_OSS_REPO:-https://github.com/BurntSushi/ripgrep.git}" REF="${RUST_OSS_REF:-master}" NAME="ripgrep" cd "$HERE" if [[ -d "$NAME/.git" ]]; then echo "rust-oss: $NAME already cloned at $HERE/$NAME; skipping." exit 0 fi echo "Cloning $REPO (ref=$REF, depth=1)..." git clone --depth 1 --filter=blob:none --branch "$REF" "$REPO" "$NAME" RUST_COUNT=$(find "$NAME" -name '*.rs' | wc -l | tr -d ' ') LOC=$(find "$NAME" -name '*.rs' -exec cat {} + | wc -l | tr -d ' ') echo "rust-oss: $NAME ready — $RUST_COUNT .rs files, $LOC lines" # Pre-fetch dependencies so cargo check inside fold-rust doesn't stall. echo "rust-oss: fetching cargo dependencies..." ( cd "$NAME" && cargo fetch 2>&1 | tail -3 ) || true echo "" echo "Next:" echo " python3 bench/run_rust_oss.py" echo " python3 bench/run_rust_oss.py --corpus $HERE/$NAME"