build: package haul.exe with an embedded icon

A plain `go build` links no icon resource, so Explorer and the Start menu
draw the generic executable glyph. Inno's SetupIconFile only skins
setup.exe, so the fix has to happen at build time: `fyne package` turns
cmd/haul/Icon.png into a .syso and links it in, and adds -H=windowsgui
itself.

Documents the installer build alongside it, since the two steps are only
useful together.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-01 08:17:26 +10:00
parent e845f63d9e
commit 9ddc152103
2 changed files with 77 additions and 3 deletions
+22 -2
View File
@@ -12,7 +12,7 @@ GO ?= $(shell test -x $(HOME)/.local/go/bin/go && echo $(HOME)/.local/go/bin/go
# FYNE=/path/to/fyne if you'd rather use an installed copy.
FYNE ?= $(GO) run fyne.io/tools/cmd/fyne@v1.7.2
.PHONY: build install test vet check run run-xvfb dist package-darwin clean
.PHONY: build install test vet check run run-xvfb dist package-darwin package-windows clean
build: ## Build a native binary into ./bin/haul
$(GO) build -trimpath -ldflags "$(LDFLAGS)" -o bin/haul ./cmd/haul
@@ -80,5 +80,25 @@ package-darwin: ## Package haul.app for macOS (run this on a Mac)
$(FYNE) package --target darwin --src ./cmd/haul --release
@echo "built ./haul.app — drag it into /Applications"
# A plain `go build` produces a haul.exe with no icon resource, so Explorer, the
# taskbar and the Start menu all draw the generic executable icon. Nothing in
# the installer can fix that — Inno's SetupIconFile only skins setup.exe itself.
# `fyne package` generates a .syso from cmd/haul/Icon.png (it converts the PNG
# itself; cmd/haul/Icon.ico is for Inno, not for this) and links it in, so the
# icon travels with the binary. It also adds -H=windowsgui on its own, so this
# needs none of the manual linker flags the README's build command does.
#
# Run this ON Windows, from the MSYS2 UCRT64 shell if you installed make there:
# haul is cgo, so it needs the host MinGW-w64 toolchain. Like package-darwin it
# rewrites cmd/haul/FyneApp.toml in place, bumping Build.
#
# fyne writes the binary beside the source, as cmd/haul/haul.exe. Move it into
# bin/, which is where Inno-compile.iss looks for it.
package-windows: ## Package haul.exe with an embedded icon (run this on Windows)
$(FYNE) package --target windows --src ./cmd/haul --release
@mkdir -p bin
mv ./cmd/haul/haul.exe ./bin/haul.exe
@echo "built ./bin/haul.exe — compile Inno-compile.iss to wrap it in an installer"
clean: ## Remove build artifacts
rm -rf bin dist haul.app
rm -rf bin dist haul.app Output
+55 -1
View File
@@ -250,6 +250,59 @@ xattr -dr com.apple.quarantine /Applications/haul.app
Signing and notarising properly needs a paid Apple Developer ID, after which
`fyne release --target darwin --certificate <name>` handles it.
### Packaging on Windows
The `go build` command [above](#building-on-windows) produces a working
`haul.exe`, but one with **no icon** — Explorer, the taskbar and the Start menu
all draw the generic executable glyph. A Windows binary carries its icon as a
linked resource, and the Go compiler has nothing to link unless you give it a
`.syso`. `fyne package` builds one:
```powershell
go run fyne.io/tools/cmd/fyne@v1.7.2 package --target windows --src .\cmd\haul --release
Move-Item .\cmd\haul\haul.exe .\bin\haul.exe
```
Or, from the MSYS2 shell with `make` installed, `make package-windows`.
That converts `cmd/haul/Icon.png` to an icon resource, links it in, and adds
`-H=windowsgui` itself — so unlike the manual build you don't pass any linker
flags. It writes the binary *beside the source* as `cmd\haul\haul.exe`, hence
the move: `Inno-compile.iss` expects it in `bin\`. As on macOS, `fyne package`
rewrites `cmd/haul/FyneApp.toml` in place and bumps `Build`.
#### The installer
`Inno-compile.iss` wraps that binary in a setup program. Install [Inno
Setup](https://jrsoftware.org/isdl.php) (`winget install JRSoftware.InnoSetup`),
then from the repo root:
```powershell
iscc Inno-compile.iss
```
That writes `Output\haul-0.1.0-setup-x64.exe`. Every `Source:` path in the
script is relative to the script itself, so it compiles from any clone — but it
packages whatever is in `bin\` at that moment, and does not build anything
itself. Run the packaging step above first.
It installs per-user into `%LOCALAPPDATA%\Programs\Haul`, so it needs no
administrator rights and prompts for no UAC elevation.
The wizard offers two install types. **Standard** installs `haul.exe` alone.
**Remote Desktop / virtual machine** adds every DLL from `bin\` as the optional
`mesa` component — the software OpenGL renderer described
[below](#running-over-remote-desktop-or-in-a-vm). That split is deliberate and
worth keeping: those DLLs override the system OpenGL for anything in the same
folder, so installing them by default would force software rendering on machines
with a perfectly good GPU. Populate `bin\` with the Mesa DLLs only when you
intend to build an installer that offers them.
Note that `cmd\haul\Icon.ico` is used by Inno for `setup.exe`'s own icon. The
icon inside `haul.exe` comes from `Icon.png` via `fyne package` — the two are
separate, and dropping the packaging step leaves you with a nicely-iconed
installer that installs an icon-less application.
### Running over Remote Desktop (or in a VM)
A build that compiles perfectly will still fail to start in an RDP session with:
@@ -315,7 +368,8 @@ Software rendering is slower than a GPU, but haul draws two tables and some text
| `make run-xvfb` | Build, then run against a virtual X display |
| `make dist` | Release binary into `./dist` |
| `make package-darwin` | macOS `.app` bundle into `./haul.app` (run on a Mac) |
| `make clean` | Remove `bin/`, `dist/` and `haul.app/` |
| `make package-windows` | `bin/haul.exe` with an embedded icon (run on Windows) |
| `make clean` | Remove `bin/`, `dist/`, `haul.app/` and `Output/` |
The Makefile picks up a Go toolchain at `~/.local/go/bin/go` if one is there,
falling back to whatever `go` is on `PATH` — so it works on machines where Go