From 080f532d825a4585b8030dce1ec14ef803a477c1 Mon Sep 17 00:00:00 2001 From: sky5454 Date: Sun, 12 Apr 2026 17:41:10 +0800 Subject: [PATCH 1/3] build: add Android arm64 cross-compile support - Add build-android-arm64, build-launcher-android-arm64, build-all-android targets to Makefile and web/Makefile - Use -tags stdjson (no goolm) for Android; CGO_ENABLED=0 throughout - Output staged as build/android-staging/arm64-v8a/libpicoclaw{,-web}.so for JNI consumption; zip packaging handled by CI - Exclude Matrix channel from android builds (channel_matrix.go) to avoid modernc.org/sqlite CGO dependency - Exclude systray from android builds; use headless stub instead (systray.go / systray_stub_nocgo.go) --- Makefile | 34 +++++++++++++++++++++++++++++++ pkg/gateway/channel_matrix.go | 2 +- web/Makefile | 15 +++++++++++++- web/backend/systray.go | 2 +- web/backend/systray_stub_nocgo.go | 2 +- 5 files changed, 51 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f7ebc7411..ef0dcd9b1 100644 --- a/Makefile +++ b/Makefile @@ -205,6 +205,40 @@ build-linux-mipsle: generate $(call PATCH_MIPS_FLAGS,$(BUILD_DIR)/$(BINARY_NAME)-linux-mipsle) @echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)-linux-mipsle" +## build-android-arm64: Build core for Android ARM64 +build-android-arm64: generate + @echo "Building for android/arm64..." + @mkdir -p $(BUILD_DIR) + GOOS=android GOARCH=arm64 $(GO) build -tags stdjson -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-android-arm64 ./$(CMD_DIR) + @echo "Build complete: $(BUILD_DIR)/$(BINARY_NAME)-android-arm64" + +## build-launcher-android-arm64: Build launcher for Android ARM64 +build-launcher-android-arm64: + @echo "Building picoclaw-launcher for android/arm64..." + @mkdir -p $(BUILD_DIR) + @$(MAKE) -C web build \ + OUTPUT="$(CURDIR)/$(BUILD_DIR)/picoclaw-launcher-android-arm64" \ + WEB_GO='GOOS=android GOARCH=arm64 CGO_ENABLED=0 go' \ + GO_BUILD_TAGS='stdjson' \ + LDFLAGS='$(LDFLAGS)' + @echo "Build complete: $(BUILD_DIR)/picoclaw-launcher-android-arm64" + +## build-all-android: Build core and launcher for all Android architectures and package as universal zip +build-all-android: generate + @echo "Building core for all Android architectures..." + @mkdir -p $(BUILD_DIR) + GOOS=android GOARCH=arm64 $(GO) build -tags stdjson -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-android-arm64 ./$(CMD_DIR) + @echo "Building launcher for Android arm64..." + @$(MAKE) build-launcher-android-arm64 + @echo "Staging JNI libs..." + @rm -rf $(BUILD_DIR)/android-staging + @mkdir -p $(BUILD_DIR)/android-staging/arm64-v8a + @cp $(BUILD_DIR)/$(BINARY_NAME)-android-arm64 $(BUILD_DIR)/android-staging/arm64-v8a/libpicoclaw.so + @cp $(BUILD_DIR)/picoclaw-launcher-android-arm64 $(BUILD_DIR)/android-staging/arm64-v8a/libpicoclaw-web.so + @cd $(BUILD_DIR)/android-staging && zip -r ../picoclaw-android-universal.zip . + @rm -rf $(BUILD_DIR)/android-staging + @echo "All Android builds complete: $(BUILD_DIR)/picoclaw-android-universal.zip" + ## build-pi-zero: Build for Raspberry Pi Zero 2 W (32-bit and 64-bit) 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)" diff --git a/pkg/gateway/channel_matrix.go b/pkg/gateway/channel_matrix.go index a46addae1..b6adbe498 100644 --- a/pkg/gateway/channel_matrix.go +++ b/pkg/gateway/channel_matrix.go @@ -1,4 +1,4 @@ -//go:build !mipsle && !netbsd && !(freebsd && arm) +//go:build !mipsle && !netbsd && !(freebsd && arm) && !android package gateway diff --git a/web/Makefile b/web/Makefile index 891c170c2..58b65621d 100644 --- a/web/Makefile +++ b/web/Makefile @@ -1,4 +1,5 @@ -.PHONY: dev dev-frontend dev-backend build build-frontend build-dev-picoclaw test lint clean +.PHONY: dev dev-frontend dev-backend build build-frontend build-dev-picoclaw test lint clean \ + build-android-arm64 build-all-android # Go variables GO?=CGO_ENABLED=0 go @@ -9,6 +10,7 @@ GOFLAGS?=-v -tags $(GO_BUILD_TAGS) # Build variables BUILD_DIR=build OUTPUT?=$(BUILD_DIR)/picoclaw-launcher +OUTPUT_ANDROID_ARM64?=$(BUILD_DIR)/picoclaw-launcher-android-arm64 FRONTEND_DIR=frontend BACKEND_DIR=backend BACKEND_DIST=$(BACKEND_DIR)/dist @@ -91,6 +93,17 @@ build: build-frontend @mkdir -p "$$(dirname "$(OUTPUT)")" ${WEB_GO} build $(GOFLAGS) -ldflags "$(LAUNCHER_LDFLAGS)" -o "$(OUTPUT)" ./$(BACKEND_DIR)/ +# Build launcher for Android ARM64 (frontend must already be built) +build-android-arm64: build-frontend + @mkdir -p $(BUILD_DIR) + GOOS=android GOARCH=arm64 $(GO) build -tags stdjson -ldflags "$(LDFLAGS)" -o "$(OUTPUT_ANDROID_ARM64)" ./$(BACKEND_DIR)/ + +# Build launcher for all Android architectures +build-all-android: build-frontend + @mkdir -p $(BUILD_DIR) + GOOS=android GOARCH=arm64 $(GO) build -tags stdjson -ldflags "$(LDFLAGS)" -o "$(BUILD_DIR)/picoclaw-launcher-android-arm64" ./$(BACKEND_DIR)/ + @echo "All Android launcher builds complete" + build-frontend: @if [ ! -d $(FRONTEND_DIR)/node_modules ] || \ [ $(FRONTEND_DIR)/package.json -nt $(FRONTEND_DIR)/node_modules ] || \ diff --git a/web/backend/systray.go b/web/backend/systray.go index 9dcc025df..204bd7dc6 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/systray_stub_nocgo.go b/web/backend/systray_stub_nocgo.go index 9e75e112a..41514feef 100644 --- a/web/backend/systray_stub_nocgo.go +++ b/web/backend/systray_stub_nocgo.go @@ -1,4 +1,4 @@ -//go:build (darwin || freebsd) && !cgo +//go:build (darwin || freebsd || android) && !cgo package main From 168b6bec5817e4b214e3be2596beb94fe8f07715 Mon Sep 17 00:00:00 2001 From: sky5454 Date: Sun, 12 Apr 2026 18:35:05 +0800 Subject: [PATCH 2/3] build(android): ci build added --- .github/workflows/release.yml | 11 +++++++++++ Makefile | 1 + 2 files changed, 12 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ce341770..03c7ce7d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,6 +110,17 @@ jobs: MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }} MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }} + - name: Build and upload Android arm64 + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + sudo apt-get install -y zip + make build-all-android + gh release upload "${{ inputs.tag }}" \ + build/picoclaw-android-universal.zip \ + --clobber + - name: Apply release flags shell: bash env: diff --git a/Makefile b/Makefile index ef0dcd9b1..1cc853458 100644 --- a/Makefile +++ b/Makefile @@ -260,6 +260,7 @@ build-all: generate GOOS=windows GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./$(CMD_DIR) GOOS=netbsd GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-netbsd-amd64 ./$(CMD_DIR) GOOS=netbsd GOARCH=arm64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-netbsd-arm64 ./$(CMD_DIR) + @$(MAKE) build-all-android @echo "All builds complete" ## install: Install picoclaw to system and copy builtin skills From 681b2a258b727102f8d89e27ed58b051d363072e Mon Sep 17 00:00:00 2001 From: sky5454 Date: Sun, 12 Apr 2026 18:50:52 +0800 Subject: [PATCH 3/3] =?UTF-8?q?build:=20address=20PR=20review=20=E2=80=94?= =?UTF-8?q?=20fix=20Android=20launcher=20flags,=20systray=20tag,=20rename?= =?UTF-8?q?=20target?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 2 +- Makefile | 13 +++++-------- web/Makefile | 4 ++-- web/backend/systray.go | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03c7ce7d8..aab9cf874 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -116,7 +116,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | sudo apt-get install -y zip - make build-all-android + make build-android-bundle gh release upload "${{ inputs.tag }}" \ build/picoclaw-android-universal.zip \ --clobber diff --git a/Makefile b/Makefile index 1cc853458..beddd1138 100644 --- a/Makefile +++ b/Makefile @@ -216,15 +216,12 @@ build-android-arm64: generate build-launcher-android-arm64: @echo "Building picoclaw-launcher for android/arm64..." @mkdir -p $(BUILD_DIR) - @$(MAKE) -C web build \ - OUTPUT="$(CURDIR)/$(BUILD_DIR)/picoclaw-launcher-android-arm64" \ - WEB_GO='GOOS=android GOARCH=arm64 CGO_ENABLED=0 go' \ - GO_BUILD_TAGS='stdjson' \ - LDFLAGS='$(LDFLAGS)' + @$(MAKE) -C web build-android-arm64 \ + OUTPUT="$(CURDIR)/$(BUILD_DIR)/picoclaw-launcher-android-arm64" @echo "Build complete: $(BUILD_DIR)/picoclaw-launcher-android-arm64" -## build-all-android: Build core and launcher for all Android architectures and package as universal zip -build-all-android: generate +## build-android-bundle: Build core and launcher for all Android architectures and package as universal zip +build-android-bundle: generate @echo "Building core for all Android architectures..." @mkdir -p $(BUILD_DIR) GOOS=android GOARCH=arm64 $(GO) build -tags stdjson -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-android-arm64 ./$(CMD_DIR) @@ -260,7 +257,7 @@ build-all: generate GOOS=windows GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./$(CMD_DIR) GOOS=netbsd GOARCH=amd64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-netbsd-amd64 ./$(CMD_DIR) GOOS=netbsd GOARCH=arm64 $(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-netbsd-arm64 ./$(CMD_DIR) - @$(MAKE) build-all-android + @$(MAKE) build-android-bundle @echo "All builds complete" ## install: Install picoclaw to system and copy builtin skills diff --git a/web/Makefile b/web/Makefile index 58b65621d..cf5ea774a 100644 --- a/web/Makefile +++ b/web/Makefile @@ -1,5 +1,5 @@ .PHONY: dev dev-frontend dev-backend build build-frontend build-dev-picoclaw test lint clean \ - build-android-arm64 build-all-android + build-android-arm64 build-android-bundle # Go variables GO?=CGO_ENABLED=0 go @@ -99,7 +99,7 @@ build-android-arm64: build-frontend GOOS=android GOARCH=arm64 $(GO) build -tags stdjson -ldflags "$(LDFLAGS)" -o "$(OUTPUT_ANDROID_ARM64)" ./$(BACKEND_DIR)/ # Build launcher for all Android architectures -build-all-android: build-frontend +build-android-bundle: build-frontend @mkdir -p $(BUILD_DIR) GOOS=android GOARCH=arm64 $(GO) build -tags stdjson -ldflags "$(LDFLAGS)" -o "$(BUILD_DIR)/picoclaw-launcher-android-arm64" ./$(BACKEND_DIR)/ @echo "All Android launcher builds complete" diff --git a/web/backend/systray.go b/web/backend/systray.go index 204bd7dc6..41fea1fbe 100644 --- a/web/backend/systray.go +++ b/web/backend/systray.go @@ -1,4 +1,4 @@ -//go:build (!darwin && !freebsd && !android) || cgo +//go:build !android && ((!darwin && !freebsd) || cgo) package main