From 22a24df5154b3fa8c9bcea88d1d8f4696d9d86b8 Mon Sep 17 00:00:00 2001 From: Euan Harris Date: Wed, 20 Jun 2018 17:20:49 +0100 Subject: [PATCH] Makefile, Dockerfile: Add support for regenerating protocol buffers Signed-off-by: Euan Harris --- libnetwork/Dockerfile | 6 ++++-- libnetwork/Makefile | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libnetwork/Dockerfile b/libnetwork/Dockerfile index 6ecb91046d..577b6c49a6 100644 --- a/libnetwork/Dockerfile +++ b/libnetwork/Dockerfile @@ -1,12 +1,14 @@ FROM golang:1.10.2 as dev -RUN apt-get update && apt-get -y install iptables +RUN apt-get update && apt-get -y install iptables \ + protobuf-compiler RUN go get github.com/golang/lint/golint \ golang.org/x/tools/cmd/cover \ github.com/mattn/goveralls \ github.com/gordonklaus/ineffassign \ github.com/client9/misspell/cmd/misspell \ - honnef.co/go/tools/cmd/gosimple + honnef.co/go/tools/cmd/gosimple \ + github.com/gogo/protobuf/protoc-gen-gogo WORKDIR /go/src/github.com/docker/libnetwork diff --git a/libnetwork/Makefile b/libnetwork/Makefile index beeea1293a..3a71655e64 100644 --- a/libnetwork/Makefile +++ b/libnetwork/Makefile @@ -123,3 +123,14 @@ gosimple: ## run gosimple shell: builder @${docker} ${SHELL} + +# Rebuild protocol buffers. +# These may need to be rebuilt after vendoring updates, so .pb.go files are declared .PHONY so they are always rebuilt. +PROTO_FILES=$(shell find . -path ./vendor -prune -o -name \*.proto -print) +PB_FILES=$(PROTO_FILES:.proto=.pb.go) + +%.pb.go: %.proto + ${docker} protoc -I=. -I=/go/src -I=/go/src/github.com/gogo/protobuf -I=/go/src/github.com/gogo/protobuf/protobuf --gogo_out=./ $< + +.PHONY: protobuf $(PROTO_FILES) +protobuf: builder $(PB_FILES)