forked from SamAmco/track-and-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
280 lines (239 loc) · 12.1 KB
/
Copy pathMakefile
File metadata and controls
280 lines (239 loc) · 12.1 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
.PHONY: deep-link-inject
deep-link-serve-local:
ifndef FILE
@echo "Error: FILE parameter is required"
@echo "Usage: make deep-link-inject FILE=<file_path>"
@exit 1
endif
@echo "Injecting deep link for file: $(FILE)"
python3 scripts/serve-and-deep-link-lua.py $(FILE)
deep-link-inject:
ifndef FILE
@echo "Error: FILE parameter is required"
@echo "Usage: make deep-link-inject FILE=<file_path>"
@exit 1
endif
@echo "Injecting deep link for file: $(FILE)"
# Copy the file over adb to the devices tmp directory
adb push $(FILE) /data/local/tmp/tmp.lua
adb shell am start -a android.intent.action.VIEW -d "trackandgraph://lua_inject_file?path=/data/local/tmp/tmp.lua"
validate-remote-config:
@echo "==> Setting up Python environment for configuration validation"
@cd ./configuration && \
if [ ! -d "venv" ]; then \
echo "Creating Python virtual environment..."; \
python3 -m venv venv; \
echo "Installing dependencies..."; \
venv/bin/pip install --upgrade pip; \
venv/bin/pip install -r requirements.txt; \
fi
@echo "==> Running configuration validation"
@cd ./configuration && . venv/bin/activate && python3 ./validate-config.py
# --- Common config ---
HOST_ARCH := $(shell uname -m)
ifeq ($(HOST_ARCH),arm64)
AVD_PACKAGE := system-images;android-35;google_apis;arm64-v8a
else
AVD_PACKAGE := system-images;android-35;google_apis;x86_64
endif
EMULATOR := $(ANDROID_HOME)/emulator/emulator
AVDMANAGER := $(ANDROID_HOME)/cmdline-tools/latest/bin/avdmanager
SDKMANAGER := $(ANDROID_HOME)/cmdline-tools/latest/bin/sdkmanager
# Bail if something else is attached
check-no-devices:
@if [ "`adb devices | grep -w 'device' | grep -v 'List'`" != "" ]; then \
echo "Error: another emulator or device is already running. Close it first."; \
exit 1; \
fi
# Ensure AVD exists
ensure-avd-%:
ifndef ANDROID_HOME
@echo "Error: ANDROID_HOME is not set."; exit 1
endif
@$(EMULATOR) -list-avds | grep -Fx '$*' >/dev/null || ( \
if [ -x "$(AVDMANAGER)" ]; then \
echo "==> Installing system image: $(AVD_PACKAGE)"; \
yes | "$(SDKMANAGER)" "$(AVD_PACKAGE)"; \
echo no | "$(AVDMANAGER)" create avd -n "$*" -k "$(AVD_PACKAGE)" -d "pixel_6"; \
else \
echo "Error: avdmanager missing. Install Android cmdline-tools."; \
exit 1; \
fi \
)
# Boot, wait, prep device (visible emulator)
boot-and-prep-%:
"$(EMULATOR)" -avd "$*" -gpu swiftshader_indirect -no-snapshot -no-boot-anim -no-audio &
@adb wait-for-device
@adb shell 'while [ "$$(getprop sys.boot_completed)" != "1" ]; do sleep 1; done'
@adb shell settings put global hidden_api_policy_pre_p_apps 1
@adb shell settings put global hidden_api_policy_p_apps 1
@adb shell settings put global window_animation_scale 0
@adb shell settings put global transition_animation_scale 0
@adb shell settings put global animator_duration_scale 0
@adb shell settings put system user_rotation 0 # portrait
@adb shell settings put secure show_ime_with_hard_keyboard 1
@adb shell cmd clipboard set text ''
# Shutdown
kill-emulator:
@adb emu kill || true
.PHONY: run-community-tests
run-community-tests: run-community-functions-tests run-community-graph-tests
.PHONY: run-community-functions-tests
run-community-functions-tests:
./gradlew :data:cleanTestDebugUnitTest :data:testDebugUnitTest --tests "com.samco.trackandgraph.data.lua.community_test_runner.FunctionTestRunner"
.PHONY: run-community-graph-tests
run-community-graph-tests:
./gradlew :data:cleanTestDebugUnitTest :data:testDebugUnitTest --tests "com.samco.trackandgraph.data.lua.community_test_runner.GraphScriptTestRunner"
.PHONY: sync-lua-to-docs
sync-lua-to-docs:
./scripts/sync-lua-to-docs.sh
.PHONY: lua-verify-api-specs
lua-verify-api-specs:
cd lua && lua tools/verify-api-specs.lua
.PHONY: lua-get-max-api-level
lua-get-max-api-level:
cd lua && lua tools/get-max-api-level.lua
.PHONY: lua-validate-functions
lua-validate-functions:
cd lua && lua tools/validate-functions.lua
.PHONY: lua-detect-changes
lua-detect-changes:
cd lua && lua tools/detect-changes.lua
.PHONY: lua-pack-functions
lua-pack-functions:
cd lua && lua tools/pack-functions.lua
.PHONY: lua-publish-debug
lua-publish-debug:
cd lua && lua tools/publish-functions-debug.lua
.PHONY: lua-publish-prod
lua-publish-prod:
cd lua && lua tools/publish-functions-prod.lua
.PHONY: lua-print-catalog
lua-print-catalog:
cd lua && lua tools/print-catalog.lua
.PHONY: lua-test-api
lua-test-api:
cd lua && lua src/tng/test/test_all.lua
.PHONY: validate-all
validate-all: lua-test-api validate-remote-config run-community-tests lua-verify-api-specs lua-validate-functions lua-detect-changes
@echo "All validations passed."
.PHONY: assemble-release
assemble-release:
./gradlew clean assembleRelease
.PHONY: bundle-release
bundle-release:
./gradlew clean bundleRelease
.PHONY: assemble-bundle-release
assemble-bundle-release:
./gradlew clean assembleRelease bundleRelease
# ---------- 1) RECORD LOW-RES SNAPSHOT BASELINES ----------
.PHONY: snapshots-record
snapshots-record: check-no-devices ensure-avd-shot-api35-low boot-and-prep-shot-api35-low
@echo "==> Setting low-res display (tuned settings: 548x1280 @ 210dpi)"
adb shell wm size 548x1280
adb shell wm density 210
@echo "==> Recording low-res baselines"
./gradlew :app:screenshotsExecuteScreenshotTests -Precord -PdirectorySuffix=api35-low
@$(MAKE) kill-emulator
# ---------- 2) VERIFY LOW-RES SNAPSHOTS ----------
.PHONY: snapshots-verify
snapshots-verify: check-no-devices ensure-avd-shot-api35-low boot-and-prep-shot-api35-low
@echo "==> Setting low-res display (tuned settings: 548x1280 @ 210dpi)"
adb shell wm size 548x1280
adb shell wm density 210
@echo "==> Verifying snapshots"
./gradlew :app:screenshotsExecuteScreenshotTests -PdirectorySuffix=api35-low
@$(MAKE) kill-emulator
# ---------- 3) RECORD HIGH-RES PLAY STORE SHOTS ----------
.PHONY: playstore-record
playstore-record: check-no-devices ensure-avd-shot-api35-hi boot-and-prep-shot-api35-hi
@echo "==> Setting high-res display for Play Store (1080x2340 @ 420dpi)"
adb shell wm size 1080x2340
adb shell wm density 420
@echo "==> Cleaning up any old screenshots"
# On the emulator, restart adbd as root otherwise the rm can fail
adb root >/dev/null 2>&1 || true
adb wait-for-device
# Now raw deletes are reliable
adb shell rm -rf /sdcard/Pictures/TrackAndGraphScreenshots/ || true
@echo "==> Running promo captures"
./gradlew :app:connectedPromoAndroidTest -PusePromoTests=true -Pandroid.testInstrumentationRunnerArguments.class=com.samco.trackandgraph.promo.PromoScreenshots
# Wait a moment to ensure all files are written
@sleep 0.3
@echo "==> Pulling screenshots from device and copying to Fastlane phoneScreenshots"
mkdir -p tmp/device_screenshots
mkdir -p fastlane/metadata/android/en-GB/images/phoneScreenshots
# Pull screenshots from device
adb pull /sdcard/Pictures/TrackAndGraphScreenshots/ tmp/device_screenshots/
# Rename and copy to fastlane directory with language suffix
mv tmp/device_screenshots/TrackAndGraphScreenshots/1.png fastlane/metadata/android/en-GB/images/phoneScreenshots/1_en-GB.png
mv tmp/device_screenshots/TrackAndGraphScreenshots/2.png fastlane/metadata/android/en-GB/images/phoneScreenshots/2_en-GB.png
mv tmp/device_screenshots/TrackAndGraphScreenshots/3.png fastlane/metadata/android/en-GB/images/phoneScreenshots/3_en-GB.png
mv tmp/device_screenshots/TrackAndGraphScreenshots/4.png fastlane/metadata/android/en-GB/images/phoneScreenshots/4_en-GB.png
mv tmp/device_screenshots/TrackAndGraphScreenshots/5.png fastlane/metadata/android/en-GB/images/phoneScreenshots/5_en-GB.png
mv tmp/device_screenshots/TrackAndGraphScreenshots/6.png fastlane/metadata/android/en-GB/images/phoneScreenshots/6_en-GB.png
mv tmp/device_screenshots/TrackAndGraphScreenshots/7.png fastlane/metadata/android/en-GB/images/phoneScreenshots/7_en-GB.png
mv tmp/device_screenshots/TrackAndGraphScreenshots/8.png fastlane/metadata/android/en-GB/images/phoneScreenshots/8_en-GB.png
@$(MAKE) kill-emulator
# ---------- 4) RECORD TUTORIAL IMAGES FOR APP ----------
.PHONY: tutorial-record
tutorial-record: check-no-devices ensure-avd-shot-api35-hi boot-and-prep-shot-api35-hi
@echo "==> Setting high-res display for tutorial capture (1080x2340 @ 420dpi)"
adb shell wm size 1080x2340
adb shell wm density 420
@echo "==> Cleaning up any old tutorial screenshots"
# On the emulator, restart adbd as root otherwise the rm can fail
adb root >/dev/null 2>&1 || true
adb wait-for-device
# Now raw deletes are reliable
adb shell rm -rf /sdcard/Pictures/TutorialScreenshots/ || true
@echo "==> Running tutorial captures"
./gradlew :app:connectedPromoAndroidTest -PusePromoTests=true -Pandroid.testInstrumentationRunnerArguments.class=com.samco.trackandgraph.tutorial.TutorialScreenshots
# Wait a moment to ensure all files are written
@sleep 0.3
@echo "==> Pulling tutorial screenshots from device and processing with ImageMagick"
rm -rf tmp/tutorial_screenshots
mkdir -p tmp/tutorial_screenshots
mkdir -p app/src/main/res/drawable-mdpi
mkdir -p app/src/main/res/drawable-hdpi
mkdir -p app/src/main/res/drawable-xhdpi
mkdir -p app/src/main/res/drawable-xxhdpi
mkdir -p app/src/main/res/drawable-xxxhdpi
# Pull screenshots from device
adb pull /sdcard/Pictures/TutorialScreenshots tmp/tutorial_screenshots/
@echo "==> Converting screenshots to optimal sizes for each density bucket"
# Convert tutorial_1.png to tutorial_image_1.png for all densities
# Source: 1080x2340 emulator capture - optimized for API 24 memory constraints
# mdpi (25% of emulator): ~270x585 pixels, 0.6MB memory - safe for low-end devices
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_1.png -resize 25% app/src/main/res/drawable-mdpi/tutorial_image_1.png
# hdpi (35% of emulator): ~378x819 pixels, 1.2MB memory - balanced size/quality
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_1.png -resize 35% app/src/main/res/drawable-hdpi/tutorial_image_1.png
# xhdpi (50% of emulator): ~540x1170 pixels, 2.5MB memory - good quality, API 24 safe
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_1.png -resize 50% app/src/main/res/drawable-xhdpi/tutorial_image_1.png
# xxhdpi (75% of emulator): ~810x1755 pixels, 5.7MB memory - high-end devices
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_1.png -resize 75% app/src/main/res/drawable-xxhdpi/tutorial_image_1.png
# xxxhdpi (100% of emulator): 1080x2340 pixels, 10.1MB memory - flagship devices with lots of RAM
cp tmp/tutorial_screenshots/TutorialScreenshots/tutorial_1.png app/src/main/res/drawable-xxxhdpi/tutorial_image_1.png
# Convert tutorial_2.png to tutorial_image_2.png for all densities
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_2.png -resize 25% app/src/main/res/drawable-mdpi/tutorial_image_2.png
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_2.png -resize 35% app/src/main/res/drawable-hdpi/tutorial_image_2.png
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_2.png -resize 50% app/src/main/res/drawable-xhdpi/tutorial_image_2.png
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_2.png -resize 75% app/src/main/res/drawable-xxhdpi/tutorial_image_2.png
cp tmp/tutorial_screenshots/TutorialScreenshots/tutorial_2.png app/src/main/res/drawable-xxxhdpi/tutorial_image_2.png
# Convert tutorial_3.png to tutorial_image_3.png for all densities
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_3.png -resize 25% app/src/main/res/drawable-mdpi/tutorial_image_3.png
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_3.png -resize 35% app/src/main/res/drawable-hdpi/tutorial_image_3.png
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_3.png -resize 50% app/src/main/res/drawable-xhdpi/tutorial_image_3.png
magick tmp/tutorial_screenshots/TutorialScreenshots/tutorial_3.png -resize 75% app/src/main/res/drawable-xxhdpi/tutorial_image_3.png
cp tmp/tutorial_screenshots/TutorialScreenshots/tutorial_3.png app/src/main/res/drawable-xxxhdpi/tutorial_image_3.png
@echo "==> Tutorial images generated successfully"
@$(MAKE) kill-emulator
.PHONY: changelog
changelog:
@lua scripts/new_changelog.lua
.PHONY: commit-version
commit-version:
@python3 scripts/commit_version_bump.py
.PHONY: github-release
github-release:
@python3 scripts/create_release.py