-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (23 loc) · 890 Bytes
/
Makefile
File metadata and controls
37 lines (23 loc) · 890 Bytes
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
GOPATH := $(shell go env GOPATH)
GOARCH ?= $(shell go env GOARCH)
GOOS ?= $(shell go env GOOS)
.PHONY: fmt all clean test binary
all: clean fmt
@make binary GOOS=linux GOARCH=amd64 && make binary GOOS=linux GOARCH=arm64 && \
make binary GOOS=windows GOARCH=amd64
clean:
@rm -rf osc-watch build osc-watch*
EXEC_EXT :=
ifeq ($(GOOS),windows)
EXEC_EXT := .exe
endif
binary: osc-watch-$(GOOS)-$(GOARCH)$(EXEC_EXT).gz
osc-watch-$(GOOS)-$(GOARCH)$(EXEC_EXT): $(shell find ./ -type f -name '*.go') go.mod go.sum
@GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags "-w -s" -v -o $@
osc-watch-$(GOOS)-$(GOARCH)$(EXEC_EXT).gz: osc-watch-$(GOOS)-$(GOARCH)$(EXEC_EXT)
@gzip osc-watch-$(GOOS)-$(GOARCH)$(EXEC_EXT) -9
fmt:
@(test -f "$(GOPATH)/bin/gofumpt" || go install mvdan.cc/gofumpt@latest) && \
"$(GOPATH)/bin/gofumpt" -l -w .
test: osc-watch
@go test -v ./...