-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
219 lines (198 loc) · 8.69 KB
/
Makefile
File metadata and controls
219 lines (198 loc) · 8.69 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# VoidReader Makefile
# Run `make help` for available commands
.PHONY: help project build run run-debug test test-ui test-ui-debug clean format lint xcode setup install dmg dmg-signed staple profile
# Default target
help:
@echo "VoidReader Development Commands"
@echo ""
@echo "Build & Run:"
@echo " make build - Build the app (Debug)"
@echo " make release - Build the app (Release)"
@echo " make run - Build and run the app"
@echo " make run-debug - Run with debug telemetry (VOID_READER_DEBUG=1)"
@echo " make run-debug-file - Run with debug telemetry + file logging"
@echo ""
@echo "Profiling:"
@echo " make profile - Build Debug and open Instruments with VoidReader as target"
@echo " (FILE=path/to/doc.md to auto-open a document at launch)"
@echo ""
@echo "Testing:"
@echo " make test - Run unit tests"
@echo " make test-ui - Run UI tests (XCUITest)"
@echo " make test-ui-debug - Run UI tests with debug logging"
@echo ""
@echo "Project:"
@echo " make setup - First-time setup (install dependencies)"
@echo " make project - Regenerate Xcode project from project.yml"
@echo " make xcode - Open project in Xcode"
@echo " make clean - Clean build artifacts"
@echo " make format - Format Swift code"
@echo " make lint - Lint Swift code"
@echo ""
@echo "Distribution:"
@echo " make install - Build release and install to /Applications"
@echo " make dmg - Build release DMG (unsigned)"
@echo " make dmg-signed - Build signed & notarized DMG"
@echo " make staple - Staple notarization ticket to DMG"
@echo ""
# First-time setup
setup:
@echo "Checking dependencies..."
@command -v xcodegen >/dev/null 2>&1 || { echo "Installing xcodegen..."; brew install xcodegen; }
@command -v swiftlint >/dev/null 2>&1 || { echo "Installing swiftlint..."; brew install swiftlint; }
@command -v swiftformat >/dev/null 2>&1 || { echo "Installing swiftformat..."; brew install swiftformat; }
@echo "Generating Xcode project..."
@$(MAKE) project
@echo ""
@echo "✓ Setup complete!"
@echo ""
@echo "Next steps:"
@echo " 1. make xcode"
@echo " 2. Select your signing team in Xcode"
@echo " 3. Cmd+R to run"
# Regenerate Xcode project
project:
@echo "Generating Xcode project..."
xcodegen generate
@echo "✓ Project generated"
# Build (Debug)
build:
@echo "Building (Debug)..."
xcodebuild -scheme VoidReader -configuration Debug build -quiet
@echo "✓ Build succeeded"
# Build (Release)
release:
@echo "Building (Release)..."
xcodebuild -scheme VoidReader -configuration Release build -quiet
@echo "✓ Release build succeeded"
# Install to /Applications
install: release
@echo "Installing to /Applications..."
@rm -rf /Applications/VoidReader.app
@cp -R "$$(xcodebuild -scheme VoidReader -configuration Release -showBuildSettings | grep -m 1 'BUILT_PRODUCTS_DIR' | awk '{print $$3}')/VoidReader.app" /Applications/
@echo "✓ Installed to /Applications/VoidReader.app"
# Build and run
run: build
@echo "Running VoidReader..."
@open "$$(xcodebuild -scheme VoidReader -configuration Debug -showBuildSettings | grep -m 1 'BUILT_PRODUCTS_DIR' | awk '{print $$3}')/VoidReader.app"
# Run with debug telemetry enabled
run-debug: build
@echo "Running VoidReader with debug telemetry..."
@VOID_READER_DEBUG=1 open "$$(xcodebuild -scheme VoidReader -configuration Debug -showBuildSettings | grep -m 1 'BUILT_PRODUCTS_DIR' | awk '{print $$3}')/VoidReader.app"
@echo ""
@echo "View logs in Console.app with filter: subsystem:com.voidreader.debug"
# Open Instruments with VoidReader preloaded as the recording target.
# Usage:
# make profile # interactive: pick template in Instruments, hit record
# make profile FILE=doc.md # auto-launch with a document open (uses xctrace Time Profiler)
# make profile FILE=doc.md TIME=15 # headless run capped at 15s wall-clock (recommended for CI/CLI)
# make profile FILE=doc.md AUTOSCROLL=fast # drive a top→bottom scroll pass after 3s delay (DEBUG builds only)
# make profile FILE=doc.md AUTOSCROLL=slow # same, at ~3600 pt/s instead of ~24000 pt/s
#
# Signposts emitted by the app appear under "os_signpost" / "Points of Interest"
# in any template that includes the os_signpost instrument (Time Profiler,
# Animation Hitches, Allocations, etc.). See DEVELOPMENT.md "Profiling" section
# for full runbooks. See openspec/changes/add-performance-instrumentation/
# FINDINGS_p2_signpost_surfacing.md for why categories must be .pointsOfInterest.
profile: build
@APP_PATH="$$(xcodebuild -scheme VoidReader -configuration Debug -showBuildSettings | grep -m 1 'BUILT_PRODUCTS_DIR' | awk '{print $$3}')/VoidReader.app"; \
case "$$APP_PATH" in *Release*) echo "ERROR: resolved path points to Release build: $$APP_PATH"; echo " purge build/derived and retry"; exit 1 ;; esac; \
if [ -n "$(FILE)" ]; then \
ABS_FILE="$$(cd "$$(dirname "$(FILE)")" && pwd)/$$(basename "$(FILE)")"; \
echo "Profiling with document: $$ABS_FILE"; \
echo " APP_PATH: $$APP_PATH"; \
mkdir -p build/traces; \
STAMP="$$(date +%Y%m%d-%H%M%S)"; \
TRACE_OUT="build/traces/voidreader-$$STAMP.trace"; \
DEBUG_LOG="build/traces/voidreader-$$STAMP.debug.log"; \
TIME_FLAG=""; \
if [ -n "$(TIME)" ]; then TIME_FLAG="--time-limit $(TIME)s"; echo " time-limit: $(TIME)s"; fi; \
AUTOSCROLL_ENV=""; \
if [ -n "$(AUTOSCROLL)" ]; then \
AUTOSCROLL_ENV="--env VOID_READER_AUTOSCROLL=1 --env VOID_READER_AUTOSCROLL_SPEED=$(AUTOSCROLL)"; \
echo " autoscroll: $(AUTOSCROLL) (app will terminate at bottom)"; \
fi; \
echo "Recording with Time Profiler template (xctrace headless)..."; \
xcrun xctrace record \
--template 'Time Profiler' \
--instrument os_signpost \
$$TIME_FLAG \
--env VOID_READER_DEBUG=1 \
--env VOID_READER_DEBUG_FILE="$$PWD/$$DEBUG_LOG" \
--env VOID_READER_OPEN="$$ABS_FILE" \
$$AUTOSCROLL_ENV \
--output "$$TRACE_OUT" \
--launch -- "$$APP_PATH/Contents/MacOS/VoidReader"; \
echo ""; \
echo " Debug log: $$DEBUG_LOG"; \
echo ""; \
echo "✓ Trace recorded: $$TRACE_OUT"; \
echo " Open with: open $$TRACE_OUT"; \
else \
echo "Opening Instruments with VoidReader as target..."; \
echo " → Pick a template (Time Profiler, Animation Hitches, Allocations)"; \
echo " → Press Record (⌘R), then drive the app"; \
echo " → Signposts appear under 'os_signpost' / 'Points of Interest'"; \
open -a Instruments "$$APP_PATH"; \
fi
# Run with debug telemetry and file logging
run-debug-file: build
@echo "Running VoidReader with debug telemetry (file logging)..."
@VOID_READER_DEBUG=1 VOID_READER_DEBUG_FILE=/tmp/voidreader_debug.log open "$$(xcodebuild -scheme VoidReader -configuration Debug -showBuildSettings | grep -m 1 'BUILT_PRODUCTS_DIR' | awk '{print $$3}')/VoidReader.app"
@echo ""
@echo "Logs being written to: /tmp/voidreader_debug.log"
@echo "Tail with: tail -f /tmp/voidreader_debug.log"
# Run tests (unit tests only)
test:
@echo "Running package tests..."
swift test
@echo ""
@echo "Running app tests..."
xcodebuild -scheme VoidReader -configuration Debug test -only-testing:VoidReaderTests -quiet || true
@echo "✓ Tests complete"
# Run UI tests
test-ui:
@echo "Running UI tests..."
xcodebuild -scheme VoidReader -configuration Debug test -only-testing:VoidReaderUITests -quiet || true
@echo "✓ UI tests complete"
# Run UI tests with debug telemetry and capture output
test-ui-debug:
@echo "Running UI tests with debug telemetry..."
@rm -f /tmp/voidreader_uitest_*.log
xcodebuild -scheme VoidReader -configuration Debug test -only-testing:VoidReaderUITests 2>&1 | tee /tmp/uitest_output.log || true
@echo ""
@echo "✓ UI tests complete"
@echo "Debug logs written to: /tmp/voidreader_uitest_*.log"
@ls -la /tmp/voidreader_uitest_*.log 2>/dev/null || echo "No debug logs found"
# Clean
clean:
@echo "Cleaning..."
rm -rf .build
rm -rf ~/Library/Developer/Xcode/DerivedData/VoidReader-*
xcodebuild clean -scheme VoidReader -quiet 2>/dev/null || true
@echo "✓ Clean complete"
# Format code
format:
@echo "Formatting Swift code..."
swiftformat Sources App Tests --swiftversion 5.9
@echo "✓ Formatting complete"
# Lint code
lint:
@echo "Linting Swift code..."
swiftlint Sources App Tests
@echo "✓ Linting complete"
# Open in Xcode
xcode: project
@echo "Opening Xcode..."
open VoidReader.xcodeproj
# Build DMG for distribution (unsigned)
dmg:
@./scripts/build-dmg.sh
# Build signed & notarized DMG
dmg-signed:
@./scripts/build-signed-dmg.sh
# Staple notarization ticket to existing DMG (after Apple approves)
staple:
@echo "Stapling notarization ticket..."
xcrun stapler staple build/VoidReader.dmg
@echo "✓ Stapled. DMG ready for distribution."