build: one shared target dir, less debuginfo, disk cleanup script
- profile.dev: line-tables-only for workspace crates, no debuginfo for dependencies (test/example binaries linked gpui, libwebrtc and tract with full DWARF) - build-windows.sh / deploy-windows.sh default to the shared ~/.cache/rusty-teams/target instead of crates/app/target per worktree, so dependencies, libwebrtc and patched gpui are built once - scripts/build-cache.sh: setup (target-dir in ~/.cargo/config.toml), status, clean (old per-worktree target dirs, cap for the shared one, kache gc) - headless-shot.sh finds the binary via cargo metadata - README: tests without linking the example binaries Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ETPxPg5vShrPxaGEbzvfZJ
@@ -49,6 +49,14 @@ gpui-base = { path = "vendor/gpui-base" }
49
49
gpui-component = { path = "vendor/gpui-component" }
50
50
webrtc-sys = { path = "vendor/webrtc-sys" }
51
51
52
# Linux builds and tests: file:line backtraces for our crates, no debuginfo for dependencies.
53
# Full debuginfo (the default) made every test and example binary hundreds of MB, gpui, libwebrtc and tract included.
54
[profile.dev]
55
debug = "line-tables-only"
56
57
[profile.dev.package."*"]
58
debug = false
59
52
60
[profile.release]
53
61
incremental = true
54
62
codegen-units = 256
@@ -49,6 +49,14 @@ gpui-base = { path = "vendor/gpui-base" }49
gpui-component = { path = "vendor/gpui-component" }49
gpui-component = { path = "vendor/gpui-component" }50
webrtc-sys = { path = "vendor/webrtc-sys" }50
webrtc-sys = { path = "vendor/webrtc-sys" }51
51
52
# Linux builds and tests: file:line backtraces for our crates, no debuginfo for dependencies.53
# Full debuginfo (the default) made every test and example binary hundreds of MB, gpui, libwebrtc and tract included.54
[profile.dev]55
debug = "line-tables-only"56
57
[profile.dev.package."*"]58
debug = false59
52
[profile.release]60
[profile.release]53
incremental = true61
incremental = true54
codegen-units = 25662
codegen-units = 256@@ -98,10 +98,12 @@ cargo run -p app -- --demo
98
98
99
99
| Task | Command |
100
100
|---|---|
101
| Linux build needs clang + mold (set in `.cargo/config.toml`); sccache shares compiled deps across worktrees | `sudo apt install clang mold sccache` |
101
| Linux build needs clang + mold (set in `.cargo/config.toml`) | `sudo apt install clang mold` |
102
| One target dir for all worktrees (`~/.cache/rusty-teams/target`), once per machine; unset any `CARGO_TARGET_DIR` | `scripts/build-cache.sh setup` |
103
| Disk use, and trimming old target dirs and the shared one to 40 GB (dry run without `--apply`) | `scripts/build-cache.sh status`, `scripts/build-cache.sh clean --apply` |
102
104
| Against Chrome on a debug port | `cargo run -p app -- --endpoint http://127.0.0.1:9222` |
103
105
| Windows exe from WSL/Linux | `scripts/build-windows.sh crates/app teams` |
104
| Tests | `cargo test` |
106
| Tests (without linking the ~30 example binaries) | `cargo test --workspace --lib --bins --tests` |
105
107
| Headless screenshot (Xvfb, xdotool, xclip, mesa-vulkan-drivers) | `cargo build -p app && scripts/headless-shot.sh shot.png -- "mousemove 450 740" "click 1" "type hello"` |
106
108
| Layout sweep before every UI deploy: 8 screens at 640x480 and 1920x1080, PNGs in `target/layout-sweep` (look at each) | `cargo build -p app && scripts/layout-sweep.sh` |
107
109
| Layout guard: no overlapping or clipped elements, no negative offsets outside `widgets::corner_badge` | `cargo test -p app layout_guard` |
@@ -98,10 +98,12 @@ cargo run -p app -- --demo98
98
99
| Task | Command |99
| Task | Command |100
|---|---|100
|---|---|101
| Linux build needs clang + mold (set in `.cargo/config.toml`); sccache shares compiled deps across worktrees | `sudo apt install clang mold sccache` |101
| Linux build needs clang + mold (set in `.cargo/config.toml`) | `sudo apt install clang mold` |102
| One target dir for all worktrees (`~/.cache/rusty-teams/target`), once per machine; unset any `CARGO_TARGET_DIR` | `scripts/build-cache.sh setup` |103
| Disk use, and trimming old target dirs and the shared one to 40 GB (dry run without `--apply`) | `scripts/build-cache.sh status`, `scripts/build-cache.sh clean --apply` |102
| Against Chrome on a debug port | `cargo run -p app -- --endpoint http://127.0.0.1:9222` |104
| Against Chrome on a debug port | `cargo run -p app -- --endpoint http://127.0.0.1:9222` |103
| Windows exe from WSL/Linux | `scripts/build-windows.sh crates/app teams` |105
| Windows exe from WSL/Linux | `scripts/build-windows.sh crates/app teams` |104
| Tests | `cargo test` |106
| Tests (without linking the ~30 example binaries) | `cargo test --workspace --lib --bins --tests` |105
| Headless screenshot (Xvfb, xdotool, xclip, mesa-vulkan-drivers) | `cargo build -p app && scripts/headless-shot.sh shot.png -- "mousemove 450 740" "click 1" "type hello"` |107
| Headless screenshot (Xvfb, xdotool, xclip, mesa-vulkan-drivers) | `cargo build -p app && scripts/headless-shot.sh shot.png -- "mousemove 450 740" "click 1" "type hello"` |106
| Layout sweep before every UI deploy: 8 screens at 640x480 and 1920x1080, PNGs in `target/layout-sweep` (look at each) | `cargo build -p app && scripts/layout-sweep.sh` |108
| Layout sweep before every UI deploy: 8 screens at 640x480 and 1920x1080, PNGs in `target/layout-sweep` (look at each) | `cargo build -p app && scripts/layout-sweep.sh` |107
| Layout guard: no overlapping or clipped elements, no negative offsets outside `widgets::corner_badge` | `cargo test -p app layout_guard` |109
| Layout guard: no overlapping or clipped elements, no negative offsets outside `widgets::corner_badge` | `cargo test -p app layout_guard` |@@ -0,0 +1,91 @@
1
#!/usr/bin/env bash
2
# One Cargo target dir for every worktree, and a disk cap for it.
3
# Usage:
4
# scripts/build-cache.sh setup point ~/.cargo/config.toml at the shared target dir (once per machine)
5
# scripts/build-cache.sh status sizes: shared target dir, old per-worktree target dirs, kache
6
# scripts/build-cache.sh clean [--apply] remove old per-worktree target dirs and trim the shared one to the cap
7
# Without --apply, clean only prints what it would remove.
8
# Env: RUSTY_TEAMS_TARGET_CAP_GB (default 40), KACHE_MAX_SIZE for `kache gc` (default 15GiB).
9
set -euo pipefail
10
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
11
sharedTarget="${XDG_CACHE_HOME:-$HOME/.cache}/rusty-teams/target"
12
capKilobytes=$(( ${RUSTY_TEAMS_TARGET_CAP_GB:-40} * 1024 * 1024 ))
13
windowsRelease="$sharedTarget/x86_64-pc-windows-msvc/release"
14
15
sizeKilobytes() { du -sk "$1" 2>/dev/null | cut -f1 || echo 0; }
16
human() { du -sh "$1" 2>/dev/null | cut -f1; }
17
18
# Target dirs from before the shared one: one per worktree under ~/.cache, plus target/ and crates/app/target/ in each worktree.
19
legacyTargets() {
20
for directory in "${XDG_CACHE_HOME:-$HOME/.cache}"/cargo-target-*; do
21
if [ -d "$directory" ]; then echo "$directory"; fi
22
done
23
git -C "$repoRoot" worktree list --porcelain | sed -n 's/^worktree //p' | while read -r worktree; do
24
for directory in "$worktree/target" "$worktree/crates/app/target" "$worktree/tools/onnxruntime-dll/target" "$worktree"/spikes/*/target; do
25
if [ -d "$directory" ]; then echo "$directory"; fi
26
done
27
done
28
return 0
29
}
30
31
case "${1:-status}" in
32
setup)
33
config="$HOME/.cargo/config.toml"
34
mkdir -p "$(dirname "$config")" "$sharedTarget"
35
if grep -qs '^target-dir' "$config"; then
36
echo "$config already sets target-dir:"; grep '^target-dir' "$config"
37
elif grep -qs '^\[build\]' "$config"; then
38
sed -i "/^\[build\]/a target-dir = \"$sharedTarget\"" "$config"
39
else
40
printf '\n[build]\ntarget-dir = "%s"\n' "$sharedTarget" >> "$config"
41
fi
42
echo "shared target dir: $sharedTarget"
43
[ -z "${CARGO_TARGET_DIR:-}" ] || echo "CARGO_TARGET_DIR=$CARGO_TARGET_DIR is set and wins over the config; unset it (shell rc, worktree env)" >&2
44
exit 0
45
;;
46
status)
47
echo "shared target: $(human "$sharedTarget") $sharedTarget"
48
[ -d "$sharedTarget" ] && for directory in "$sharedTarget"/*/ "$sharedTarget"/x86_64-pc-windows-msvc/*/; do
49
[ -d "$directory" ] && echo " $(human "$directory") $directory"
50
done
51
echo "old per-worktree target dirs:"
52
legacyTargets | while read -r directory; do echo " $(human "$directory") $directory"; done
53
if command -v kache >/dev/null; then echo "kache:"; kache stats 2>/dev/null | sed 's/^/ /' || true; fi
54
exit 0
55
;;
56
clean) ;;
57
*) sed -n '2,9p' "$0"; exit 2 ;;
58
esac
59
60
apply=false
61
[ "${2:-}" = "--apply" ] && apply=true
62
remove() {
63
echo "remove $(human "$1") $1"
64
if $apply; then rm -rf "$1"; fi
65
}
66
67
legacyTargets | while read -r directory; do
68
[ "$(realpath "$directory")" = "$(realpath -m "$sharedTarget")" ] || remove "$directory"
69
done
70
71
# Over the cap: drop what rebuilds fastest first. Incremental caches, then the Linux debug build, then the Windows release
72
# dependencies. The Windows exe itself stays, so scripts/deploy-windows.sh still works after a clean.
73
if [ -d "$sharedTarget" ]; then
74
remainingKilobytes=$(sizeKilobytes "$sharedTarget")
75
for candidate in \
76
"$sharedTarget"/debug/incremental "$windowsRelease"/incremental "$sharedTarget"/release/incremental \
77
"$sharedTarget"/debug "$sharedTarget"/release "$sharedTarget"/x86_64-pc-windows-msvc/debug \
78
"$windowsRelease"/examples "$windowsRelease"/deps "$windowsRelease"/build; do
79
[ "$remainingKilobytes" -le "$capKilobytes" ] && break
80
[ -d "$candidate" ] || continue
81
remainingKilobytes=$(( remainingKilobytes - $(sizeKilobytes "$candidate") ))
82
remove "$candidate"
83
done
84
echo "shared target: $(human "$sharedTarget"), cap ${RUSTY_TEAMS_TARGET_CAP_GB:-40}G"
85
fi
86
87
if command -v kache >/dev/null; then
88
echo "kache gc down to ${KACHE_MAX_SIZE:-15GiB}"
89
if $apply; then KACHE_MAX_SIZE="${KACHE_MAX_SIZE:-15GiB}" kache gc; fi
90
fi
91
$apply || echo "dry run; add --apply to remove"
@@ -0,0 +1,91 @@1
#!/usr/bin/env bash2
# One Cargo target dir for every worktree, and a disk cap for it.3
# Usage:4
# scripts/build-cache.sh setup point ~/.cargo/config.toml at the shared target dir (once per machine)5
# scripts/build-cache.sh status sizes: shared target dir, old per-worktree target dirs, kache6
# scripts/build-cache.sh clean [--apply] remove old per-worktree target dirs and trim the shared one to the cap7
# Without --apply, clean only prints what it would remove.8
# Env: RUSTY_TEAMS_TARGET_CAP_GB (default 40), KACHE_MAX_SIZE for `kache gc` (default 15GiB).9
set -euo pipefail10
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"11
sharedTarget="${XDG_CACHE_HOME:-$HOME/.cache}/rusty-teams/target"12
capKilobytes=$(( ${RUSTY_TEAMS_TARGET_CAP_GB:-40} * 1024 * 1024 ))13
windowsRelease="$sharedTarget/x86_64-pc-windows-msvc/release"14
15
sizeKilobytes() { du -sk "$1" 2>/dev/null | cut -f1 || echo 0; }16
human() { du -sh "$1" 2>/dev/null | cut -f1; }17
18
# Target dirs from before the shared one: one per worktree under ~/.cache, plus target/ and crates/app/target/ in each worktree.19
legacyTargets() {20
for directory in "${XDG_CACHE_HOME:-$HOME/.cache}"/cargo-target-*; do21
if [ -d "$directory" ]; then echo "$directory"; fi22
done23
git -C "$repoRoot" worktree list --porcelain | sed -n 's/^worktree //p' | while read -r worktree; do24
for directory in "$worktree/target" "$worktree/crates/app/target" "$worktree/tools/onnxruntime-dll/target" "$worktree"/spikes/*/target; do25
if [ -d "$directory" ]; then echo "$directory"; fi26
done27
done28
return 029
}30
31
case "${1:-status}" in32
setup)33
config="$HOME/.cargo/config.toml"34
mkdir -p "$(dirname "$config")" "$sharedTarget"35
if grep -qs '^target-dir' "$config"; then36
echo "$config already sets target-dir:"; grep '^target-dir' "$config"37
elif grep -qs '^\[build\]' "$config"; then38
sed -i "/^\[build\]/a target-dir = \"$sharedTarget\"" "$config"39
else40
printf '\n[build]\ntarget-dir = "%s"\n' "$sharedTarget" >> "$config"41
fi42
echo "shared target dir: $sharedTarget"43
[ -z "${CARGO_TARGET_DIR:-}" ] || echo "CARGO_TARGET_DIR=$CARGO_TARGET_DIR is set and wins over the config; unset it (shell rc, worktree env)" >&244
exit 045
;;46
status)47
echo "shared target: $(human "$sharedTarget") $sharedTarget"48
[ -d "$sharedTarget" ] && for directory in "$sharedTarget"/*/ "$sharedTarget"/x86_64-pc-windows-msvc/*/; do49
[ -d "$directory" ] && echo " $(human "$directory") $directory"50
done51
echo "old per-worktree target dirs:"52
legacyTargets | while read -r directory; do echo " $(human "$directory") $directory"; done53
if command -v kache >/dev/null; then echo "kache:"; kache stats 2>/dev/null | sed 's/^/ /' || true; fi54
exit 055
;;56
clean) ;;57
*) sed -n '2,9p' "$0"; exit 2 ;;58
esac59
60
apply=false61
[ "${2:-}" = "--apply" ] && apply=true62
remove() {63
echo "remove $(human "$1") $1"64
if $apply; then rm -rf "$1"; fi65
}66
67
legacyTargets | while read -r directory; do68
[ "$(realpath "$directory")" = "$(realpath -m "$sharedTarget")" ] || remove "$directory"69
done70
71
# Over the cap: drop what rebuilds fastest first. Incremental caches, then the Linux debug build, then the Windows release72
# dependencies. The Windows exe itself stays, so scripts/deploy-windows.sh still works after a clean.73
if [ -d "$sharedTarget" ]; then74
remainingKilobytes=$(sizeKilobytes "$sharedTarget")75
for candidate in \76
"$sharedTarget"/debug/incremental "$windowsRelease"/incremental "$sharedTarget"/release/incremental \77
"$sharedTarget"/debug "$sharedTarget"/release "$sharedTarget"/x86_64-pc-windows-msvc/debug \78
"$windowsRelease"/examples "$windowsRelease"/deps "$windowsRelease"/build; do79
[ "$remainingKilobytes" -le "$capKilobytes" ] && break80
[ -d "$candidate" ] || continue81
remainingKilobytes=$(( remainingKilobytes - $(sizeKilobytes "$candidate") ))82
remove "$candidate"83
done84
echo "shared target: $(human "$sharedTarget"), cap ${RUSTY_TEAMS_TARGET_CAP_GB:-40}G"85
fi86
87
if command -v kache >/dev/null; then88
echo "kache gc down to ${KACHE_MAX_SIZE:-15GiB}"89
if $apply; then KACHE_MAX_SIZE="${KACHE_MAX_SIZE:-15GiB}" kache gc; fi90
fi91
$apply || echo "dry run; add --apply to remove"@@ -5,7 +5,8 @@ set -euo pipefail
5
5
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6
6
crateDir="$(realpath "${1:-$repoRoot/spikes/gpui-list}")"
7
7
binaryName="${2:-}"
8
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$crateDir/target}"
8
# One target dir for every worktree and crate (scripts/build-cache.sh): dependencies, libwebrtc and the patched gpui are built once.
9
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/rusty-teams/target}"
9
10
export PATH="$HOME/.cargo/bin:$PATH"
10
11
export XWIN_ACCEPT_LICENSE=1
11
12
export GPUI_FXC_PATH="$repoRoot/scripts/fxc-wsl.sh"
@@ -5,7 +5,8 @@ set -euo pipefail5
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"5
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"6
crateDir="$(realpath "${1:-$repoRoot/spikes/gpui-list}")"6
crateDir="$(realpath "${1:-$repoRoot/spikes/gpui-list}")"7
binaryName="${2:-}"7
binaryName="${2:-}"8
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$crateDir/target}"8
# One target dir for every worktree and crate (scripts/build-cache.sh): dependencies, libwebrtc and the patched gpui are built once.9
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/rusty-teams/target}"9
export PATH="$HOME/.cargo/bin:$PATH"10
export PATH="$HOME/.cargo/bin:$PATH"10
export XWIN_ACCEPT_LICENSE=111
export XWIN_ACCEPT_LICENSE=111
export GPUI_FXC_PATH="$repoRoot/scripts/fxc-wsl.sh"12
export GPUI_FXC_PATH="$repoRoot/scripts/fxc-wsl.sh"@@ -1,9 +1,8 @@
1
1
#!/usr/bin/env bash
2
2
# Publish the release exe to %LOCALAPPDATA%\Programs\ms-teams-linux\update\. The running app swaps itself.
3
# Usage: scripts/deploy-windows.sh [exe, default crates/app/target/x86_64-pc-windows-msvc/release/teams.exe]
3
# Usage: scripts/deploy-windows.sh [exe, default the teams.exe scripts/build-windows.sh wrote]
4
4
set -euo pipefail
5
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6
targetDirectory="${CARGO_TARGET_DIR:-$repoRoot/crates/app/target}"
5
targetDirectory="${CARGO_TARGET_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/rusty-teams/target}"
7
6
sourceExe="$(realpath "${1:-$targetDirectory/x86_64-pc-windows-msvc/release/teams.exe}")"
8
7
installRoot="${TEAMS_INSTALL_DIR:-}"
9
8
if [ -z "$installRoot" ]; then
@@ -1,9 +1,8 @@1
#!/usr/bin/env bash1
#!/usr/bin/env bash2
# Publish the release exe to %LOCALAPPDATA%\Programs\ms-teams-linux\update\. The running app swaps itself.2
# Publish the release exe to %LOCALAPPDATA%\Programs\ms-teams-linux\update\. The running app swaps itself.3
# Usage: scripts/deploy-windows.sh [exe, default crates/app/target/x86_64-pc-windows-msvc/release/teams.exe]3
# Usage: scripts/deploy-windows.sh [exe, default the teams.exe scripts/build-windows.sh wrote]4
set -euo pipefail4
set -euo pipefail5
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"5
targetDirectory="${CARGO_TARGET_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/rusty-teams/target}"6
targetDirectory="${CARGO_TARGET_DIR:-$repoRoot/crates/app/target}"7
sourceExe="$(realpath "${1:-$targetDirectory/x86_64-pc-windows-msvc/release/teams.exe}")"6
sourceExe="$(realpath "${1:-$targetDirectory/x86_64-pc-windows-msvc/release/teams.exe}")"8
installRoot="${TEAMS_INSTALL_DIR:-}"7
installRoot="${TEAMS_INSTALL_DIR:-}"9
if [ -z "$installRoot" ]; then8
if [ -z "$installRoot" ]; then@@ -1,5 +1,5 @@
1
1
#!/usr/bin/env bash
2
# Usage: scripts/headless-shot.sh OUT.png [--size 1280x800] [--window WxH] [--wait 10] [--settle 1] [--bin target/debug/teams] [--] [xdotool command]...
2
# Usage: scripts/headless-shot.sh OUT.png [--size 1280x800] [--window WxH] [--wait 10] [--settle 1] [--bin TARGET_DIR/debug/teams] [--] [xdotool command]...
3
3
# Runs the Linux build with --demo on a private Xvfb display and saves a screenshot.
4
4
# Example: scripts/headless-shot.sh shot.png -- "mousemove 450 740" "click 1" "type hello" "paste ```\\ncode\\n```"
5
5
# `type` cannot send a backtick (X11 treats it as a dead key and input stops); use `paste`, which expands \n.
@@ -11,7 +11,7 @@ size=1280x800
11
11
wait_seconds=10
12
12
window_size=
13
13
settle_seconds=1
14
binary=target/debug/teams
14
binary="$(cargo metadata --no-deps --format-version 1 | python3 -c 'import json,sys; print(json.load(sys.stdin)["target_directory"])')/debug/teams"
15
15
while [[ $# -gt 0 ]]; do
16
16
case $1 in
17
17
--size) size=$2; shift 2 ;;
@@ -1,5 +1,5 @@1
#!/usr/bin/env bash1
#!/usr/bin/env bash2
# Usage: scripts/headless-shot.sh OUT.png [--size 1280x800] [--window WxH] [--wait 10] [--settle 1] [--bin target/debug/teams] [--] [xdotool command]...2
# Usage: scripts/headless-shot.sh OUT.png [--size 1280x800] [--window WxH] [--wait 10] [--settle 1] [--bin TARGET_DIR/debug/teams] [--] [xdotool command]...3
# Runs the Linux build with --demo on a private Xvfb display and saves a screenshot.3
# Runs the Linux build with --demo on a private Xvfb display and saves a screenshot.4
# Example: scripts/headless-shot.sh shot.png -- "mousemove 450 740" "click 1" "type hello" "paste ```\\ncode\\n```"4
# Example: scripts/headless-shot.sh shot.png -- "mousemove 450 740" "click 1" "type hello" "paste ```\\ncode\\n```"5
# `type` cannot send a backtick (X11 treats it as a dead key and input stops); use `paste`, which expands \n.5
# `type` cannot send a backtick (X11 treats it as a dead key and input stops); use `paste`, which expands \n.@@ -11,7 +11,7 @@ size=1280x80011
wait_seconds=1011
wait_seconds=1012
window_size=12
window_size=13
settle_seconds=113
settle_seconds=114
binary=target/debug/teams14
binary="$(cargo metadata --no-deps --format-version 1 | python3 -c 'import json,sys; print(json.load(sys.stdin)["target_directory"])')/debug/teams"15
while [[ $# -gt 0 ]]; do15
while [[ $# -gt 0 ]]; do16
case $1 in16
case $1 in17
--size) size=$2; shift 2 ;;17
--size) size=$2; shift 2 ;;