Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
201 lines (180 loc) · 8.87 KB
/
Copy pathMakefile
File metadata and controls
201 lines (180 loc) · 8.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# App Studio — every command for running the app and releasing it. The
# Makefile is the whole interface: no release step should require running a
# tool/ script by hand.
#
# Run locally:
# make start Run the app (flutter run -d macos)
# make deps flutter pub get + CEF/pods
# make widgetbook Every screen and dialog, in every state (Widgetbook)
# make start_driver The app, drivable by an agent through the Dart MCP server
# make widgetbook_driver Widgetbook, drivable the same way
# make clean Drop build output and dist artifacts
# make clean_all Also drop CEF and Pods
#
# Release the app (two steps, so a build can be tested before it goes live):
# make release V=1.2.3 Set the version, build, notarize, upload — the build
# is downloadable and testable, existing installs
# are NOT updated yet
# make promote Put the uploaded build in the appcast: auto-update
# goes live for every existing install
#
# make set_version V=… Set the version and bump both build counters
# make build Signed + notarized zip in dist/, nothing uploaded
# make publish Upload the built zip + refresh downloads/macos.json
# make build_debug Unsigned zip, local only
#
.DEFAULT_GOAL := help
# Recipes use [[ ]] and read -p.
SHELL := /bin/bash
ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
CEF_STAMP := $(ROOT)/packages/webview_cef/macos/third/cef/version.txt
.PHONY: help start deps ensure_deps widgetbook start_driver widgetbook_driver \
clean clean_all \
set_version release build build_debug publish promote
help:
@echo "Run locally:"
@echo " make start Run the app (flutter run -d macos)"
@echo " make deps flutter pub get + CEF/pods"
@echo " make widgetbook Every screen and dialog, in every state"
@echo " make start_driver The app, drivable through the Dart MCP server"
@echo " make widgetbook_driver Widgetbook, drivable through the Dart MCP server"
@echo " make clean Remove build/ and dist/ (keeps CEF)"
@echo " make clean_all Also remove CEF and Pods"
@echo ""
@echo "Release the app:"
@echo " make release V=1.2.3 Set the version (or V=patch|minor|major|build),"
@echo " build, notarize, upload. Testable by direct"
@echo " download; existing installs are NOT updated yet."
@echo " make promote Put the uploaded build in the appcast —"
@echo " auto-update goes live for every install"
@echo ""
@echo " make set_version V=… Set the version and bump both build counters"
@echo " make build Signed + notarized zip in dist/, no upload"
@echo " make publish Upload the built zip + refresh the download links"
@echo " make build_debug Unsigned zip, local only"
@echo ""
@echo "The app installs Flutter and the Serverpod CLI from their official"
@echo "sources on first run, so no toolchain is needed to build or ship it."
# ---------------------------------------------------------------------------
# Run locally
# ---------------------------------------------------------------------------
# CEF is the one thing that must exist before the app can build at all.
ensure_deps:
@if test -f "$(CEF_STAMP)"; then \
echo "==> CEF ready"; \
else \
echo "==> CEF missing — running deps"; \
$(MAKE) deps; \
fi
deps:
@echo "==> flutter pub get"
cd "$(ROOT)" && flutter pub get
@echo "==> macOS pods / CEF"
cd "$(ROOT)/macos" && pod install
# Refuses to start while another `flutter run` of this repo is running. Every
# run builds into the same build/macos bundle, so a second one rebuilds and
# replaces the app the first is using. Other projects' runs are left alone:
# only a run whose working directory is this repo counts.
define refuse_second_run
@for pid in $$(pgrep -f "flutter_tools.snapshot run" || true); do \
cwd=$$(lsof -a -p $$pid -d cwd -Fn 2>/dev/null | sed -n 's/^n//p'); \
if [ "$$cwd" = "$(ROOT)" ]; then \
echo "error: flutter run is already active for this project (pid $$pid)."; \
echo " Stop it first — a second run would replace the app it is using."; \
exit 1; \
fi; \
done
endef
start: ensure_deps
$(refuse_second_run)
@echo "==> flutter run -d macos"
cd "$(ROOT)" && flutter run -d macos
# Widgetbook: every screen and dialog in every state, in both themes, for
# reviewing copy and layout. A second entry point into this package rather
# than an app of its own, so it runs in App Studio's own macOS runner — same
# fonts, assets and plugins — and needs CEF for the same reason `start` does.
widgetbook: ensure_deps
$(refuse_second_run)
@echo "==> flutter run -d macos -t widgetbook/main.dart"
cd "$(ROOT)" && flutter run -d macos -t widgetbook/main.dart
# The same two, with Flutter Driver's extension switched on, so an agent can
# tap, type and take screenshots through the Dart MCP server. The entry points
# live in test_driver/, outside lib/, so flutter_driver never ships.
start_driver: ensure_deps
$(refuse_second_run)
@echo "==> flutter run -d macos -t test_driver/app.dart"
cd "$(ROOT)" && flutter run -d macos -t test_driver/app.dart
widgetbook_driver: ensure_deps
$(refuse_second_run)
@echo "==> flutter run -d macos -t test_driver/widgetbook.dart"
cd "$(ROOT)" && flutter run -d macos -t test_driver/widgetbook.dart
# Xcode leaves unknown files under Contents/Resources between builds, so a tree
# from before the toolchain moved out keeps a ~1.8 GB embed alive. distribute
# drops it defensively, but a clean build tree is the honest fix.
clean:
@echo "==> flutter clean"
cd "$(ROOT)" && flutter clean
@echo "==> removing dist/"
rm -rf "$(ROOT)/dist"
@echo ""
@echo "Kept (expensive to re-fetch, use clean_all to drop them too):"
@echo " packages/webview_cef/macos/third/cef CEF binaries"
@echo " macos/Pods CocoaPods"
@echo ""
@echo "flutter clean also removed .dart_tool, so dart analyze will report"
@echo "thousands of unresolved imports until you run: flutter pub get"
# Back to a fresh checkout. Re-fetches CEF (~380 MB) on the next build. Also
# drops toolchain/, what the retired tool-publishing pipeline left behind.
clean_all: clean
@echo "==> removing CEF, Pods and any old toolchain/ build trees"
rm -rf "$(ROOT)/packages/webview_cef/macos/third/cef"
rm -rf "$(ROOT)/macos/Pods"
rm -rf "$(ROOT)/toolchain"
# ---------------------------------------------------------------------------
# Release the app
#
# Two deliberate halves. `make release` ends with the build uploaded and
# testable by direct download, but invisible to auto-update; `make promote`
# is the separate, confirmed step that puts it in the appcast. That split is
# what lets a build be tried on another Mac before every install is offered it.
# ---------------------------------------------------------------------------
# Set the version. The build counter is bumped automatically and never reset —
# Sparkle compares CFBundleVersion, so a repeat or a rollback would make every
# installed copy stop seeing updates. It clears promoted releases AND uploads
# still waiting for promotion. Windows has a counter of its own
# (windows/release.json), bumped by the same rule in the same command.
#
# make set_version V=1.2.3 make set_version V=patch
set_version:
@test -n "$(V)" || { \
echo "usage: make set_version V=1.2.3 (or V=patch|minor|major|build)"; \
exit 1; \
}
cd "$(ROOT)" && ./tool/set_version.sh "$(V)"
cd "$(ROOT)" && ./tool/windows/bump_build.sh
# Build, sign and notarize the zip into dist/macos. Nothing is uploaded.
build: ensure_deps
@echo "==> distribute (signed + notarized)"
cd "$(ROOT)" && NOTARIZE=1 ./tool/distribute_macos.sh
# Unsigned zip for local smoke tests on other Macs (xattr -cr may still be
# needed there). Never uploaded.
build_debug: ensure_deps
@echo "==> distribute (unsigned, no notarization)"
cd "$(ROOT)" && SIGN_IDENTITY="" NOTARIZE=0 ./tool/distribute_macos.sh
# Upload the built zip to the immutable releases/ path and point the
# downloads/macos.json "preview" entry at it. Does NOT touch the appcast.
# Safe to re-run: an upload of identical bytes is recognised and skipped.
publish:
cd "$(ROOT)" && ./tool/publish_dist.sh
# The whole first half in one action: set the version, build, upload.
release: set_version
@$(MAKE) build
@$(MAKE) publish
# The second half: add the uploaded build to the Sparkle appcast, after which
# every installed copy is offered it. Asks first — this is the step that
# reaches users, and it cannot be taken back (build numbers never repeat).
promote:
@grep '^version:' "$(ROOT)/pubspec.yaml" | sed 's/^version: */ about to promote: /'
@read -r -p "Make this build the live auto-update for every install? [y/N] " a; \
[[ $$a == [yY]* ]] || { echo "aborted"; exit 1; }
cd "$(ROOT)" && ./tool/publish_appcast.sh