From 47f68e0f8ab26cec753df3114731e281f54f61ef Mon Sep 17 00:00:00 2001 From: wenzirui Date: Mon, 23 Mar 2026 16:36:04 +0800 Subject: [PATCH] feat(build): add Android build targets Enable cross-compiling the launcher and main binary for Android (arm64), and exclude desktop systray code from Android builds. --- Makefile | 18 ++++++++++++++++++ web/backend/systray.go | 2 +- web/backend/tray_stub_nocgo.go | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 411cd9dc5..e78cdd024 100644 --- a/Makefile +++ b/Makefile @@ -125,6 +125,17 @@ build-launcher: @ln -sf picoclaw-launcher-$(PLATFORM)-$(ARCH) $(BUILD_DIR)/picoclaw-launcher @echo "Build complete: $(BUILD_DIR)/picoclaw-launcher" +## build-launcher-android: Build picoclaw-launcher for Android ARM64 +build-launcher-android: + @echo "Building picoclaw-launcher for android/arm64..." + @mkdir -p $(BUILD_DIR) + @if [ ! -f web/backend/dist/index.html ]; then \ + echo "Building frontend..."; \ + cd web/frontend && pnpm install && pnpm build:backend; \ + fi + GOOS=android GOARCH=arm64 $(GO) build $(GOFLAGS) -o $(BUILD_DIR)/picoclaw-launcher-android-arm64 ./web/backend + @echo "Build complete: $(BUILD_DIR)/picoclaw-launcher-android-arm64" + ## build-whatsapp-native: Build with WhatsApp native (whatsmeow) support; larger binary build-whatsapp-native: generate ## @echo "Building $(BINARY_NAME) with WhatsApp native for $(PLATFORM)/$(ARCH)..." @@ -169,6 +180,13 @@ build-linux-mipsle: generate build-pi-zero: build-linux-arm build-linux-arm64 @echo "Pi Zero 2 W builds: $(BUILD_DIR)/$(BINARY_NAME)-linux-arm (32-bit), $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 (64-bit)" +## build-android-arm64: Build for Android ARM64 +build-android: generate + @echo "Building for android/arm64..." + @mkdir -p $(BUILD_DIR) + GOOS=android GOARCH=arm64 $(GO) build -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-android-arm64 ./$(CMD_DIR) + @echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)-android-arm64" + ## build-all: Build picoclaw for all platforms build-all: generate @echo "Building for multiple platforms..." diff --git a/web/backend/systray.go b/web/backend/systray.go index fde2e115e..39be44f63 100644 --- a/web/backend/systray.go +++ b/web/backend/systray.go @@ -1,4 +1,4 @@ -//go:build (!darwin && !freebsd) || cgo +//go:build (!darwin && !freebsd && !android) || cgo package main diff --git a/web/backend/tray_stub_nocgo.go b/web/backend/tray_stub_nocgo.go index 13ecfd2cb..cbc53215e 100644 --- a/web/backend/tray_stub_nocgo.go +++ b/web/backend/tray_stub_nocgo.go @@ -1,4 +1,4 @@ -//go:build (darwin || freebsd) && !cgo +//go:build (darwin || freebsd || android) && !cgo package main