feat(make): add install-android-app target and default help listing

- add `help` target and make it the default goal (bare `make` lists targets)
- add `install-android-app`: build debug APK and install on the selected device
- device selection via SERIAL/$ANDROID_SERIAL; several devices list and stop
- document the target in android/README.md
This commit is contained in:
iu
2026-10-13 12:06:34 +03:00
parent 43f5520236
commit d9f6a163e5
6 changed files with 172 additions and 1 deletions
+41 -1
View File
@@ -1,8 +1,19 @@
.PHONY: build build-release frontend backend android run migrate reconcile reconcile-delete tidy test testdata clean
.PHONY: help build build-release frontend backend android install-android-app run migrate reconcile reconcile-delete tidy test testdata clean
# Default goal: print the list of available targets.
.DEFAULT_GOAL := help
# Android SDK location. Override when the SDK lives elsewhere.
ANDROID_SDK ?= $(HOME)/Android/sdk
# adb from the Android SDK's platform-tools (matches the SDK we build against).
ADB ?= $(ANDROID_SDK)/platform-tools/adb
# Device serial for `install-android-app` (falls back to $ANDROID_SERIAL). When
# empty, the sole connected device is used; with several connected devices the
# target lists them and stops instead of guessing. Override with SERIAL=<serial>.
SERIAL ?= $(ANDROID_SERIAL)
# Release version stamped into the binary (-X main.version). Override with VERSION=...
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
@@ -14,6 +25,13 @@ PHOTOS ?= 10
SEED ?= 0
TIMEOUT ?= 30
# Print the list of available targets.
help:
@echo "Usage: make <target>"
@echo
@echo "Available targets:"
@grep -hE '^[a-zA-Z0-9_-]+:' $(MAKEFILE_LIST) | cut -d: -f1 | sed 's/^/ /'
frontend:
cd frontend && npm ci && npm run build
rm -rf backend/static/*
@@ -32,6 +50,28 @@ build: frontend backend
android:
cd android && ANDROID_HOME=$(ANDROID_SDK) ./gradlew :app:assembleDebug
# Install the debug Android client on a connected device. Builds the APK via the
# `android` target first; only devices in the `device` state are considered.
install-android-app: android
@devices="$$($(ADB) devices | awk 'NR>1 && $$2 == "device" {print $$1}')"; \
if [ -n "$(SERIAL)" ]; then \
target="$(SERIAL)"; \
else \
count=$$(printf '%s\n' "$$devices" | grep -c .); \
if [ "$$count" -eq 0 ]; then \
echo "install-android-app: no connected device (see '$(ADB) devices')" >&2; \
exit 1; \
elif [ "$$count" -gt 1 ]; then \
echo "install-android-app: several devices connected; set SERIAL=<serial>:" >&2; \
printf '%s\n' "$$devices" | sed 's/^/ /' >&2; \
exit 1; \
else \
target="$$devices"; \
fi; \
fi; \
echo "Installing app-debug.apk on $$target"; \
$(ADB) -s "$$target" install -r android/app/build/outputs/apk/debug/app-debug.apk
# Release build: full static, stripped and (if available) UPX-compressed binary
# with the version embedded. Produces bin/galo and a copy at bin/galo-$(VERSION).
build-release: frontend