-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (53 loc) · 1.7 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
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
67
68
MAKEFLAGS += --no-print-directory
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOBIN ?= $(shell go env GOPATH)/bin
netscanner_version := $(shell cat version.txt)
netscanner_module := github.com/hdecarne-github/netscanner
LDFLAGS := $(LDFLAGS) -X $(netscanner_module)/internal/version.buildVersion=$(netscanner_version) -X $(netscanner_module)/internal/version.buildTimestamp=$(shell date +%Y%m%d%H%M%S)
.DEFAULT_GOAL := build
.PHONY: deps
deps:
go mod download -x
.PHONY: testdeps
testdeps: deps
go install honnef.co/go/tools/cmd/[email protected]
.PHONY: tidy
tidy:
go mod verify
go mod tidy
.PHONY: build
build: deps
ifneq (windows, $(GOOS))
go build -ldflags "$(LDFLAGS)" -o build/bin/netscanner-cli ./cmd/netscanner-cli
go build -ldflags "$(LDFLAGS)" -o build/bin/netscanner ./cmd/netscanner
else
go build -ldflags "$(LDFLAGS)" -o build/bin/netscanner-cli.exe ./cmd/netscanner-cli
go build -ldflags "$(LDFLAGS)" -o build/bin/netscanner.exe ./cmd/netscanner
endif
.PHONY: dist
dist: build
mkdir -p build/dist
tar czvf build/dist/$(plugin_name)-$(GOOS)-$(GOARCH)-$(plugin_version).tar.gz -C build/bin .
ifneq (, $(shell command -v zip 2>/dev/null))
zip -j build/dist/$(plugin_name)-$(GOOS)-$(GOARCH)-$(plugin_version).zip build/bin/*
else ifneq (, $(shell command -v 7z 2>/dev/null))
7z a -bd build/dist/$(plugin_name)-$(GOOS)-$(GOARCH)-$(plugin_version).zip ./build/bin/*
endif
.PHONY: vet
vet: testdeps
go vet ./...
.PHONY: staticcheck
staticcheck: testdeps
$(GOBIN)/staticcheck ./...
.PHONY: lint
lint: vet staticcheck
.PHONY: test
test:
go test -v -covermode=atomic -coverprofile=build/coverage.out ./...
.PHONY: check
check: test lint
.PHONY: clean
clean:
go clean ./...
rm -rf build