Files
komorebi/tools/kde-closure-check
T
LGUG2Z 27b36a457e build(tools): add kde-closure-check and e2e-needed
kde-closure-check fails when komorebi-for-kde/nix/root-crates.json differs from the KDE cargo
closure; e2e-needed says whether a diff touches anything the Windows e2e binaries are built
from. Copies of the host-side scripts with these differences only:
- kde-closure-check: none (it already finds the repository relative to the script); verbatim.
- e2e-needed: `tools/*` joins the paths that cannot change the binaries (docs, .github), so a
  change to the tools is NO instead of "not understood: treated as needed";
- e2e-needed: `# shellcheck disable=SC2001` before `set` (the sed one-liners indent multi-line
  output); no behaviour change.

Verified: bash -n and shellcheck clean; `tools/kde-closure-check .` prints "ok: 11 root crates
match the KDE cargo closure"; `tools/e2e-needed --since <rev>` gives the same output as the host
copy on a range without tools/ files, and NO for a tools-only range.
2026-11-05 15:03:26 -08:00

27 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Fails if the crates outside komorebi-for-kde that the KDE packages depend on differ from the list the KDE
# source filter uses (komorebi-for-kde/nix/root-crates.json).
# Usage: tools/kde-closure-check [REPO_ROOT] (default: the repository this script is in)
# Works for the merged workspace (one root Cargo.toml) and for the old KDE workspace.
set -euo pipefail
root=$(cd "${1:-$(dirname "$0")/..}" && pwd)
[ -d "$root/komorebi-for-kde" ] || root=$(cd "$root/.." && pwd)
want=$(jq -r '.[]' "$root/komorebi-for-kde/nix/root-crates.json" | sort)
if [ -f "$root/komorebi-for-kde/Cargo.toml" ]; then
have=$(cd "$root/komorebi-for-kde" && nice -n 19 cargo metadata --offline --format-version 1 \
| jq -r --arg r "$root/" '.packages[] | select(.source == null) | .manifest_path
| select(startswith($r) and (startswith($r + "komorebi-for-kde/") | not))
| ltrimstr($r) | sub("/Cargo.toml$"; "")' | sort)
else
# merged workspace: the closure of the KDE packages on a Linux target
have=$(cd "$root" && for p in komorebi-linux komorebic-linux komorebi-client-linux komorebi-hotkeys; do
nice -n 19 cargo tree --offline --locked -p "$p" --target x86_64-unknown-linux-gnu --prefix none -e normal,build,dev 2>/dev/null
done | grep -o "($root/[^)]*)" | tr -d '()' | sed "s#^$root/##" | grep -v '^komorebi-for-kde' | sort -u)
fi
if [ "$want" != "$have" ]; then
echo "KDE source filter and cargo closure differ" >&2
diff <(echo "$want") <(echo "$have") | sed 's/^</ only in root-crates.json:/; s/^>/ only in cargo closure: /' >&2
exit 1
fi
echo "ok: $(echo "$want" | wc -l) root crates match the KDE cargo closure"