-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
91 lines (73 loc) · 2.64 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
# Copyright © 2022 IOTIC LABS LTD. [email protected]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://github.com/Iotic-Labs/iotics-grpc-client-ts/blob/main/LICENSE
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
BUF_VERSION:=1.6.0
PROTOC_VERSION:=3.17.3
GOPATH=$(shell go env GOPATH)
export GOBIN=$(GOPATH)/bin
export PATH:=$(PATH):$(GOBIN)
BUF = $(GOBIN)/buf
PROTOC = $(GOBIN)/protoc
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Darwin)
PROTOC_ARCHIVE="protoc-$(PROTOC_VERSION)-osx-x86_64.zip"
else
PROTOC_ARCHIVE="protoc-$(PROTOC_VERSION)-$(UNAME_S)-$(shell uname -m).zip"
endif
BUF_URL = "https://github.com/bufbuild/buf/releases/download/v$(BUF_VERSION)/buf-$(shell uname -s)-$(shell uname -m)"
PROTOC_URL = "https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VERSION)/$(PROTOC_ARCHIVE)"
########################
## High level targets ##
########################
build: deps-proto deps-go deps-buf lint deps-node generate dist
clean:
rm -rf buf.lock dist node_modules src/client yarn.lock
dist dist-update:
yarn build
generate: src/client
generate-update src/client:
$(BUF) generate --include-imports $(GEN_ARGS)
lint:
$(BUF) lint
list:
$(BUF) ls-files
publish:
yarn publish --access public
#######################
## Low level targets ##
#######################
deps-proto:
git submodule update --init --recursive
deps-proto-update:
git submodule foreach git pull origin main
deps-go: $(GOBIN)/buf $(GOBIN)/protoc
$(GOBIN)/buf $(GOBIN)/protoc:
curl -sSL $(BUF_URL) -o $(GOBIN)/buf && chmod +x $(GOBIN)/buf
curl -OL $(PROTOC_URL) && \
unzip -p $(PROTOC_ARCHIVE) bin/protoc > $(GOBIN)/protoc && chmod +x $(GOBIN)/protoc && \
rm $(PROTOC_ARCHIVE)
deps-go-update:
ifneq ("$(shell ! test -e $(BUF) || $(BUF) --version 2>&1)", "$(BUF_VERSION)")
curl -sSL $(BUF_URL) -o $(GOBIN)/buf && chmod +x $(GOBIN)/buf
endif
ifneq ("$(shell ! test -e $(PROTOC) || $(PROTOC) --version 2>&1)", "libprotoc $(PROTOC_VERSION)")
curl -OL $(PROTOC_URL) && \
unzip -p $(PROTOC_ARCHIVE) bin/protoc > $(GOBIN)/protoc && chmod +x $(GOBIN)/protoc && \
rm $(PROTOC_ARCHIVE)
endif
deps-node: node_modules
deps-node-update node_modules:
yarn install && cd examples && yarn install
deps-buf: buf.lock
deps-buf-update buf.lock:
$(BUF) mod update