77 lines
2.0 KiB
Makefile
77 lines
2.0 KiB
Makefile
# Should be the same as upstream version in production
|
|
VERSION ?= dev
|
|
UBOOT_VERSION=v2026.01
|
|
|
|
# Target kube version
|
|
KUBE_VERSION ?= v1.35.0
|
|
|
|
GIT_REV := $(shell git rev-parse HEAD)
|
|
|
|
PACKAGES_DIR := packages
|
|
BIN_DIR := bin
|
|
OUT_DIR := out
|
|
|
|
UBOOT_TAR := $(PACKAGES_DIR)/uboot-$(UBOOT_VERSION).tar.gz
|
|
|
|
BUILDINFO_FILE := pkg/buildinfo/buildinfo_gen.go
|
|
CRD_PATHS := ./pkg/apis/...
|
|
|
|
$(PACKAGES_DIR):
|
|
mkdir -p $@
|
|
|
|
# Never cache this
|
|
.buildinfo:
|
|
@mkdir -p $(dir $(BUILDINFO_FILE))
|
|
@printf '%s\n' \
|
|
'package buildinfo' \
|
|
'' \
|
|
'const (' \
|
|
' Version = "$(VERSION)"' \
|
|
' KubeVersion = "$(KUBE_VERSION)"' \
|
|
' GitRevision = "$(GIT_REV)"' \
|
|
' Timestamp = "'$$(TZ=UTC date +%Y%m%d.%H%M%S)'"' \
|
|
')' \
|
|
> $(BUILDINFO_FILE)
|
|
|
|
$(UBOOT_TAR): | $(PACKAGES_DIR)
|
|
git clone --depth 1 --branch v2026.01 --filter=blob:none https://github.com/u-boot/u-boot.git $(OUT_DIR)/u-boot-$(UBOOT_VERSION)
|
|
tar -C "$(OUT_DIR)/u-boot-$(UBOOT_VERSION)" -zcf "$@" .
|
|
rm -rf $(OUT_DIR)/u-boot-$(UBOOT_VERSION)
|
|
test -f $@
|
|
|
|
uboot-tools: $(UBOOT_TAR)
|
|
docker buildx build --platform linux/arm64 \
|
|
-f docker/uboot-tools.Dockerfile \
|
|
--build-arg UBOOT_VERSION=$(UBOOT_VERSION) \
|
|
--build-arg UBOOT_TAR=$(UBOOT_TAR) \
|
|
--output type=local,dest=./$(OUT_DIR) .
|
|
|
|
build: .buildinfo
|
|
mkdir -p $(BIN_DIR) $(OUT_DIR)/crds
|
|
controller-gen crd paths=$(CRD_PATHS) output:crd:dir=$(OUT_DIR)/crds
|
|
GOOS=linux GOARCH=arm64 go build -o $(BIN_DIR)/ctl-linux-aarch64-$(VERSION) ./cmd/ctl
|
|
|
|
build-agent: build uboot-tools
|
|
docker build \
|
|
-f docker/ctl-agent.Dockerfile \
|
|
--platform=linux/arm64 \
|
|
--build-arg VERSION=$(VERSION) \
|
|
-t localhost/monok8s/control-agent:$(VERSION) .
|
|
|
|
build-local: .buildinfo
|
|
mkdir -p $(BIN_DIR)
|
|
go build -o $(BIN_DIR)/ctl-$(VERSION) ./cmd/ctl
|
|
|
|
run-agent:
|
|
go run -tags dev ./cmd/ctl agent --env-file ./out/cluster.env
|
|
|
|
clean:
|
|
-docker image rm localhost/monok8s/control-agent:$(VERSION)
|
|
rm -rf $(BIN_DIR) \
|
|
$(BUILDINFO_FILE) \
|
|
$(OUT_DIR)/crds
|
|
|
|
all: build build-agent build-local
|
|
|
|
.PHONY: clean all run .buildinfo build build-local build-agent uboot-tools
|