-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (37 loc) · 1 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
MAKE_PATH=$(GOPATH)/bin:/bin:/usr/bin:/usr/local/bin:$PATH
.PHONY: all
all: clean format gen lint
BUF_VERSION=1.6.0
.PHONY: buf-install
buf-install:
ifeq ($(shell uname -s), Darwin)
@[ ! -f $(GOPATH)/bin/buf ] || exit 0 && \
tmp=$$(mktemp -d) && cd $$tmp && \
curl -L -o buf \
https://github.com/bufbuild/buf/releases/download/v$(BUF_VERSION)/buf-Darwin-arm64 && \
mv buf $(GOPATH)/bin/buf && \
chmod +x $(GOPATH)/bin/buf
else
@[ ! -f $(GOPATH)/bin/buf ] || exit 0 && \
tmp=$$(mktemp -d) && cd $$tmp && \
curl -L -o buf \
https://github.com/bufbuild/buf/releases/download/v$(BUF_VERSION)/buf-Linux-x86_64 && \
mv buf $(GOPATH)/bin/buf && \
chmod +x $(GOPATH)/bin/buf
endif
.PHONY: gen
gen: buf-install
@$(GOPATH)/bin/buf generate
@for dir in $(CURDIR)/gen/go/*/; do \
cd $$dir && \
go mod init && go mod tidy; \
done
.PHONY: lint
lint: buf-install
@$(GOPATH)/bin/buf lint --config buf.yaml
.PHONY: format
format: buf-install
@$(GOPATH)/bin/buf format
.PHONY: clean
clean:
@rm -rf ./gen || true