Skip to content

Dep Support #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/go/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/vendor
/dep
/protoc
/protoc-gen-go
/csi.a
Expand Down
39 changes: 39 additions & 0 deletions lib/go/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions lib/go/Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# Refer to https://github.com/toml-lang/toml for detailed TOML docs.

# The following packages are required because they're either build
# tools or are dependencies only if the "csi" package is already
# generated. However, if the "csi" package is removed (a valid
# condition), a "dep ensure" will not fetch the dependencies it
# no longer sees in the project's dependency graph. Including the
# dependencies in the "required" list ensures they're always
# downloaded.
required = [
"github.com/golang/protobuf/protoc-gen-go",
"golang.org/x/net/context",
"google.golang.org/grpc"
]

[[constraint]]
branch = "master"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we target a specific revision? These can be updated periodically if needed.

name = "github.com/golang/protobuf"

[[constraint]]
branch = "master"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

name = "golang.org/x/net"

[[constraint]]
name = "google.golang.org/grpc"
version = "1.6.0"
37 changes: 27 additions & 10 deletions lib/go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,33 @@ endif
export GOPATH


################################################################################
## DEP ##
################################################################################

DEP ?= ./dep
DEP_VER ?= 0.3.1
DEP_BIN := dep-$$GOHOSTOS-$$GOHOSTARCH
DEP_URL := https://github.com/golang/dep/releases/download/v$(DEP_VER)/$$DEP_BIN

$(DEP):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't spend much time designing makefiles, but a little iffy in automatically installing a binary for people. We can add how to get dep in the README or in a contributing guide.

GOVERSION=$$(go version | awk '{print $$4}') && \
GOHOSTOS=$$(echo $$GOVERSION | awk -F/ '{print $$1}') && \
GOHOSTARCH=$$(echo $$GOVERSION | awk -F/ '{print $$2}') && \
DEP_BIN="$(DEP_BIN)" && \
DEP_URL="$(DEP_URL)" && \
curl -sSLO $$DEP_URL && \
chmod 0755 "$$DEP_BIN" && \
mv -f "$$DEP_BIN" "$@"

vendor: | $(DEP)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a compromise would be a vendor: check-dep dependency, where check-dep tests for the presence of dep in the $PATH and if it's missing exits the build?

if we want to stay friendly, we could also have a target dep: | $(DEP) so that a user that's missing dep could simply invoke make dep to pull it down.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we merge as is and handle it later since this adds value without detracting from any. This needs to be deterministic, period. Or bindings could be off since the tool used to grab the eps may influence the eps.

$(DEP) ensure -v -vendor-only


########################################################################
## PROTOC ##
########################################################################

# Only set PROTOC_VER if it has an empty value.
ifeq (,$(strip $(PROTOC_VER)))
PROTOC_VER := 3.5.1
endif

PROTOC_VER ?= 3.5.1
PROTOC_OS := $(shell uname -s)
ifeq (Darwin,$(PROTOC_OS))
PROTOC_OS := osx
Expand Down Expand Up @@ -57,10 +75,9 @@ $(PROTOC):
# This is the recipe for getting and installing the go plug-in
# for protoc
PROTOC_GEN_GO_PKG := github.com/golang/protobuf/protoc-gen-go
PROTOC_GEN_GO := protoc-gen-go
$(PROTOC_GEN_GO):
go get -d $(PROTOC_GEN_GO_PKG) && \
go build -o "$@" $(PROTOC_GEN_GO_PKG)
PROTOC_GEN_GO := ./protoc-gen-go
$(PROTOC_GEN_GO): | vendor
go build -o "$@" ./vendor/$(PROTOC_GEN_GO_PKG)


########################################################################
Expand Down