Add multiarch build setup and build documentation
- Add `make setup` target to register qemu and create a multiplatform buildx builder for universal (x86_64 + aarch64) packages - Use named builder with --progress=plain to avoid flickering output - Conditionally depend on arch-specific Docker tars so single-arch builds don't require the other image - Document prerequisites, build targets, and overrides in README
This commit is contained in:
@@ -6,13 +6,16 @@ TS_FILES := $(shell find ./scripts -name \*.ts 2>/dev/null)
|
||||
# Where KamadoPool source lives (buildx passes it as a named context).
|
||||
KAMADO_SRC ?= ../KamadoPool
|
||||
|
||||
# Buildx builder name. Must support linux/amd64 and linux/arm64.
|
||||
BUILDER ?= kamado-multiarch
|
||||
|
||||
.DELETE_ON_ERROR:
|
||||
|
||||
# Default: build both arches and verify a universal package.
|
||||
all: verify
|
||||
|
||||
# Single-arch convenience targets — much faster if you don't have
|
||||
# qemu-user-static registered for cross-arch emulation.
|
||||
# Single-arch convenience targets — much faster when you don't need
|
||||
# cross-arch emulation.
|
||||
x86: ARCH = x86_64
|
||||
x86:
|
||||
@rm -f docker-images/aarch64.tar
|
||||
@@ -23,6 +26,14 @@ arm:
|
||||
@rm -f docker-images/x86_64.tar
|
||||
$(MAKE) ARCH=aarch64
|
||||
|
||||
# Register qemu for cross-arch builds and create a multiplatform builder.
|
||||
setup:
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
-docker buildx rm $(BUILDER) 2>/dev/null
|
||||
docker buildx create --name $(BUILDER) --platform linux/amd64,linux/arm64 --use
|
||||
docker buildx inspect --bootstrap $(BUILDER)
|
||||
@echo "Ready. 'make' will now build universal packages."
|
||||
|
||||
verify: $(PKG_ID).s9pk
|
||||
start-sdk verify s9pk $(PKG_ID).s9pk
|
||||
@echo "Package: $(PKG_ID).s9pk ($(shell du -h $(PKG_ID).s9pk | cut -f1))"
|
||||
@@ -38,7 +49,7 @@ scripts/embassy.js: $(TS_FILES)
|
||||
docker-images/x86_64.tar: Dockerfile docker_entrypoint.sh
|
||||
ifneq ($(ARCH),aarch64)
|
||||
mkdir -p docker-images
|
||||
docker buildx build \
|
||||
docker buildx build --builder $(BUILDER) --progress=plain \
|
||||
--tag start9/$(PKG_ID)/main:$(PKG_VERSION) \
|
||||
--platform linux/amd64 \
|
||||
--build-arg ARCH=x86_64 \
|
||||
@@ -50,7 +61,7 @@ endif
|
||||
docker-images/aarch64.tar: Dockerfile docker_entrypoint.sh
|
||||
ifneq ($(ARCH),x86_64)
|
||||
mkdir -p docker-images
|
||||
docker buildx build \
|
||||
docker buildx build --builder $(BUILDER) --progress=plain \
|
||||
--tag start9/$(PKG_ID)/main:$(PKG_VERSION) \
|
||||
--platform linux/arm64 \
|
||||
--build-arg ARCH=aarch64 \
|
||||
@@ -60,9 +71,17 @@ ifneq ($(ARCH),x86_64)
|
||||
endif
|
||||
|
||||
# ── Pack ─────────────────────────────────────────────────────────────
|
||||
ifeq ($(ARCH),x86_64)
|
||||
DOCKER_DEPS := docker-images/x86_64.tar
|
||||
else ifeq ($(ARCH),aarch64)
|
||||
DOCKER_DEPS := docker-images/aarch64.tar
|
||||
else
|
||||
DOCKER_DEPS := docker-images/x86_64.tar docker-images/aarch64.tar
|
||||
endif
|
||||
|
||||
$(PKG_ID).s9pk: manifest.yaml instructions.md icon.png LICENSE \
|
||||
scripts/embassy.js \
|
||||
docker-images/x86_64.tar docker-images/aarch64.tar
|
||||
$(DOCKER_DEPS)
|
||||
ifeq ($(ARCH),x86_64)
|
||||
@echo "start-sdk: packing x86_64 only"
|
||||
else ifeq ($(ARCH),aarch64)
|
||||
@@ -76,4 +95,4 @@ clean:
|
||||
rm -rf docker-images
|
||||
rm -f $(PKG_ID).s9pk image.tar scripts/embassy.js
|
||||
|
||||
.PHONY: all x86 arm verify install clean
|
||||
.PHONY: all x86 arm verify install clean setup
|
||||
|
||||
Reference in New Issue
Block a user