diff --git a/Makefile b/Makefile index f3a3a17..15dfc63 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ .PHONY: android desktop android-usb android-emulator ADB := $(shell command -v adb 2>/dev/null || echo "$(HOME)/Library/Android/sdk/platform-tools/adb") +EMULATOR := $(shell command -v emulator 2>/dev/null || echo "$(HOME)/Library/Android/sdk/emulator/emulator") +AVD := $(firstword $(shell $(EMULATOR) -list-avds 2>/dev/null)) APK := composeApp/build/outputs/apk/debug/composeApp-debug.apk android: @@ -13,4 +15,15 @@ android-usb: android $(ADB) -d install -r $(APK) android-emulator: android + @if ! $(ADB) devices | grep -q '^emulator'; then \ + echo "Aucun émulateur en cours — lancement de $(AVD)…"; \ + $(EMULATOR) -avd $(AVD) -no-snapshot-load >/dev/null 2>&1 & \ + echo "En attente du démarrage…"; \ + $(ADB) -e wait-for-device; \ + while [ "$$($(ADB) -e shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')" != "1" ]; do \ + sleep 2; \ + done; \ + echo "Émulateur prêt."; \ + fi $(ADB) -e install -r $(APK) + $(ADB) -e shell am start -n ch.parano.myicek/.MainActivity