Skip to content

Commit 59f8b79

Browse files
committed
Dep Support
This patch introduces support for the Golang dependency management program `dep`. The changes include using a predetermined version of the gRPC plug-in for Go, `protoc-gen-go`.
1 parent d68da7a commit 59f8b79

File tree

4 files changed

+84
-9
lines changed

4 files changed

+84
-9
lines changed

lib/go/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/vendor
2+
/dep
13
/protoc
24
/protoc-gen-go
35
/csi.a

lib/go/Gopkg.lock

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/go/Gopkg.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
2+
# for detailed Gopkg.toml documentation.
3+
#
4+
# Refer to https://github.com/toml-lang/toml for detailed TOML docs.
5+
6+
[[constraint]]
7+
branch = "master"
8+
name = "github.com/golang/protobuf"
9+
10+
[[constraint]]
11+
branch = "master"
12+
name = "golang.org/x/net"
13+
14+
[[constraint]]
15+
name = "google.golang.org/grpc"
16+
version = "1.6.0"

lib/go/Makefile

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,34 @@ endif
1515
export GOPATH
1616

1717

18+
################################################################################
19+
## DEP ##
20+
################################################################################
21+
22+
DEP ?= ./dep
23+
DEP_VER ?= 0.3.1
24+
DEP_BIN := dep-$$GOHOSTOS-$$GOHOSTARCH
25+
DEP_URL := https://github.com/golang/dep/releases/download/v$(DEP_VER)/$$DEP_BIN
26+
27+
$(DEP):
28+
GOVERSION=$$(go version | awk '{print $$4}') && \
29+
GOHOSTOS=$$(echo $$GOVERSION | awk -F/ '{print $$1}') && \
30+
GOHOSTARCH=$$(echo $$GOVERSION | awk -F/ '{print $$2}') && \
31+
DEP_BIN="$(DEP_BIN)" && \
32+
DEP_URL="$(DEP_URL)" && \
33+
curl -sSLO $$DEP_URL && \
34+
chmod 0755 "$$DEP_BIN" && \
35+
mv -f "$$DEP_BIN" "$@"
36+
37+
vendor: | $(DEP)
38+
$(DEP) ensure -v -vendor-only
39+
40+
1841
########################################################################
1942
## PROTOC ##
2043
########################################################################
2144

22-
# Only set PROTOC_VER if it has an empty value.
23-
ifeq (,$(strip $(PROTOC_VER)))
24-
PROTOC_VER := 3.3.0
25-
endif
26-
45+
PROTOC_VER ?= 3.3.0
2746
PROTOC_OS := $(shell uname -s)
2847
ifeq (Darwin,$(PROTOC_OS))
2948
PROTOC_OS := osx
@@ -57,10 +76,9 @@ $(PROTOC):
5776
# This is the recipe for getting and installing the go plug-in
5877
# for protoc
5978
PROTOC_GEN_GO_PKG := github.com/golang/protobuf/protoc-gen-go
60-
PROTOC_GEN_GO := protoc-gen-go
61-
$(PROTOC_GEN_GO):
62-
go get -d $(PROTOC_GEN_GO_PKG) && \
63-
go build -o "$@" $(PROTOC_GEN_GO_PKG)
79+
PROTOC_GEN_GO := ./protoc-gen-go
80+
$(PROTOC_GEN_GO): | vendor
81+
go build -o "$@" ./vendor/$(PROTOC_GEN_GO_PKG)
6482

6583

6684
########################################################################

0 commit comments

Comments
 (0)