|
72 | 72 | export PATH := $(JAVA_HOME)/bin:$(PATH)
|
73 | 73 | endif
|
74 | 74 |
|
| 75 | +AVD_BASE_IMAGE := "system-images;android-33;google_apis;" |
| 76 | +export HOST_ARCH=$(shell uname -m) |
| 77 | +ifeq ($(HOST_ARCH),aarch64) |
| 78 | + AVD_IMAGE := "$(AVD_BASE_IMAGE)arm64-v8a" |
| 79 | +else ifeq ($(HOST_ARCH),arm64) |
| 80 | + AVD_IMAGE := "$(AVD_BASE_IMAGE)arm64-v8a" |
| 81 | +else |
| 82 | + AVD_IMAGE := "$(AVD_BASE_IMAGE)x86_64" |
| 83 | +endif |
| 84 | +AVD ?= tailscale-$(HOST_ARCH) |
| 85 | +export AVD_IMAGE |
| 86 | +export AVD |
| 87 | + |
75 | 88 | # TOOLCHAINDIR is set by fdoid CI and used by tool/* scripts.
|
76 | 89 | TOOLCHAINDIR ?=
|
77 | 90 | export TOOLCHAINDIR
|
|
160 | 173 | @echo ANDROID_STUDIO_ROOT=$(ANDROID_STUDIO_ROOT)
|
161 | 174 | @echo JAVA_HOME=$(JAVA_HOME)
|
162 | 175 | @echo TOOLCHAINDIR=$(TOOLCHAINDIR)
|
| 176 | + @echo AVD_IMAGE="$(AVD_IMAGE)" |
163 | 177 |
|
164 | 178 | # Ensure that JKS_PATH and JKS_PASSWORD are set before we attempt a build
|
165 | 179 | # that requires signing.
|
@@ -238,6 +252,21 @@ checkandroidsdk: ## Check that Android SDK is installed
|
238 | 252 | test: gradle-dependencies ## Run the Android tests
|
239 | 253 | (cd android && ./gradlew test)
|
240 | 254 |
|
| 255 | +.PHONY: emulator |
| 256 | +emulator: ## Start an android emulator instance |
| 257 | + @echo "Checking installed SDK packages..." |
| 258 | + @if ! $(ANDROID_HOME)/cmdline-tools/latest/bin/sdkmanager --list_installed | grep -q "$(AVD_IMAGE)"; then \ |
| 259 | + echo "$(AVD_IMAGE) not found, installing..."; \ |
| 260 | + $(ANDROID_HOME)/cmdline-tools/latest/bin/sdkmanager "$(AVD_IMAGE)"; \ |
| 261 | + fi |
| 262 | + @echo "Checking if AVD exists..." |
| 263 | + @if ! $(ANDROID_HOME)/cmdline-tools/latest/bin/avdmanager list avd | grep -q "$(AVD)"; then \ |
| 264 | + echo "AVD $(AVD) not found, creating..."; \ |
| 265 | + $(ANDROID_HOME)/cmdline-tools/latest/bin/avdmanager create avd -n "$(AVD)" -k "$(AVD_IMAGE)"; \ |
| 266 | + fi |
| 267 | + @echo "Starting emulator..." |
| 268 | + @$(ANDROID_HOME)/emulator/emulator -avd "$(AVD)" -logcat-output /dev/stdout -netdelay none -netspeed full |
| 269 | + |
241 | 270 | .PHONY: install
|
242 | 271 | install: $(DEBUG_APK) ## Install the debug APK on a connected device
|
243 | 272 | adb install -r $<
|
@@ -278,7 +307,7 @@ docker-remove-shell-image: ## Removes all docker shell image
|
278 | 307 | clean: ## Remove build artifacts. Does not purge docker build envs. Use dockerRemoveEnv for that.
|
279 | 308 | clean: ## Remove build artifacts. Does not purge docker build envs. Use dockerRemoveEnv for that.
|
280 | 309 | @echo "Cleaning up old build artifacts"
|
281 |
| - -rm -rf android/build $(DEBUG_APK) $(RELEASE_AAB) $(RELEASE_TV_AAB) $(LIBTAILSCALE) android/libs *.apk *.aab |
| 310 | + -rm -rf android/build $(DEBUG_APK) $(RELEASE_AAB) $(RELEASE_TV_AAB) $(LIBTAILSCALE) android/libs *.apk *.aab |
282 | 311 | @echo "Cleaning cached toolchain"
|
283 | 312 | -rm -rf $(HOME)/.cache/tailscale-go
|
284 | 313 | -pkill -f gradle
|
|
0 commit comments