-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (45 loc) · 2.26 KB
/
Makefile
File metadata and controls
58 lines (45 loc) · 2.26 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
VERSION ?= $(shell git describe --tags --always 2>/dev/null || echo dev)
BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
GO_VERSION ?= $(shell go version | cut -d' ' -f3)
LDFLAGS := -s -w -X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME) -X main.goVersion=$(GO_VERSION)
.PHONY: build webui test bench fuzz lint docker clean cross install
# Build frontend then Go binary
build: webui
go build -ldflags="$(LDFLAGS)" -o labyrinth .
# Build Go binary only (skip frontend)
build-go:
go build -ldflags="$(LDFLAGS)" -o labyrinth .
# Build React frontend
webui:
cd web/ui && npm ci --silent && npm run build
test:
go test ./... -v -count=1 -timeout 120s
bench:
go test ./... -bench=. -benchmem -run='^$$' -timeout 120s
fuzz:
go test ./dns/ -fuzz=FuzzUnpack -fuzztime=60s
go test ./dns/ -fuzz=FuzzDecodeName -fuzztime=60s
lint:
go vet ./...
@which staticcheck > /dev/null 2>&1 && staticcheck ./... || echo "staticcheck not installed, skipping"
docker:
docker build -t labyrinth:$(VERSION) .
clean:
rm -f labyrinth labyrinth.exe labyrinth-*
rm -rf web/ui/dist web/ui/node_modules
go clean -testcache
cross: webui
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o labyrinth-linux-amd64 .
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o labyrinth-linux-arm64 .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o labyrinth-darwin-amd64 .
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o labyrinth-darwin-arm64 .
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o labyrinth-windows-amd64.exe .
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o labyrinth-bench-linux-amd64 ./cmd/labyrinth-bench/
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o labyrinth-bench-linux-arm64 ./cmd/labyrinth-bench/
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o labyrinth-bench-darwin-amd64 ./cmd/labyrinth-bench/
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o labyrinth-bench-darwin-arm64 ./cmd/labyrinth-bench/
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o labyrinth-bench-windows-amd64.exe ./cmd/labyrinth-bench/
install:
sudo bash install.sh
uninstall:
sudo bash uninstall.sh