-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
53 lines (41 loc) · 1.97 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
.DEFAULT_GOAL := all
all: test
fmt: tools/go.mod
@go run -modfile=tools/go.mod github.com/elastic/go-licenser -license=Elasticv2 .
@go run -modfile=tools/go.mod golang.org/x/tools/cmd/goimports -local github.com/elastic/ -w .
lint: tools/go.mod
for dir in $(shell find . -type f -name go.mod -exec dirname '{}' \;); do (cd $$dir && go mod tidy && git diff --stat --exit-code -- go.mod go.sum) || exit $$?; done
go run -modfile=tools/go.mod honnef.co/go/tools/cmd/staticcheck -checks=all ./...
protolint:
docker run --volume "$(PWD):/workspace" --workdir /workspace bufbuild/buf lint proto
docker run --volume "$(PWD):/workspace" --workdir /workspace bufbuild/buf breaking proto --against https://github.com/elastic/apm-aggregation.git#branch=main,subdir=proto
.PHONY: clean
clean:
rm -fr bin build
.PHONY: test
test: go.mod
go test -v -race ./...
##############################################################################
# Protobuf generation
##############################################################################
GITROOT ?= $(shell git rev-parse --show-toplevel)
GOOSBUILD:=$(GITROOT)/build/$(shell go env GOOS)
PROTOC=$(GOOSBUILD)/protoc/bin/protoc
PROTOC_GEN_GO_VTPROTO=$(GOOSBUILD)/protoc-gen-go-vtproto
PROTOC_GEN_GO=$(GOOSBUILD)/protoc-gen-go
$(PROTOC):
@./tools/install-protoc.sh
$(PROTOC_GEN_GO_VTPROTO):
GOBIN=$(GOOSBUILD) go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto
$(PROTOC_GEN_GO):
GOBIN=$(GOOSBUILD) go install google.golang.org/protobuf/cmd/protoc-gen-go
PROTOC_OUT?=.
.PHONY: gen-proto
gen-proto: $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_VTPROTO) $(PROTOC)
$(eval STRUCTS := $(shell grep '^message' proto/*.proto | cut -d ' ' -f2))
$(PROTOC) -I . --go_out=$(PROTOC_OUT) --plugin protoc-gen-go="$(PROTOC_GEN_GO)" \
--go-vtproto_out=$(PROTOC_OUT) --plugin protoc-gen-go-vtproto="$(PROTOC_GEN_GO_VTPROTO)" \
--go-vtproto_opt=features=marshal+unmarshal+size+clone \
$(wildcard proto/*.proto)
go generate ./aggregators/internal/protohash
$(MAKE) fmt