@@ -13,14 +13,32 @@ GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
1313BUILD_DATE := $(shell date -u +"% Y-% m-% dT% H:% M:% SZ")
1414LDFLAGS := -X main.version=$(BUILD_VERSION ) -X main.commit=$(GIT_COMMIT ) -X main.date=$(BUILD_DATE )
1515
16- .PHONY : all build clean deps run app-bundle install install-darwin install-unix install-windows test release
17-
18- test :
19- go test -race ./...
16+ .PHONY : all build build-all build-darwin build-linux build-windows clean deps run app-bundle app-bundle-universal install install-darwin install-unix install-windows test release help
2017
2118# Default target
2219all : build
2320
21+ # Show available make targets
22+ help :
23+ @echo " Available targets:"
24+ @echo " make build - Build for current platform"
25+ @echo " make build-all - Build for all platforms"
26+ @echo " make build-darwin - Build for macOS (amd64 and arm64)"
27+ @echo " make build-linux - Build for Linux (amd64 and arm64)"
28+ @echo " make build-windows - Build for Windows (amd64 and arm64)"
29+ @echo " make app-bundle - Create macOS .app bundle (native arch)"
30+ @echo " make app-bundle-universal - Create macOS .app bundle (universal)"
31+ @echo " make install - Install application for current platform"
32+ @echo " make test - Run tests with race detector"
33+ @echo " make lint - Run linters"
34+ @echo " make fix - Run auto-fixers"
35+ @echo " make clean - Remove build artifacts"
36+ @echo " make release VERSION=vX.Y.Z - Create and push a new release tag"
37+
38+ test :
39+ @echo " Running tests with race detector..."
40+ @go test -race ./...
41+
2442# Install dependencies
2543deps :
2644 go mod download
@@ -39,95 +57,99 @@ endif
3957# Build for current platform
4058build : out
4159ifeq ($(OS ) ,Windows_NT)
42- CGO_ENABLED=1 go build -ldflags "-H=windowsgui $(LDFLAGS)" -o out/$(APP_NAME).exe ./cmd/review-goose
60+ @echo "Building $(APP_NAME) for Windows..."
61+ @CGO_ENABLED=1 go build -ldflags "-H=windowsgui $(LDFLAGS)" -o out/$(APP_NAME).exe ./cmd/review-goose
62+ @echo "✓ Created: out/$(APP_NAME).exe"
4363else
44- CGO_ENABLED=1 go build -ldflags "$(LDFLAGS)" -o out/$(APP_NAME) ./cmd/review-goose
64+ @echo "Building $(APP_NAME) for $(shell uname -s)/$(shell uname -m)..."
65+ @CGO_ENABLED=1 go build -ldflags "$(LDFLAGS)" -o out/$(APP_NAME) ./cmd/review-goose
66+ @echo "✓ Created: out/$(APP_NAME)"
4567endif
4668
4769# Build for all platforms
4870build-all : build-darwin build-linux build-windows
4971
50- # Build for macOS
51- build-darwin :
52- CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o out/$(APP_NAME ) -darwin-amd64 ./cmd/review-goose
53- CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags " $( LDFLAGS) " -o out/$(APP_NAME ) -darwin-arm64 ./cmd/review-goose
54-
55- # Build for Linux
56- build-linux :
57- CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o out/$(APP_NAME ) -linux-amd64 ./cmd/review-goose
58- CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags " $( LDFLAGS) " -o out/$(APP_NAME ) -linux-arm64 ./cmd/review-goose
59-
60- # Build for Windows
61- build-windows :
62- CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags " -H=windowsgui $( LDFLAGS) " -o out/$(APP_NAME ) -windows-amd64.exe ./cmd/review-goose
63- CGO_ENABLED=1 GOOS=windows GOARCH=arm64 go build -ldflags " -H=windowsgui $( LDFLAGS) " -o out/$(APP_NAME ) -windows-arm64.exe ./cmd/review-goose
72+ # Build for macOS (both architectures)
73+ build-darwin : out
74+ @echo " Building $( APP_NAME) for darwin/amd64..."
75+ @CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o out/$(APP_NAME ) -darwin-amd64 ./cmd/review-goose
76+ @echo " ✓ Created: out/$( APP_NAME) -darwin-amd64"
77+ @echo " Building $( APP_NAME) for darwin/arm64..."
78+ @CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -ldflags " $( LDFLAGS) " -o out/$(APP_NAME ) -darwin-arm64 ./cmd/review-goose
79+ @echo " ✓ Created: out/$( APP_NAME) -darwin-arm64"
80+
81+ # Build for Linux (both architectures)
82+ # Note: CGO cross-compilation requires appropriate cross-compiler toolchain
83+ build-linux : out
84+ @echo " Building $( APP_NAME) for linux/amd64..."
85+ @CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags " $( LDFLAGS) " -o out/$(APP_NAME ) -linux-amd64 ./cmd/review-goose
86+ @echo " ✓ Created: out/$( APP_NAME) -linux-amd64"
87+ @echo " Building $( APP_NAME) for linux/arm64..."
88+ @CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags " $( LDFLAGS) " -o out/$(APP_NAME ) -linux-arm64 ./cmd/review-goose
89+ @echo " ✓ Created: out/$( APP_NAME) -linux-arm64"
90+
91+ # Build for Windows (both architectures)
92+ # Note: CGO cross-compilation requires appropriate cross-compiler toolchain
93+ build-windows : out
94+ @echo " Building $( APP_NAME) for windows/amd64..."
95+ @CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags " -H=windowsgui $( LDFLAGS) " -o out/$(APP_NAME ) -windows-amd64.exe ./cmd/review-goose
96+ @echo " ✓ Created: out/$( APP_NAME) -windows-amd64.exe"
97+ @echo " Building $( APP_NAME) for windows/arm64..."
98+ @CGO_ENABLED=1 GOOS=windows GOARCH=arm64 go build -ldflags " -H=windowsgui $( LDFLAGS) " -o out/$(APP_NAME ) -windows-arm64.exe ./cmd/review-goose
99+ @echo " ✓ Created: out/$( APP_NAME) -windows-arm64.exe"
64100
65101# Clean build artifacts
66102clean :
67- rm -rf out/
103+ @echo " Cleaning build artifacts..."
104+ @rm -rf out/
68105
69106# Create out directory
70107out :
71- mkdir -p out
72-
73- # Install appify if not already installed
74- install-appify :
75- @if ! command -v appify & > /dev/null; then \
76- echo " Installing appify..." ; \
77- go install github.com/machinebox/appify@latest; \
78- else \
79- echo " appify is already installed" ; \
80- fi
81-
82- # Build macOS application bundle using appify
83- app-bundle : out build-darwin install-appify
108+ @mkdir -p out
109+
110+ # Install appify to out/tools directory (pinned version)
111+ APPIFY_COMMIT := 15c1e09ce9247bfd78610ac4831dd0a3cb02483c
112+ APPIFY_BIN := out/tools/appify-$(APPIFY_COMMIT )
113+ $(APPIFY_BIN ) :
114+ @echo " Installing appify ($( APPIFY_COMMIT) )..."
115+ @mkdir -p out/tools
116+ @GOBIN=$(shell pwd) /out/tools go install github.com/machinebox/appify@$(APPIFY_COMMIT ) 2>&1 | grep -v " go: finding\|go: downloading\|go: found" || true
117+ @mv out/tools/appify $@
118+
119+ install-appify : $(APPIFY_BIN )
120+
121+ # Internal helper to create app bundle from a binary
122+ # Usage: make _create-app-bundle BUNDLE_BINARY=review-goose
123+ define create-app-bundle
84124 @echo "Removing old app bundle..."
85125 @rm -rf "out/$(BUNDLE_NAME ) .app"
86126
87127 @echo "Creating macOS application bundle with appify..."
88-
89- # Create universal binary
90- @echo "Creating universal binary..."
91- lipo -create out/$(APP_NAME)-darwin-amd64 out/$(APP_NAME)-darwin-arm64 \
92- -output out/$(APP_NAME)-universal
93-
94- # Copy logo to out directory
95- cp media/logo.png out/logo.png
96-
97- # Create menubar icon (small version with transparency)
128+ @cp media/logo.png out/logo.png
98129 @echo "Creating menubar icon..."
99- sips -z 44 44 media/logo.png --out out/menubar-icon.png
100- # Ensure the icon has an alpha channel
101- sips -s format png out/menubar-icon.png --out out/menubar-icon.png
130+ @sips -z 44 44 media/logo.png --out out/menubar-icon.png >/dev/null 2>&1
131+ @sips -s format png out/menubar-icon.png --out out/menubar-icon.png >/dev/null 2>&1
102132
103- # Create app bundle with appify using universal binary
104- cd out && appify -name "$(BUNDLE_NAME)" \
133+ cd out && ../$(APPIFY_BIN ) -name "$(BUNDLE_NAME ) " \
105134 -icon logo.png \
106135 -id "$(BUNDLE_ID ) " \
107- $(APP_NAME)-universal
136+ $(1 )
108137
109- # Move the generated app to the expected location
110- @if [ -f "out/$(BUNDLE_NAME)-universal.app" ]; then \
111- mv "out/$(BUNDLE_NAME)-universal.app" "out/$(BUNDLE_NAME).app"; \
138+ @if [ -f "out/$(BUNDLE_NAME ) -$(1 ) .app" ]; then \
139+ mv "out/$(BUNDLE_NAME ) -$(1 ) .app" "out/$(BUNDLE_NAME ) .app"; \
112140 elif [ ! -d "out/$(BUNDLE_NAME ) .app" ]; then \
113141 echo "Warning: App bundle not found in expected location"; \
114142 fi
115143
116- # Copy menubar icon to Resources
117144 @echo "Copying menubar icon to app bundle..."
118- cp out/menubar-icon.png "out/$(BUNDLE_NAME).app/Contents/Resources/menubar-icon.png"
119-
120- # Create English localization
121- @echo "Creating English localization..."
122- mkdir -p "out/$(BUNDLE_NAME).app/Contents/Resources/en.lproj"
145+ @cp out/menubar-icon.png "out/$(BUNDLE_NAME ) .app/Contents/Resources/menubar-icon.png"
146+ @mkdir -p "out/$(BUNDLE_NAME ) .app/Contents/Resources/en.lproj"
123147
124- # Fix the executable name (appify adds .app suffix which we don't want)
125148 @echo "Fixing executable name..."
126149 @if [ -f "out/$(BUNDLE_NAME ) .app/Contents/MacOS/$(BUNDLE_NAME ) .app" ]; then \
127150 mv "out/$(BUNDLE_NAME ) .app/Contents/MacOS/$(BUNDLE_NAME ) .app" "out/$(BUNDLE_NAME ) .app/Contents/MacOS/$(BUNDLE_NAME ) "; \
128151 fi
129152
130- # Fix the Info.plist
131153 @echo "Fixing Info.plist..."
132154 @/usr/libexec/PlistBuddy -c "Set :CFBundleExecutable Review\\ Goose" "out/$(BUNDLE_NAME ) .app/Contents/Info.plist"
133155 @/usr/libexec/PlistBuddy -c "Add :LSUIElement bool true" "out/$(BUNDLE_NAME ) .app/Contents/Info.plist" 2>/dev/null || \
@@ -143,14 +165,23 @@ app-bundle: out build-darwin install-appify
143165 @/usr/libexec/PlistBuddy -c "Add :CFBundleGetInfoString string 'Review Goose $(BUILD_VERSION ) '" "out/$(BUNDLE_NAME ) .app/Contents/Info.plist" 2>/dev/null || \
144166 /usr/libexec/PlistBuddy -c "Set :CFBundleGetInfoString 'Review Goose $(BUILD_VERSION ) '" "out/$(BUNDLE_NAME ) .app/Contents/Info.plist"
145167
146- # Remove extended attributes and code sign the app bundle
147- @echo "Preparing app bundle for signing..."
148- xattr -cr "out/$(BUNDLE_NAME).app"
149-
150168 @echo "Code signing the app bundle..."
151- codesign --force --deep --sign - --options runtime "out/$(BUNDLE_NAME).app"
169+ @xattr -cr "out/$(BUNDLE_NAME ) .app"
170+ @codesign --force --deep --sign - --options runtime "out/$(BUNDLE_NAME ) .app" >/dev/null 2>&1
171+
172+ @echo "✓ macOS app bundle created: out/$(BUNDLE_NAME ) .app"
173+ endef
174+
175+ # Build macOS application bundle using appify (native architecture only)
176+ app-bundle : out build install-appify
177+ $(call create-app-bundle,$(APP_NAME ) )
152178
153- @echo "macOS app bundle created: out/$(BUNDLE_NAME).app"
179+ # Build macOS universal application bundle (both arm64 and amd64)
180+ app-bundle-universal : out build-darwin install-appify
181+ @echo " Creating universal binary..."
182+ @lipo -create out/$(APP_NAME ) -darwin-amd64 out/$(APP_NAME ) -darwin-arm64 \
183+ -output out/$(APP_NAME ) -universal
184+ $(call create-app-bundle,$(APP_NAME ) -universal)
154185
155186# Install the application (detects OS automatically)
156187install :
@@ -283,9 +314,9 @@ release:
283314 echo " Error: Tag $( VERSION) already exists" ; \
284315 exit 1; \
285316 fi
286- @echo " Running tests..."
317+ @echo " → Running tests..."
287318 @$(MAKE ) test
288- @echo " Running linters..."
319+ @echo " → Running linters..."
289320 @$(MAKE ) lint
290321 @echo " Creating VERSION file..."
291322 @echo " $( VERSION) " > cmd/review-goose/VERSION
0 commit comments