-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
65 lines (52 loc) · 2.06 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
GO := go
BINDIR := $(CURDIR)/bin
GOLANGCI_LINT_VERSION := v1.53.3
GOLANGCI_LINT_BINDIR := .golangci-bin
GOLANGCI_LINT_BIN := $(GOLANGCI_LINT_BINDIR)/$(GOLANGCI_LINT_VERSION)/golangci-lint
all: bin
.bins/go-bindata:
@mkdir -p .bins
@GO111MODULE=off GOBIN=$(CURDIR)/.bins/ go get -u github.com/go-bindata/go-bindata/...
.bins/p4c-lite.sh:
@mkdir -p .bins
@curl -s https://raw.githubusercontent.com/antoninbas/p4c-lite-docker/master/p4c-lite.sh -o $@
@chmod +x $@
l2_switch: .bins/go-bindata .bins/p4c-lite.sh
@mkdir -p $(CURDIR)/cmd/l2_switch/l2_switch.out
./.bins/p4c-lite.sh --pull $(CURDIR)/cmd/l2_switch/l2_switch.p4 -o $(CURDIR)/cmd/l2_switch/l2_switch.out/
./.bins/go-bindata -o $(CURDIR)/cmd/l2_switch/l2_switch_data.go cmd/l2_switch/l2_switch.out
wcmp: .bins/go-bindata .bins/p4c-lite.sh
@mkdir -p $(CURDIR)/cmd/wcmp/wcmp.out
./.bins/p4c-lite.sh --pull $(CURDIR)/cmd/wcmp/wcmp.p4 -o $(CURDIR)/cmd/wcmp/wcmp.out/
./.bins/go-bindata -o $(CURDIR)/cmd/wcmp/wcmp_data.go cmd/wcmp/wcmp.out
.PHONY: bin
bin:
GOBIN=$(BINDIR) $(GO) install github.com/antoninbas/p4runtime-go-client/...
.PHONY: fmt
fmt:
$(GO) fmt github.com/antoninbas/p4runtime-go-client/...
# Run unit tests only, no integration tests
.PHONY: check-unit
check-unit:
$(GO) test github.com/antoninbas/p4runtime-go-client/...
.PHONY: check
check:
$(GO) test -tags=integration github.com/antoninbas/p4runtime-go-client/...
# code linting
$(GOLANGCI_LINT_BIN):
@echo "===> Installing Golangci-lint <==="
@rm -rf $(GOLANGCI_LINT_BINDIR)/* # delete old versions
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOLANGCI_LINT_BINDIR)/$(GOLANGCI_LINT_VERSION) $(GOLANGCI_LINT_VERSION)
.PHONY: golangci
golangci: $(GOLANGCI_LINT_BIN)
@echo "===> Running golangci <==="
@GOOS=linux $(GOLANGCI_LINT_BIN) run -c .golangci.yml
.PHONY: golangci-fix
golangci-fix: $(GOLANGCI_LINT_BIN)
@echo "===> Running golangci-fix <==="
@GOOS=linux $(GOLANGCI_LINT_BIN) run -c .golangci.yml --fix
.PHONY: clean
clean:
rm -rf $(BINDIR)
rm -rf .bins
rm -rf $(GOLANGCI_LINT_BINDIR)