From 5722d68a3e529fb22886c2430dc0d268c33424e7 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 28 Jan 2026 02:17:04 +0100 Subject: feat(crunch): Add UPX-based binary packer script Adds 'scripts/crunch_demo.sh' to automate building a stripped binary and compressing it with UPX. Updates 'FETCH_DEPS.md' with UPX installation instructions and 'HOWTO.md' with usage guide. This addresses Task 3 (add binary crunchers). --- FETCH_DEPS.md | 14 ++++++++++++++ HOWTO.md | 9 +++++++++ scripts/crunch_demo.sh | 23 +++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100755 scripts/crunch_demo.sh diff --git a/FETCH_DEPS.md b/FETCH_DEPS.md index 24cbf08..c8f315f 100644 --- a/FETCH_DEPS.md +++ b/FETCH_DEPS.md @@ -56,3 +56,17 @@ Use one of the provided scripts: - scripts/project_init.bat These scripts will download `glfw3webgpu.h` and `glfw3webgpu.c` into `third_party/glfw3webgpu`. + +## UPX + +Executable packer for binary compression. + +### Installation + +**macOS:** +```bash +brew install upx +``` + +**Other platforms:** +Download the appropriate release from https://github.com/upx/upx/releases and ensure the `upx` executable is in your PATH. diff --git a/HOWTO.md b/HOWTO.md index 60a29fa..5716524 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -40,6 +40,15 @@ cmake --build build ``` In this mode, the demo will always start in fullscreen. +### Packed Build (Binary Crunching) + +To build the stripped binary and compress it using `UPX`, run the provided script: + +```bash +./scripts/crunch_demo.sh +``` +This requires `UPX` to be installed. + ## Testing **Commit Policy**: Always run tests before committing. Refer to `CONTRIBUTING.md` for details. diff --git a/scripts/crunch_demo.sh b/scripts/crunch_demo.sh new file mode 100755 index 0000000..333faa9 --- /dev/null +++ b/scripts/crunch_demo.sh @@ -0,0 +1,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" -- cgit v1.2.3