-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathMakefile
131 lines (105 loc) · 2.98 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
current_os :=
ifeq ($(OS),Windows_NT)
current_os = windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
current_os = linux
endif
ifeq ($(UNAME_S),Darwin)
current_os = darwin
endif
endif
binary_base_path = build/bin/cifuzz
project := "code-intelligence.com/cifuzz"
default:
@echo cifuzz
.PHONY: clean
clean:
rm -rf build/
.PHONY: deps
deps:
go mod download
.PHONY: deps/dev
deps/dev: deps
go install github.com/incu6us/goimports-reviser/v2@latest
go install github.com/golangci/golangci-lint/cmd/[email protected]
.PHONY: install
install:
go run cmd/installer/main.go
.PHONY: build
build: build/$(current_os)
.PHONY: build/all
build/all: build/linux build/windows build/darwin ;
.PHONY: build/linux
build/linux: deps
env GOOS=linux GOARCH=amd64 go build -o $(binary_base_path)_linux cmd/cifuzz/main.go
.PHONY: build/windows
build/windows: deps
env GOOS=windows GOARCH=amd64 go build -o $(binary_base_path)_windows.exe cmd/cifuzz/main.go
.PHONY: build/darwin
build/darwin: deps
env GOOS=darwin GOARCH=amd64 go build -o $(binary_base_path)_darwin cmd/cifuzz/main.go
.PHONY: lint
lint: deps/dev
golangci-lint run
.PHONY: fmt
fmt:
find . -type f -name "*.go" -exec goimports-reviser -project-name $(project) -file-path {} \;
.PHONY: fmt/check
fmt/check:
@DIFF=$$(find . -type f -name "*.go" -exec goimports-reviser -project-name $(project) -list-diff -file-path {} \;); \
if [ -n "$$DIFF" ]; then \
echo >&2 "Unformatted files:\n$$DIFF"; \
exit 1; \
fi;
.PHONY: tidy
tidy:
go mod tidy
.PHONY: tidy/check
tidy/check:
# Replace with `go mod tidy -check` once that's available, see
# https://github.com/golang/go/issues/27005
if [ -n "$$(git status --porcelain go.mod go.sum)" ]; then \
echo >&2 "Error: The working tree has uncommitted changes."; \
exit 1; \
fi
go mod tidy
if [ -n "$$(git status --porcelain go.mod go.sum)" ]; then \
echo >&2 "Error: Files were modified by go mod tidy"; \
git checkout go.mod go.sum; \
exit 1; \
fi
.PHONY: test
test: deps build/$(current_os)
go test -v ./...
.PHONY: test/unit
test/unit: deps
go test -v ./... -short
.PHONY: test/integration
test/integration: deps
go test -v ./... -run 'TestIntegration.*'
.PHONY: test/integration/sequential
test/integration/sequential: deps
go test -v -parallel=1 ./... -run 'TestIntegration.*'
.PHONY: test/race
test/race: deps build/$(current_os)
go test -v ./... -race
.PHONY: test/coverage
test/coverage: deps
go test -v ./... -coverprofile coverage.out
go tool cover -html coverage.out
.PHONY: site/setup
site/setup:
-rm -rf site
git clone [email protected]:CodeIntelligenceTesting/cifuzz.wiki.git site
.PHONY: site/generate
site/generate: deps
rm -f ./site/*.md
go run ./cmd/gen-docs/main.go --dir ./site/
cp -R ./docs/*.md ./site
.PHONY: site/update
site/update:
git -C site add -A
git -C site commit -m "update docs" || true
git -C site push