summaryrefslogtreecommitdiff
path: root/scripts/crunch_demo.sh
blob: 333faa953ddefbc0017cc594c3571dcfc77e526c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# Build a size-optimized binary and compress it with UPX.

set -e

if ! command -v upx >/dev/null 2>&1; then
    echo "Error: upx is not installed or not in PATH."
    echo "Please install it using 'brew install upx' or from https://github.com/upx/upx"
    exit 1
fi

echo "Building stripped binary..."
cmake -S . -B build_strip -DDEMO_STRIP_ALL=ON
cmake --build build_strip

SRC_BIN="build_strip/demo64k"
OUT_BIN="build_strip/demo64k_packed"

echo "Compressing with UPX..."
upx --best --lzma -o "$OUT_BIN" "$SRC_BIN"

echo "Done."
ls -lh "$SRC_BIN" "$OUT_BIN"