Something went wrong. Try again.
A fork of the Cocoon PDS but being made more distributed.
Something went wrong. Try again.
distributed-pds Makefile
2.2 kB · 82 lines
Makefile
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283SHELL = /bin/bash.SHELLFLAGS = -o pipefail -cGIT_TAG := $(shell git describe --tags --exact-match 2>/dev/null)GIT_COMMIT := $(shell git rev-parse --short=9 HEAD)VERSION := $(if $(GIT_TAG),$(GIT_TAG),dev-$(GIT_COMMIT))
# Build output directoryBUILD_DIR := dist
# Platforms to build forPLATFORMS := \ linux/amd64 \ linux/arm64 \ linux/arm \ darwin/amd64 \ darwin/arm64 \ windows/amd64 \ windows/arm64 \ freebsd/amd64 \ freebsd/arm64 \ openbsd/amd64 \ openbsd/arm64
.PHONY: helphelp: ## Print info about all commands @echo "Commands:" @echo @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[01;32m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: buildbuild: ## Build all executables go build -ldflags "-X main.Version=$(VERSION)" -o cocoon ./cmd/cocoon
.PHONY: build-releasebuild-all: ## Build binaries for all architectures @echo "Building for all architectures..." @mkdir -p $(BUILD_DIR) @$(foreach platform,$(PLATFORMS), \ $(eval OS := $(word 1,$(subst /, ,$(platform)))) \ $(eval ARCH := $(word 2,$(subst /, ,$(platform)))) \ $(eval EXT := $(if $(filter windows,$(OS)),.exe,)) \ $(eval OUTPUT := $(BUILD_DIR)/cocoon-$(VERSION)-$(OS)-$(ARCH)$(EXT)) \ echo "Building $(OS)/$(ARCH)..."; \ GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "-X main.Version=$(VERSION)" -o $(OUTPUT) ./cmd/cocoon && \ echo " ✓ $(OUTPUT)" || echo " ✗ Failed: $(OS)/$(ARCH)"; \ ) @echo "Done! Binaries are in $(BUILD_DIR)/"
.PHONY: clean-distclean-dist: ## Remove all built binaries rm -rf $(BUILD_DIR)
.PHONY: runrun: go build -ldflags "-X main.Version=dev-local" -o cocoon ./cmd/cocoon && ./cocoon run
.PHONY: allall: build
.PHONY: testtest: ## Run tests go clean -testcache && go test -v ./...
.PHONY: lintlint: ## Verify code style and run static checks go vet ./... test -z $(gofmt -l ./...)
.PHONY: fmtfmt: ## Run syntax re-formatting (modify in place) go fmt ./...
.PHONY: checkcheck: ## Compile everything, checking syntax (does not output binaries) go build ./...
.env: if [ ! -f ".env" ]; then cp example.dev.env .env; fi
.PHONY: docker-builddocker-build: docker build -t cocoon .