#!/usr/bin/env bash # Build the leleka-runtime test binary of THIS worktree in WSL (never on the server). # scripts/chain/build_rt.sh TAG [extra cargo args] run from Git Bash in the worktree; needs WSL distro "Ubuntu" # Result: WSL ~/chain-bin/rt-TAG (also copied to /../chain-bin-rt-TAG for scp from the Windows side). set -euo pipefail tag=${1:?tag} shift || true root=$(git rev-parse --show-toplevel) tar_win="$root/../wt-chain-$tag.tar" git -C "$root" -c core.autocrlf=false ls-files -co --exclude-standard -z | tar --force-local -C "$root" --null -T - -cf "$tar_win" tar_wsl="/mnt/c/Users/pavel/work/wt-chain-$tag.tar" wsl -d Ubuntu -e bash -lc " set -e source ~/.cargo/env export PATH=\$HOME/cuda-toolkits/13.2.2/bin:\$HOME/.cargo/bin:/usr/local/bin:/usr/bin:/bin rm -rf ~/chain-src && mkdir -p ~/chain-src ~/chain-bin && tar -xf '$tar_wsl' -C ~/chain-src cd ~/chain-src export CARGO_TARGET_DIR=\$HOME/chain-target nice -n 10 cargo test --no-run --locked --release -p leleka-runtime --lib $* 2>&1 | tee ~/chain-build-$tag.log | grep -E 'Executable|^error|warning: unused' | tail -5 exe=\$(grep -o 'target/release/deps/leleka_runtime-[0-9a-f]*' ~/chain-build-$tag.log | tail -1) cp \$CARGO_TARGET_DIR/\${exe#target/} ~/chain-bin/rt-$tag cp ~/chain-bin/rt-$tag /mnt/c/Users/pavel/work/chain-bin-rt-$tag ls -la ~/chain-bin/rt-$tag " rm -f "$tar_win"