Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
196 lines (157 loc) · 7.49 KB
/
Copy pathjustfile
File metadata and controls
196 lines (157 loc) · 7.49 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
XCBEAUTIFY_ARGS := "--quiet --is-ci"
BUILD_THREADS := `getconf _NPROCESSORS_ONLN`
SIMULATOR_NAME := env("SIMULATOR_NAME", "iPhone 17")
SIMULATOR_DEST := "platform=iOS Simulator,name=" + SIMULATOR_NAME
XCODE_CONFIGURATION := env("CONFIGURATION", "Debug")
GEMSTONE_IOS_PROFILE := if XCODE_CONFIGURATION == "Release" { "release" } else { "debug" }
DERIVED_DATA := "build/DerivedData"
SPM_CACHE := "build/SourcePackages"
XCODEBUILD := "xcodebuild -project Gem.xcodeproj -derivedDataPath " + DERIVED_DATA + " -clonedSourcePackagesDirPath " + SPM_CACHE
GEMSTONE_LINKER_FLAGS := '"OTHER_LDFLAGS=\$(inherited) $PWD/../core/target/aarch64-apple-ios-sim/' + GEMSTONE_IOS_PROFILE + '/libgemstone.a"'
COMPILATION_CACHE_FLAGS := if XCODE_CONFIGURATION == "Release" { "" } else { "COMPILATION_CACHE_ENABLE_CACHING=YES COMPILATION_CACHE_LIMIT_SIZE=40G" }
SIMULATOR_BUILD_FLAGS := '-configuration "' + XCODE_CONFIGURATION + '" -destination "' + SIMULATOR_DEST + '" ONLY_ACTIVE_ARCH=YES -parallelizeTargets -jobs ' + BUILD_THREADS + ' ' + GEMSTONE_LINKER_FLAGS + ' ' + COMPILATION_CACHE_FLAGS
default:
@just --list
install: install-toolchains install-swifttools generate-stone
install-toolchains:
@echo "==> Install toolchains for uniffi"
@cd ../core && just gemstone install-ios-targets
install-swifttools:
@echo "==> Install Swift tools"
@brew install swiftformat swiftlint xcbeautify
setup-git:
@echo "==> Setup git submodules"
@git submodule update --init --recursive
@git config submodule.recurse true
spm-resolve:
@{{ XCODEBUILD }} -resolvePackageDependencies -scheme Gem
spm-resolve-all:
@sh scripts/spm-resolve-all.sh
lint:
@echo "==> Running SwiftLint"
@git ls-files -z '*.swift' | xargs -0 swiftlint lint --fix --config .swiftlint.yml --quiet --force-exclude
format:
@echo "==> Running SwiftFormat"
@git ls-files -z '*.swift' | xargs -0 swiftformat --config .swiftformat --quiet
_build action scheme="Gem":
@set -o pipefail && {{ XCODEBUILD }} \
-scheme {{ scheme }} \
{{ SIMULATOR_BUILD_FLAGS }} \
-showBuildTimingSummary \
{{ action }} | xcbeautify {{ XCBEAUTIFY_ARGS }}
# Example: just build
build: (_build "build")
# Example: just build-for-testing
build-for-testing: (_build "build-for-testing")
clean:
#!/usr/bin/env bash
set -euo pipefail
rm -rf build .build
while IFS= read -r -d '' manifest; do
package_directory="${manifest%/Package.swift}"
rm -rf "$package_directory/build" "$package_directory/.build"
done < <(find . -name Package.swift -print0)
echo "iOS build folders cleaned"
_simulator-app:
#!/usr/bin/env bash
set -euo pipefail
xcode_developer_directory="$(xcode-select -p)"
if [ -d "$xcode_developer_directory/../Applications/DeviceHub.app" ]; then
printf '%s\n' "$xcode_developer_directory/../Applications/DeviceHub.app"
else
printf '%s\n' "$xcode_developer_directory/Applications/Simulator.app"
fi
run: build boot-simulator
@echo "==> Installing app on simulator..."
@open -a "$(just _simulator-app)"
@xcrun simctl install "{{SIMULATOR_NAME}}" {{DERIVED_DATA}}/Build/Products/Debug-iphonesimulator/Gem.app
@echo "==> Launching app..."
@xcrun simctl launch --console-pty "{{SIMULATOR_NAME}}" com.gemwallet.ios
# Fastest compile check while iterating: builds one package with SwiftPM, no xcodebuild.
# ~1-2s warm against 8s or more for `just build`, and reports every error in the package
# instead of stopping at the first failing file. SwiftPM builds for the host, so this
# only works for packages that never import UIKit or SwiftUI; the rest need `just build`.
# Example: just check GemstonePrimitives
check PACKAGE:
@dir=$(ls -d Packages/{{PACKAGE}} Features/{{PACKAGE}} 2>/dev/null | head -1); \
if [ -z "$dir" ]; then echo "no package or feature named {{PACKAGE}}"; exit 1; fi; \
cd "$dir" && swift build
# Runs one package's tests with SwiftPM. Same host-build limits as `just check`, plus
# packages that depend on Gemstone cannot link — the static library is built for the
# iOS simulator. For those use `just test <TestTarget>`.
# Example: just check-test Primitives
check-test PACKAGE:
@dir=$(ls -d Packages/{{PACKAGE}} Features/{{PACKAGE}} 2>/dev/null | head -1); \
if [ -z "$dir" ]; then echo "no package or feature named {{PACKAGE}}"; exit 1; fi; \
cd "$dir" && swift test
# Example: just build-package Primitives
build-package PACKAGE: (_build "build" PACKAGE)
archive-release: clean
@set -o pipefail && {{ XCODEBUILD }} \
-scheme Gem \
-configuration Release \
-sdk iphoneos \
-destination "generic/platform=iOS" \
-archivePath {{DERIVED_DATA}}/Gem.xcarchive \
-jobs {{BUILD_THREADS}} \
CODE_SIGNING_ALLOWED=NO \
archive | xcbeautify {{XCBEAUTIFY_ARGS}}
show-simulator:
@echo "Destination: {{SIMULATOR_DEST}}"
@xcrun simctl list devices | grep "iPhone" | head -5 || true
_test action target="":
@set -o pipefail && {{ XCODEBUILD }} \
-scheme Gem \
{{ SIMULATOR_BUILD_FLAGS }} \
{{ if target != "" { "-only-testing " + target + " -parallel-testing-enabled NO" } else { "-parallel-testing-enabled YES" } }} \
{{ action }} | xcbeautify {{ XCBEAUTIFY_ARGS }}
test-without-building TARGET="": boot-simulator (_test "test-without-building" TARGET)
# Example: just test
# Example: just test PrimitivesTests
test TARGET="": boot-simulator (_test "test" TARGET)
test-package PACKAGE: (test (PACKAGE + "Tests"))
test-all: test
_test-integration action:
@set -o pipefail && {{ XCODEBUILD }} \
-scheme GemUITests \
-testPlan ui_tests \
{{ SIMULATOR_BUILD_FLAGS }} \
-allowProvisioningUpdates \
-allowProvisioningDeviceRegistration \
{{ action }} | xcbeautify {{ XCBEAUTIFY_ARGS }}
test-integration: reset-simulator (_test-integration "test")
test-ui: test-integration
build-for-testing-integration: (_test-integration "build-for-testing")
test-integration-without-building: reset-simulator (_test-integration "test-without-building")
# Run full upgrade test: build old version, create wallet, build current, verify wallet survives
test-upgrade COMMIT:
@bash ./scripts/upgrade-test.sh {{COMMIT}}
boot-simulator:
@xcrun simctl boot "{{SIMULATOR_NAME}}" 2>/dev/null || true
wait-simulator:
#!/usr/bin/env bash
for _ in $(seq 1 12); do
xcrun simctl list runtimes > /dev/null
xcrun simctl list devices available | grep -qF "{{SIMULATOR_NAME}} (" && exit 0
sleep 10
done
xcrun simctl list runtimes
echo "{{SIMULATOR_NAME}} simulator is not available"
exit 1
reset-simulator NAME=SIMULATOR_NAME:
@echo "==> Resetting {{NAME}} simulator to clean state"
@xcrun simctl shutdown "{{NAME}}" 2>/dev/null || true
@xcrun simctl erase "{{NAME}}" 2>/dev/null || true
@xcrun simctl boot "{{NAME}}" 2>/dev/null || true
localize:
@cd ../core && cargo run --package generate --bin generate localize ios ../localization/app ../ios/Packages/Localization/Sources
@cd ../core && cargo run --package generate --bin generate localize ios-plist ../localization/InfoPlist ../ios/Packages/Localization/Sources/Resources
@cd ../core && cargo run --package generate --bin generate localize ios-widget ../localization/widget ../ios/Packages/Localization/WidgetSources
generate: generate-models
generate-models:
@echo "==> Generate models for iOS"
@cd ../core && cargo run --package generate --bin generate ios ../ios/Packages
generate-stone BUILD_MODE="":
@./scripts/generate-stone.sh {{BUILD_MODE}}
bump TARGET="patch":
@cd .. && just bump {{TARGET}}