a8a60f5860
Double-clicking the bare binary in Finder opens a Terminal window alongside the app: Finder has no better idea what to do with a Mach-O executable than hand it to Terminal.app, and the terminal stays up as long as the process does. macOS has no counterpart to -H=windowsgui, so the only fix is to ship an application bundle, which Finder launches directly. Add `make package-darwin`, which runs a pinned `fyne package --target darwin` to produce ./haul.app. Its metadata comes from cmd/haul/FyneApp.toml — the app ID there must stay in step with the one app.NewWithID uses, or macOS treats the bundle and the running app as separate applications. The icon is a placeholder; `fyne package` will not run without one. Note that `fyne package` rewrites FyneApp.toml in place on every run, so the file is left in that tool's canonical formatting rather than a commented version it would only strip again. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
85 lines
3.8 KiB
Makefile
85 lines
3.8 KiB
Makefile
VERSION ?= 0.1.0
|
|
# No -X main.version here: cmd/haul has no version var yet, and a -X against a
|
|
# symbol that doesn't exist is silently a no-op rather than an error.
|
|
LDFLAGS := -s -w
|
|
|
|
# Go is installed at ~/.local/go on this box and deliberately kept off PATH, so
|
|
# prefer that toolchain and fall back to whatever `go` is in PATH elsewhere.
|
|
GO ?= $(shell test -x $(HOME)/.local/go/bin/go && echo $(HOME)/.local/go/bin/go || echo go)
|
|
|
|
# The packaging tool lives outside the Fyne library repo since v2.5. Pinned and
|
|
# run through `go run` so no separate install step is needed; override with
|
|
# 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
|
|
|
|
build: ## Build a native binary into ./bin/haul
|
|
$(GO) build -trimpath -ldflags "$(LDFLAGS)" -o bin/haul ./cmd/haul
|
|
|
|
install: ## Install haul into $GOBIN / $GOPATH/bin
|
|
$(GO) install -trimpath -ldflags "$(LDFLAGS)" ./cmd/haul
|
|
|
|
test: ## Run tests
|
|
$(GO) test ./...
|
|
|
|
vet: ## Run go vet
|
|
$(GO) vet ./...
|
|
|
|
# GOOS=js typechecks every package, Fyne API usage included, without needing the
|
|
# cgo/X11 toolchain. It proves nothing about layout or runtime behaviour.
|
|
check: ## Typecheck the whole tree without cgo
|
|
GOOS=js GOARCH=wasm $(GO) build ./...
|
|
|
|
run: build ## Build and run (needs a DISPLAY)
|
|
./bin/haul
|
|
|
|
# This box is headless. Xvfb gives haul a display to render into; software GL
|
|
# because there's no GPU.
|
|
#
|
|
# Cleanup is a trap on a PID held in a shell variable, never a pidfile and never
|
|
# pkill. A pidfile survives Ctrl-C and goes stale, and PIDs get recycled, so a
|
|
# later `kill $(cat .xvfb.pid)` can hit an unrelated process. `pkill -f Xvfb` is
|
|
# worse still: the pattern also matches make's own command line, and this box
|
|
# runs inside tmux, where a stray match can take out the session.
|
|
run-xvfb: build ## Build and run against a virtual X display
|
|
@if [ -e /tmp/.X99-lock ]; then \
|
|
echo "display :99 is already in use — close that first"; exit 1; \
|
|
fi; \
|
|
Xvfb :99 -screen 0 1500x900x24 >/dev/null 2>&1 & \
|
|
xvfb_pid=$$!; \
|
|
trap 'kill $$xvfb_pid 2>/dev/null || true' INT TERM EXIT; \
|
|
sleep 1; \
|
|
DISPLAY=:99 LIBGL_ALWAYS_SOFTWARE=1 ./bin/haul || true
|
|
|
|
# haul is cgo (Fyne needs OpenGL + X11), so `GOOS=windows go build` does NOT
|
|
# work the way it does for dial. Cross-targets need a matching C toolchain:
|
|
# linux/arm64 -> apt install gcc-aarch64-linux-gnu
|
|
# windows/amd64-> apt install gcc-mingw-w64
|
|
# darwin/* -> a Mac, or osxcross
|
|
# Docker is present, so `fyne-cross` is the practical route for the others:
|
|
# go install github.com/fyne-io/fyne-cross@latest
|
|
# fyne-cross windows -arch=amd64
|
|
dist: ## Build the release binary for this host into ./dist
|
|
@mkdir -p dist
|
|
$(GO) build -trimpath -ldflags "$(LDFLAGS)" -o dist/haul-linux-amd64 ./cmd/haul
|
|
@echo "built dist/haul-linux-amd64 (see the Makefile for cross-compiling)"
|
|
|
|
# Finder hands a bare Unix executable to Terminal.app, so double-clicking the
|
|
# raw binary opens a terminal window alongside the GUI. Nothing in the code can
|
|
# stop that — the fix is to ship a .app bundle instead, which Finder launches
|
|
# directly. `fyne package` writes the Info.plist (CFBundlePackageType APPL and
|
|
# friends) and converts cmd/haul/Icon.png into Contents/Resources/icon.icns; the
|
|
# rest of the metadata comes from cmd/haul/FyneApp.toml.
|
|
#
|
|
# Run this ON a Mac: it compiles the binary with the host cgo toolchain, and it
|
|
# builds for the host architecture, so an Intel Mac gives an amd64 bundle and
|
|
# Apple silicon an arm64 one. The .app is unsigned, so first launch needs
|
|
# right-click -> Open (or `xattr -dr com.apple.quarantine haul.app`).
|
|
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"
|
|
|
|
clean: ## Remove build artifacts
|
|
rm -rf bin dist haul.app
|