-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (51 loc) · 1.39 KB
/
Copy pathMakefile
File metadata and controls
66 lines (51 loc) · 1.39 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
55
56
57
58
59
60
61
62
63
64
65
66
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo development)
MODULE := github.com/fhsinchy/tent
BINARY := tent
BINDIR := bin
BUILDTAGS := containers_image_openpgp
GOFLAGS := CGO_ENABLED=0
LDFLAGS := -ldflags="-s -w -X '$(MODULE)/cmd.version=$(VERSION)'"
TAGS := -tags $(BUILDTAGS)
.PHONY: build install clean vet lint fmt check test
## Build
build:
$(GOFLAGS) go build $(TAGS) $(LDFLAGS) -o $(BINDIR)/$(BINARY)
install:
$(GOFLAGS) go install $(TAGS) $(LDFLAGS)
clean:
rm -rf $(BINDIR)
## Quality
vet:
$(GOFLAGS) go vet $(TAGS) ./...
fmt:
gofmt -s -w .
lint: vet
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run; \
else \
echo "golangci-lint not installed, skipping"; \
fi
test:
$(GOFLAGS) go test $(TAGS) ./...
check: fmt vet lint test
## Helpers
tidy:
go mod tidy
help:
@echo "Usage: make [target]"
@echo ""
@echo "Build:"
@echo " build Build binary to $(BINDIR)/$(BINARY)"
@echo " install Install binary via go install"
@echo " clean Remove build artifacts"
@echo ""
@echo "Quality:"
@echo " vet Run go vet"
@echo " fmt Format code with gofmt"
@echo " lint Run vet + golangci-lint (if installed)"
@echo " test Run tests"
@echo " check Run fmt + vet + lint + test"
@echo ""
@echo "Helpers:"
@echo " tidy Run go mod tidy"
@echo " help Show this help"