Files
komorebi/tools/trim-target
T
LGUG2Z 1879b86a5c build(tools): add trim-target, gate-lock and lite-env
Optional helpers for a shared host: trim-target deletes stale test executables from the
persistent cargo target dirs, gate-lock is a FIFO flock for heavy and timing-sensitive gates,
lite-env sources debug-info-off cargo settings. Copies of the host-side scripts with these
differences:
- trim-target: the default scratch dir is `${XDG_CACHE_HOME:-$HOME/.cache}/komorebi-fast-check`
  (was a /tmp/claude-1000/... scratchpad path), the same as fast-check;
- gate-lock: GATE_LOCK_DIR defaults to `${XDG_STATE_HOME:-$HOME/.local/state}/komorebi-gate`
  (was /home/jado/komomono-work/.gate), in the header and in the code;
- gate-lock: "/proc/$pid/cmdline" is quoted and a shellcheck directive disables SC2012 and
  SC2016 (ls of plain queue ticket names, and a bash -c script expanding its own $1);
- lite-env: a `# shellcheck shell=bash` first line.
Not committed: mini (host and credential specific), host-sample and jitter-probe (host
measurement), the .bak files.

Verified: bash -n and shellcheck clean. Not run: gate-lock was tested by its author with a scratch
GATE_LOCK_DIR before this change; the default path change is untested.
2026-11-05 15:03:26 -08:00

17 lines
888 B
Bash
Executable File

#!/usr/bin/env bash
# Delete stale test executables from the shared cargo target dirs. A debug test binary is about
# 290MB and every workspace path that builds the KDE tests adds up to 79 of them; the KDE target
# dir grew from 30G to 109G in one evening this way. The binaries are rebuilt on demand.
# tools/trim-target [MINUTES] (default 45: binaries untouched for that long are removed)
set -euo pipefail
minutes=${1:-45}
S=${FAST_CHECK_SCRATCH:-${XDG_CACHE_HOME:-$HOME/.cache}/komorebi-fast-check}
for d in "$S"/kde-target "$S"/target-fast-win "$S"/target-fast-mac "$S"/target-fast-native "$S"/target-spikes; do
[ -d "$d/debug/deps" ] || continue
before=$(du -sm "$d" | cut -f1)
find "$d/debug/deps" -maxdepth 1 -type f -perm -u+x ! -name '*.*' -mmin +"$minutes" -delete
after=$(du -sm "$d" | cut -f1)
echo "$d: ${before}M -> ${after}M"
done
df -h / /mnt/e | tail -2