-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (117 loc) · 5.29 KB
/
Copy pathMakefile
File metadata and controls
138 lines (117 loc) · 5.29 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
# Destination precedence: an explicit SIM= (command line or environment) wins;
# otherwise this worktree's dedicated simulator from .simulator_id (created by
# the addworktree/takeoff fish functions); otherwise the shared default device.
SIM_FROM_WORKTREE := $(shell test -f .simulator_id && printf 'platform=iOS Simulator,id=%s' "$$(cat .simulator_id)")
SIM ?= $(if $(SIM_FROM_WORKTREE),$(SIM_FROM_WORKTREE),platform=iOS Simulator,name=iPhone 17)
WATCH_SIM := generic/platform=watchOS Simulator
# Concrete watchOS Simulator used by watch UI tests (xcodebuild requires a
# concrete device to run XCTests). The default is resolved to the matching
# device's UDID at parse time: with multiple watchOS runtimes installed, a
# name-only destination normalizes to OS:latest and can match nothing.
# Override with WATCH_TEST_SIM='platform=watchOS Simulator,id=…' to pin a
# specific device.
# Parentheses for use inside $(shell ...): make counts parentheses even inside
# quoted shell text, so embedded '(' / ')' must come from these variables.
LPAREN := (
RPAREN := )
# The `,id=…` / `,name=…` destinations contain commas, which make uses to split
# $(if …) arguments, so each destination is pre-built as its own variable.
WATCH_TEST_SIM_UDID := $(shell xcrun simctl list devices available | awk -v n='Apple Watch Series 11 $(LPAREN)46mm$(RPAREN)' '{ s = $$0; sub(/^[ \t]+/, "", s); if (index(s, n " $(LPAREN)") == 1) { print; exit } }' | sed -E 's/.*\$(LPAREN)([A-F0-9-]+)\$(RPAREN).*/\1/')
WATCH_TEST_SIM_ID := platform=watchOS Simulator,id=$(WATCH_TEST_SIM_UDID)
WATCH_TEST_SIM_NAME := platform=watchOS Simulator,name=Apple Watch Series 11 (46mm)
WATCH_TEST_SIM ?= $(if $(WATCH_TEST_SIM_UDID),$(WATCH_TEST_SIM_ID),$(WATCH_TEST_SIM_NAME))
MAC_SIM := platform=macOS
DERIVED_DATA := DerivedData
COVERAGE_RESULT := build/Coverage.xcresult
COVERAGE_UI_RESULT := build/Coverage.UI.xcresult
COVERAGE_ALL_RESULT := build/Coverage.All.xcresult
# Export SIM only when explicitly overridden: scripts/test.sh resolves
# .simulator_id itself and must not receive the name-only fallback as if it
# were an explicit override.
ifneq ($(origin SIM),file)
export SIM
endif
.PHONY: build watch-build test ui-test simverify mac-build mac-test mac-run mac-distribute reset-storekit coverage coverage-ui coverage-all check clean lint format periphery watch-ui-test watch-test
build:
xcodebuild -scheme SingleThread -destination '$(SIM)' -configuration Debug -derivedDataPath '$(DERIVED_DATA)' build-for-testing
watch-build:
xcodebuild -scheme SingleThreadWatch -destination '$(WATCH_SIM)' -configuration Debug -derivedDataPath '$(DERIVED_DATA)' build
mac-build:
xcodebuild -scheme SingleThread -destination '$(MAC_SIM)' -configuration Debug -derivedDataPath '$(DERIVED_DATA)' CODE_SIGNING_ALLOWED=NO build
mac-test:
xcodebuild -scheme SingleThread -destination '$(MAC_SIM)' -derivedDataPath '$(DERIVED_DATA)' CODE_SIGNING_ALLOWED=NO test -only-testing:SingleThreadTests
mac-run:
xcodebuild -scheme SingleThread -destination '$(MAC_SIM)' \
-configuration Debug -derivedDataPath '$(DERIVED_DATA)' build
open '$(DERIVED_DATA)/Build/Products/Debug/SingleThread.app'
mac-distribute:
bash scripts/distribute-macos.sh
reset-storekit:
bash scripts/reset-storekit.sh
coverage:
rm -rf '$(COVERAGE_RESULT)'
xcodebuild -scheme SingleThread \
-destination '$(SIM)' \
-derivedDataPath '$(DERIVED_DATA)' \
-enableCodeCoverage YES \
-only-testing:SingleThreadTests \
test \
-resultBundlePath '$(COVERAGE_RESULT)'
@echo ""
@echo "==> Coverage report"
xcrun xccov view --report '$(COVERAGE_RESULT)'
coverage-ui:
rm -rf '$(COVERAGE_UI_RESULT)'
xcodebuild -scheme SingleThread \
-destination '$(SIM)' \
-derivedDataPath '$(DERIVED_DATA)' \
-enableCodeCoverage YES \
-only-testing:SingleThreadUITests \
test \
-resultBundlePath '$(COVERAGE_UI_RESULT)'
@echo ""
@echo "==> UI coverage report"
xcrun xccov view --report '$(COVERAGE_UI_RESULT)'
coverage-all:
rm -rf '$(COVERAGE_ALL_RESULT)'
xcodebuild -scheme SingleThread \
-destination '$(SIM)' \
-derivedDataPath '$(DERIVED_DATA)' \
-enableCodeCoverage YES \
test \
-resultBundlePath '$(COVERAGE_ALL_RESULT)'
@echo ""
@echo "==> Full coverage report (unit + UI)"
xcrun xccov view --report '$(COVERAGE_ALL_RESULT)'
test:
./scripts/test.sh --unit-only
ui-test:
./scripts/test.sh --ui-only
simverify:
./scripts/simverify.sh
watch-ui-test:
xcodebuild -scheme SingleThreadWatch \
-destination '$(WATCH_TEST_SIM)' \
-configuration Debug \
-derivedDataPath '$(DERIVED_DATA)' \
test \
-only-testing:SingleThreadWatchUITests
watch-test:
xcodebuild -scheme SingleThreadWatch \
-destination '$(WATCH_TEST_SIM)' \
-configuration Debug \
-derivedDataPath '$(DERIVED_DATA)' \
test \
-only-testing:SingleThreadWatchTests
check:
./scripts/test.sh
clean:
xcodebuild -scheme SingleThread -destination '$(SIM)' clean
lint:
swiftformat --lint SingleThread/ SingleThreadCore/ SingleThreadWatch/ SingleThreadWidget/ SingleThreadTests/ SingleThreadUITests/ SingleThreadWatchUITests/ SingleThreadWatchTests/
swiftlint lint --strict
format:
swiftformat SingleThread/ SingleThreadCore/ SingleThreadWatch/ SingleThreadWidget/ SingleThreadTests/ SingleThreadUITests/ SingleThreadWatchUITests/ SingleThreadWatchTests/
swiftlint --fix
periphery:
periphery scan --strict -- -destination "$(SIM)"