-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
184 lines (156 loc) · 7.07 KB
/
Makefile
File metadata and controls
184 lines (156 loc) · 7.07 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
.PHONY: build test lint lint-fix clean resolve open build-evm-demo build-solana-demo run-solana-demo run-evm-demo
# Default task
all: build
# ==========================================
# User-configurable variables (uppercase)
# ==========================================
# Simulator destination for builds and tests
SIMULATOR_DEST := platform=iOS Simulator,name=iPhone 17 Pro,OS=26.1
# Scheme names
SDK_SCHEME := CrossmintClientSDK
SOLANA_DEMO_SCHEME := SolanaDemo
EVM_DEMO_SCHEME := SmartWalletsDemo
# External programs
XCODEBUILD := xcodebuild
XCRUN := xcrun
SWIFT := swift
# Bundle identifiers for demos
SOLANA_BUNDLE_ID := com.paella.SolanaDemo
EVM_BUNDLE_ID := com.paella.SmartWalletsDemo
# ==========================================
# Internal variables (lowercase)
# ==========================================
# SwiftLint binary from build artifacts
swiftlint_bin := .build/artifacts/swiftlintplugins/SwiftLintBinary/SwiftLintBinary.artifactbundle/swiftlint-0.59.1-macos/bin/swiftlint
# ==========================================
# Functions
# ==========================================
# Define a function to run xcodebuild with xcbeautify
define run-with-xcbeautify
@if command -v xcbeautify >/dev/null 2>&1; then \
set -o pipefail && $(1) | xcbeautify; \
else \
$(1); \
fi
endef
# ==========================================
# Build targets
# ==========================================
# Build the Swift package
build:
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(SDK_SCHEME) -destination "$(SIMULATOR_DEST)" -skipPackagePluginValidation)
# Build with release configuration
release:
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(SDK_SCHEME) -destination "$(SIMULATOR_DEST)" archive -skipPackagePluginValidation)
# Build the EVM demo app (SmartWalletsDemo)
build-evm-demo:
@echo "Building EVM demo app..."
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(EVM_DEMO_SCHEME) -destination "$(SIMULATOR_DEST)" -skipPackagePluginValidation)
# Build the Solana demo app
build-solana-demo:
@echo "Building Solana demo app..."
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(SOLANA_DEMO_SCHEME) -destination "$(SIMULATOR_DEST)" -skipPackagePluginValidation)
# ==========================================
# Test targets
# ==========================================
# Run all tests
test:
@echo "Running tests..."
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(SDK_SCHEME) -destination "$(SIMULATOR_DEST)" test)
# CI sanity check and test running
ci-test:
@echo "Resolving dependencies..."
$(SWIFT) package resolve
@echo "Checking if lint-fix would produce changes..."
git diff --quiet || { echo "Working copy has uncommitted changes. Please commit or stash them first."; exit 1; }
$(SWIFT) package plugin --allow-writing-to-package-directory swiftlint --fix
git status
@if [ -n "$$(git diff)" ]; then \
echo "lint-fix produced changes to the working copy. Reverting changes and failing."; \
git checkout -- .; \
exit 1; \
fi
$(MAKE) lint
@echo "Running tests..."
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(SDK_SCHEME) -destination "$(SIMULATOR_DEST)" test -skipPackagePluginValidation)
@echo "Building demo apps..."
$(MAKE) build-evm-demo
$(MAKE) build-solana-demo
# ==========================================
# Lint targets
# ==========================================
# Run SwiftLint using the SPM plugin
lint:
@echo "Running SwiftLint via Swift Package Manager..."
$(SWIFT) package plugin --allow-writing-to-package-directory swiftlint lint-strict || (echo "SwiftLint found issues. Please fix them before running tests." && exit 1)
@echo "Running SwiftLint on SolanaDemo..."
@if [ -f "$(swiftlint_bin)" ]; then \
$(swiftlint_bin) lint Examples/SolanaDemo/SolanaDemo --strict || (echo "SwiftLint found issues in SolanaDemo. Please fix them before running tests." && exit 1); \
else \
echo "SwiftLint binary not found. Run 'make build' first to download dependencies."; \
exit 1; \
fi
@echo "Running SwiftLint on SmartWalletsDemo..."
@if [ -f "$(swiftlint_bin)" ]; then \
$(swiftlint_bin) lint Examples/SmartWalletsDemo/SmartWalletsDemo --strict || (echo "SwiftLint found issues in SmartWalletsDemo. Please fix them before running tests." && exit 1); \
else \
echo "SwiftLint binary not found. Run 'make build' first to download dependencies."; \
exit 1; \
fi
# Run SwiftLint with auto-fix option
lint-fix:
@echo "Running SwiftLint with auto-fix option..."
$(SWIFT) package plugin --allow-writing-to-package-directory swiftlint --fix
@echo "Running SwiftLint auto-fix on SolanaDemo..."
@if [ -f "$(swiftlint_bin)" ]; then \
$(swiftlint_bin) --fix Examples/SolanaDemo/SolanaDemo; \
else \
echo "SwiftLint binary not found. Run 'make build' first to download dependencies."; \
exit 1; \
fi
@echo "Running SwiftLint auto-fix on SmartWalletsDemo..."
@if [ -f "$(swiftlint_bin)" ]; then \
$(swiftlint_bin) --fix Examples/SmartWalletsDemo/SmartWalletsDemo; \
else \
echo "SwiftLint binary not found. Run 'make build' first to download dependencies."; \
exit 1; \
fi
# ==========================================
# Clean and utility targets
# ==========================================
# Clean build artifacts
clean:
@echo "Cleaning $(SDK_SCHEME)..."
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(SDK_SCHEME) clean)
@echo "Cleaning $(SOLANA_DEMO_SCHEME)..."
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(SOLANA_DEMO_SCHEME) clean)
@echo "Cleaning $(EVM_DEMO_SCHEME)..."
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(EVM_DEMO_SCHEME) clean)
# Resolve Swift package dependencies (downloads but doesn't update versions)
resolve:
@echo "Resolving Swift package dependencies..."
$(SWIFT) package resolve
# Open in Xcode (macOS only)
open:
open *.xcworkspace
# ==========================================
# Demo run targets
# ==========================================
# Build and run SolanaDemo
run-solana-demo:
@echo "Building and running $(SOLANA_DEMO_SCHEME)..."
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(SOLANA_DEMO_SCHEME) -destination "$(SIMULATOR_DEST)" -skipPackagePluginValidation build)
@echo "Launching $(SOLANA_DEMO_SCHEME) in simulator..."
$(XCRUN) simctl boot "iPhone 17 Pro" 2>/dev/null || true
open -a Simulator
$(XCRUN) simctl install "iPhone 17 Pro" "$$($(XCODEBUILD) -scheme $(SOLANA_DEMO_SCHEME) -destination "$(SIMULATOR_DEST)" -showBuildSettings 2>/dev/null | grep -m 1 "BUILT_PRODUCTS_DIR" | awk '{print $$3}')/$(SOLANA_DEMO_SCHEME).app"
$(XCRUN) simctl launch "iPhone 17 Pro" $(SOLANA_BUNDLE_ID)
# Build and run SmartWalletsDemo (EVM)
run-evm-demo:
@echo "Building and running $(EVM_DEMO_SCHEME)..."
$(call run-with-xcbeautify,$(XCODEBUILD) -scheme $(EVM_DEMO_SCHEME) -destination "$(SIMULATOR_DEST)" -skipPackagePluginValidation build)
@echo "Launching $(EVM_DEMO_SCHEME) in simulator..."
$(XCRUN) simctl boot "iPhone 17 Pro" 2>/dev/null || true
open -a Simulator
$(XCRUN) simctl install "iPhone 17 Pro" "$$($(XCODEBUILD) -scheme $(EVM_DEMO_SCHEME) -destination "$(SIMULATOR_DEST)" -showBuildSettings 2>/dev/null | grep -m 1 "BUILT_PRODUCTS_DIR" | awk '{print $$3}')/$(EVM_DEMO_SCHEME).app"
$(XCRUN) simctl launch "iPhone 17 Pro" $(EVM_BUNDLE_ID)