-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathMakefile
51 lines (46 loc) · 1.98 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
#
# Copyright 2018 Dgraph Labs, Inc. and Contributors
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#
PROTO_PATH := ${GOPATH}/src:.
PROTO_PATH := ${PROTO_PATH}:${GOPATH}/src/github.com/dgraph-io/dgraph
PROTO_PATH := ${PROTO_PATH}:${GOPATH}/src/github.com/dgraph-io/dgo/protos
PROTO_PATH := ${PROTO_PATH}:${GOPATH}/src/github.com/dgraph-io/badger/pb
.PHONY: help
help:
@echo Use \"make regenerate\" to proceed.
.PHONY: clean
clean:
@mkdir -p pb && rm -f pb/pb.pb.go
.PHONY: check
check:
@./depcheck.sh && \
(echo "Setting proto libraries to versions in go.mod." ; \
go get github.com/golang/protobuf/protoc-gen-go ; \
go get github.com/gogo/protobuf/protoc-gen-gofast)
.PHONY: regenerate
regenerate: check clean
# These sed replacements are necessary to use Badger v2 via Go modules.
# The protoc tool doesn't recognize Go module import paths, so we need to
# specify the filesystem-level import path (without "v2") to generate the
# protos and then set "v2" in the generated code (pb/pb.pb.go).
@sed -i'' -e 's;github.com/dgraph-io/badger/v2/pb/pb.proto;github.com/dgraph-io/badger/pb/pb.proto;' pb.proto
@protoc \
--proto_path=/usr/local/include \
--proto_path=${PROTO_PATH} \
--gofast_out=plugins=grpc,Mapi.proto=github.com/dgraph-io/dgo/v200/protos/api:pb \
pb.proto
@sed -i'' -e 's;github.com/dgraph-io/badger/pb/pb.proto;github.com/dgraph-io/badger/v2/pb/pb.proto;' pb.proto
@sed -i'' -e 's;github.com/dgraph-io/badger/pb;github.com/dgraph-io/badger/v2/pb;' pb/pb.pb.go
@echo Done.