cmd/ctrd-protobuild: create proper command for building protos

After trying to explain the complexities of developing with protobuf, I
have now created a command that correctly calculates the import paths
for each package and runs the protobuf command.

The Makefile has been updated accordingly, expect we now no longer use
`go generate`. A new target `protos` has been defined. We alias the two,
for the lazy. We leave `go generate` in place for cases where we will
actually use `go generate`.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2017-02-14 16:48:36 -08:00
parent 6bb8d5a589
commit 83e7610194
No known key found for this signature in database
GPG key ID: 67B3DED84EDC823F
17 changed files with 493 additions and 287 deletions

View file

@ -15,7 +15,7 @@ INTEGRATION_PACKAGE=${PROJECT_ROOT}/integration
SNAPSHOT_PACKAGES=$(shell go list ./snapshot/...)
# Project binaries.
COMMANDS=ctr containerd containerd-shim protoc-gen-gogoctrd dist
COMMANDS=ctr containerd containerd-shim protoc-gen-gogoctrd dist ctrd-protobuild
BINARIES=$(addprefix bin/,$(COMMANDS))
# TODO(stevvooe): This will set version from git tag, but overrides major,
@ -26,7 +26,7 @@ GO_LDFLAGS=-ldflags "-X `go list`.Version=$(VERSION)"
# Flags passed to `go test`
TESTFLAGS ?=-parallel 8 -race
.PHONY: clean all AUTHORS fmt vet lint build binaries test integration setup generate checkprotos coverage ci check help install uninstall vendor
.PHONY: clean all AUTHORS fmt vet lint build binaries test integration setup generate protos checkprotos coverage ci check help install uninstall vendor
.DEFAULT: default
all: binaries
@ -45,12 +45,15 @@ setup: ## install dependencies
#@go get -u github.com/kisielk/errcheck
@go get -u github.com/gordonklaus/ineffassign
generate: bin/protoc-gen-gogoctrd ## generate protobuf
generate: protos
@echo "🐳 $@"
@tools/gen-gen-go.sh
@PATH=${ROOTDIR}/bin:${PATH} go generate -x ${PACKAGES}
checkprotos: generate ## check if protobufs needs to be generated again
protos: bin/protoc-gen-gogoctrd bin/ctrd-protobuild ## generate protobuf
@echo "🐳 $@"
@PATH=${ROOTDIR}/bin:${PATH} ctrd-protobuild ${PACKAGES}
checkprotos: protos ## check if protobufs needs to be generated again
@echo "🐳 $@"
@test -z "$$(git status --short | grep ".pb.go" | tee /dev/stderr)" || \
((git diff | cat) && \