-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
39 lines (30 loc) · 1.02 KB
/
Makefile
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
PROJECT_DIR := ${shell dirname ${abspath ${lastword ${MAKEFILE_LIST}}}}
LOCALBIN ?= ${PROJECT_DIR}/bin
${LOCALBIN}:
mkdir -p ${LOCALBIN}
.PHONY: clean
clean:
rm -rf bin
.PHONY: fmt
fmt: gofumpt ## Run gofumt against code.
go mod tidy -compat=1.23
$(GOFUMPT) -w -extra .
.PHONY: vendor
vendor:
go mod vendor
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
.PHONY: lint
lint:
test -s $(GOLANGCI_LINT) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCALBIN)
CGO_ENABLED=0 $(GOLANGCI_LINT) run --timeout 5m
GOFUMPT ?= $(LOCALBIN)/gofumpt
.PHONY: gofumpt
gofumpt: $(GOFUMPT) ## Download gofumpt locally if necessary.
$(GOFUMPT): $(LOCALBIN)
test -s $(LOCALBIN)/gofumpt || GOBIN=$(LOCALBIN) go install mvdan.cc/gofumpt@latest
.PHONY: build
build: ## Build binary for host
CGO_ENABLED=0 go build -ldflags '-s -w' -o bin/tg-led main.go
.PHONY: build-arm
build-arm: ## Build binary for arm64
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags '-s -w' -o bin/tg-led-arm main.go