1.DEFAULT_GOAL	:= build
2
3#------------------------------------------------------------------------------
4# Variables
5#------------------------------------------------------------------------------
6
7SHELL 	:= /bin/bash
8BINDIR	:= bin
9PKG 		:= github.com/envoyproxy/go-control-plane
10
11.PHONY: build
12build:
13	@go build ./pkg/... ./envoy/...
14
15.PHONY: clean
16clean:
17	@echo "--> cleaning compiled objects and binaries"
18	@go clean -tags netgo -i ./...
19	@go mod tidy
20	@rm -rf $(BINDIR)
21	@rm -rf *.log
22
23# TODO(mattklein123): See the note in TestLinearConcurrentSetWatch() for why we set -parallel here
24# This should be removed.
25.PHONY: test
26test:
27	@go test -race -v -timeout 30s -count=1 -parallel 100 ./pkg/...
28
29.PHONY: cover
30cover:
31	@build/coverage.sh
32
33.PHONY: format
34format:
35	@goimports -local $(PKG) -w -l pkg
36
37.PHONY: examples
38examples:
39	@pushd examples/dyplomat && go build ./... && popd
40
41.PHONY: lint
42lint:
43	docker run \
44		--rm \
45		--volume $$(pwd):/src \
46		--workdir /src \
47		golangci/golangci-lint:v1.41.1 \
48	golangci-lint run
49
50#-----------------
51#-- integration
52#-----------------
53.PHONY: $(BINDIR)/test $(BINDIR)/upstream integration integration.ads integration.xds integration.rest integration.xds.mux integration.xds.delta integration.ads.delta
54
55$(BINDIR)/upstream:
56	@go build -race -o $@ internal/upstream/main.go
57
58$(BINDIR)/test:
59	@echo "Building test binary"
60	@go build -race -o $@ pkg/test/main/main.go
61
62integration: integration.xds integration.ads integration.rest integration.xds.mux integration.xds.delta integration.ads.delta
63
64integration.ads: $(BINDIR)/test $(BINDIR)/upstream
65	env XDS=ads build/integration.sh
66
67integration.xds: $(BINDIR)/test $(BINDIR)/upstream
68	env XDS=xds build/integration.sh
69
70integration.rest: $(BINDIR)/test $(BINDIR)/upstream
71	env XDS=rest build/integration.sh
72
73integration.xds.mux: $(BINDIR)/test $(BINDIR)/upstream
74	env XDS=xds build/integration.sh -mux
75
76integration.xds.delta: $(BINDIR)/test $(BINDIR)/upstream
77	env XDS=delta build/integration.sh
78
79integration.ads.delta: $(BINDIR)/test $(BINDIR)/upstream
80	env XDS=delta-ads build/integration.sh
81
82#--------------------------------------
83#-- example xDS control plane server
84#--------------------------------------
85.PHONY: $(BINDIR)/example example
86
87$(BINDIR)/example:
88	@go build -race -o $@ internal/example/main/main.go
89
90example: $(BINDIR)/example
91	@build/example.sh
92
93.PHONY: docker_tests
94docker_tests:
95	docker build --pull -f Dockerfile.ci . -t gcp_ci && \
96	docker run -v $$(pwd):/go-control-plane $$(tty -s && echo "-it" || echo) gcp_ci /bin/bash -c /go-control-plane/build/do_ci.sh
97