An atproto PDS written in Go
at list 2.2 kB view raw
1SHELL = /bin/bash 2.SHELLFLAGS = -o pipefail -c 3GIT_TAG := $(shell git describe --tags --exact-match 2>/dev/null) 4GIT_COMMIT := $(shell git rev-parse --short=9 HEAD) 5VERSION := $(if $(GIT_TAG),$(GIT_TAG),dev-$(GIT_COMMIT)) 6 7# Build output directory 8BUILD_DIR := dist 9 10# Platforms to build for 11PLATFORMS := \ 12 linux/amd64 \ 13 linux/arm64 \ 14 linux/arm \ 15 darwin/amd64 \ 16 darwin/arm64 \ 17 windows/amd64 \ 18 windows/arm64 \ 19 freebsd/amd64 \ 20 freebsd/arm64 \ 21 openbsd/amd64 \ 22 openbsd/arm64 23 24.PHONY: help 25help: ## Print info about all commands 26 @echo "Commands:" 27 @echo 28 @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[01;32m%-20s\033[0m %s\n", $$1, $$2}' 29 30.PHONY: build 31build: ## Build all executables 32 go build -ldflags "-X main.Version=$(VERSION)" -o cocoon ./cmd/cocoon 33 34.PHONY: build-release 35build-all: ## Build binaries for all architectures 36 @echo "Building for all architectures..." 37 @mkdir -p $(BUILD_DIR) 38 @$(foreach platform,$(PLATFORMS), \ 39 $(eval OS := $(word 1,$(subst /, ,$(platform)))) \ 40 $(eval ARCH := $(word 2,$(subst /, ,$(platform)))) \ 41 $(eval EXT := $(if $(filter windows,$(OS)),.exe,)) \ 42 $(eval OUTPUT := $(BUILD_DIR)/cocoon-$(VERSION)-$(OS)-$(ARCH)$(EXT)) \ 43 echo "Building $(OS)/$(ARCH)..."; \ 44 GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "-X main.Version=$(VERSION)" -o $(OUTPUT) ./cmd/cocoon && \ 45 echo "$(OUTPUT)" || echo " ✗ Failed: $(OS)/$(ARCH)"; \ 46 ) 47 @echo "Done! Binaries are in $(BUILD_DIR)/" 48 49.PHONY: clean-dist 50clean-dist: ## Remove all built binaries 51 rm -rf $(BUILD_DIR) 52 53.PHONY: run 54run: 55 go build -ldflags "-X main.Version=dev-local" -o cocoon ./cmd/cocoon && ./cocoon run 56 57.PHONY: all 58all: build 59 60.PHONY: test 61test: ## Run tests 62 go clean -testcache && go test -v ./... 63 64.PHONY: lint 65lint: ## Verify code style and run static checks 66 go vet ./... 67 test -z $(gofmt -l ./...) 68 69.PHONY: fmt 70fmt: ## Run syntax re-formatting (modify in place) 71 go fmt ./... 72 73.PHONY: check 74check: ## Compile everything, checking syntax (does not output binaries) 75 go build ./... 76 77.env: 78 if [ ! -f ".env" ]; then cp example.dev.env .env; fi 79 80.PHONY: docker-build 81docker-build: 82 docker build -t cocoon .