-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (38 loc) · 1.78 KB
/
Copy pathMakefile
File metadata and controls
54 lines (38 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
.DEFAULT_GOAL := help
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
VERSION ?= dev
LDFLAGS = -ldflags "-X github.com/mozilla/markfluence/internal/buildinfo.Version=$(VERSION)"
GOLANGCI_LINT_VERSION ?= v2.6.0
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
.PHONY: help all build build-linux install lint vet fmt fmt-check test regen-regressions
help: ## Show this help
@echo "Available rules:"
@grep -F -h "##" Makefile | grep -F -v grep | sed 's/\(.*\):.*##/\1: /'
all: build
build: $(LOCALBIN) ## Build the markfluence binary into ./bin
go build $(LDFLAGS) -o $(LOCALBIN)/markfluence .
build-linux: $(LOCALBIN) ## Cross-compile a linux/amd64 binary into ./bin
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(LDFLAGS) -o $(LOCALBIN)/markfluence-linux-amd64 .
install: ## Install the markfluence binary
go install $(LDFLAGS) .
lint: $(GOLANGCI_LINT) ## Lint with golangci-lint
$(GOLANGCI_LINT) run
vet: ## Run go vet
go vet ./...
fmt: ## Format Go files
go fmt ./...
fmt-check: ## Check formatting without modifying files (fails if any file needs gofmt)
@out="$$(gofmt -l .)"; if [ -n "$$out" ]; then \
echo "These files are not gofmt'd:"; echo "$$out"; exit 1; fi
test: ## Run tests
go test ./...
regen-regressions: ## Regenerate the converter regression goldens
go test ./internal/convert -run TestRegression -update
# golangci-lint (version/path defined near the top so `lint` can depend on it).
# Order-only dependency on $(LOCALBIN) so adding files to bin/ (e.g. `make
# build`) doesn't retrigger the install. Installs the versioned binary once.
$(GOLANGCI_LINT): | $(LOCALBIN)
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
mv $(LOCALBIN)/golangci-lint $(GOLANGCI_LINT)