summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.md20
-rw-r--r--HOWTO.md16
-rwxr-xr-xscripts/analyze_win_bloat.sh18
-rwxr-xr-xscripts/crunch_win.sh36
4 files changed, 80 insertions, 10 deletions
diff --git a/BUILD.md b/BUILD.md
index d8501dc..3a581b1 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -7,3 +7,23 @@ cmake --build build
Size-optimized build:
cmake -S . -B build -DDEMO_SIZE_OPT=ON
cmake --build build
+
+## Windows Cross-Compilation (from macOS)
+
+Requires `mingw-w64` and `wine-stable` (for testing).
+
+1. Fetch Windows binaries:
+ ```bash
+ ./scripts/fetch_win_deps.sh
+ ```
+
+2. Build for Windows:
+ ```bash
+ ./scripts/build_win.sh
+ ```
+ This will produce `build_win/demo64k_packed.exe`.
+
+3. Run with Wine:
+ ```bash
+ ./scripts/run_win.sh
+ ```
diff --git a/HOWTO.md b/HOWTO.md
index 8efbf59..1a3ec6d 100644
--- a/HOWTO.md
+++ b/HOWTO.md
@@ -40,18 +40,14 @@ cmake --build build
```
In this mode, the demo will always start in fullscreen.
-### Packed Build (Binary Crunching)
+### Windows (Wine)
-To build the stripped binary and compress it, run the `final` target:
+If you are on macOS and want to test the Windows build:
-```bash
-cmake --build build --target final
-```
-Alternatively, you can run the script directly:
-```bash
-./scripts/crunch_demo.sh
-```
-This requires `gzexe` (macOS) or `UPX` (Linux/Windows) to be installed.
+1. Build it: `./scripts/build_win.sh`
+2. Run it: `./scripts/run_win.sh`
+
+Note: WebGPU support in Wine requires a Vulkan-capable backend (like MoltenVK on macOS).
## Testing
diff --git a/scripts/analyze_win_bloat.sh b/scripts/analyze_win_bloat.sh
new file mode 100755
index 0000000..6710558
--- /dev/null
+++ b/scripts/analyze_win_bloat.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -e
+
+EXE="build_win/demo64k.exe"
+
+if [ ! -f "$EXE" ]; then
+ echo "Error: $EXE not found. Run scripts/build_win.sh first."
+ exit 1
+fi
+
+echo "Analyzing $EXE..."
+echo "------------------------------------------------"
+echo "Sections:"
+x86_64-w64-mingw32-objdump -h "$EXE"
+echo "------------------------------------------------"
+echo "Top 20 Symbols by Size:"
+x86_64-w64-mingw32-nm --print-size --size-sort --radix=d "$EXE" | tail -n 20
+echo "------------------------------------------------"
diff --git a/scripts/crunch_win.sh b/scripts/crunch_win.sh
new file mode 100755
index 0000000..59d7889
--- /dev/null
+++ b/scripts/crunch_win.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+set -e
+
+INPUT_EXE="build_win/demo64k.exe"
+STRIPPED_EXE="build_win/demo64k_stripped.exe"
+PACKED_EXE="build_win/demo64k_packed.exe"
+
+if [ ! -f "$INPUT_EXE" ]; then
+ echo "Error: $INPUT_EXE not found. Run scripts/build_win.sh first."
+ exit 1
+fi
+
+echo "Crunching $INPUT_EXE..."
+
+# 1. Strip debug symbols and sections
+cp "$INPUT_EXE" "$STRIPPED_EXE"
+x86_64-w64-mingw32-strip -s "$STRIPPED_EXE"
+x86_64-w64-mingw32-strip --strip-unneeded "$STRIPPED_EXE"
+x86_64-w64-mingw32-strip -R .comment -R .gnu.version "$STRIPPED_EXE"
+
+# 2. Pack with UPX
+# --best: max compression
+# --lzma: use lzma algorithm (usually smallest)
+# --filter=...: filters for x86 code
+cp "$STRIPPED_EXE" "$PACKED_EXE"
+upx --best --lzma --overlay=strip "$PACKED_EXE"
+
+echo "------------------------------------------------"
+echo "Size Report:"
+ls -lh "$INPUT_EXE"
+ls -lh "$STRIPPED_EXE"
+ls -lh "$PACKED_EXE"
+echo "------------------------------------------------"
+echo "Top 10 Largest Symbols (from unstripped):"
+x86_64-w64-mingw32-nm --print-size --size-sort --radix=d "$INPUT_EXE" | tail -n 10
+echo "------------------------------------------------"