From 4736c8825218eeeef02a8737d9bc0f31c8c76daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Villaf=C3=A1=C3=B1ez?= Date: Fri, 21 Jan 2022 14:29:57 +0100 Subject: [PATCH] Restore old makefile and check custom lock file before the generation --- .make/protobuf.mk | 24 ++++++++++++++++++++++++ Makefile | 21 ++++----------------- accounts/Makefile | 6 ++++++ settings/Makefile | 6 ++++++ store/Makefile | 6 ++++++ thumbnails/Makefile | 6 ++++++ 6 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 .make/protobuf.mk diff --git a/.make/protobuf.mk b/.make/protobuf.mk new file mode 100644 index 000000000..52204ed97 --- /dev/null +++ b/.make/protobuf.mk @@ -0,0 +1,24 @@ +SHA1_LOCK_FILE := $(abspath $(CURDIR)/../protogen/buf.sha1.lock) + +# bingo creates symlinks from the -l option in GOBIN, from where +# we can easily use it with buf. To have the symlinks inside this +# repo and on a known location, we set GOBIN to .bingo in the root +# of the repository (therefore we need to cd ..) +.PHONY: protoc-deps +protoc-deps: $(BINGO) + @cd .. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l google.golang.org/protobuf/cmd/protoc-gen-go + @cd .. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/asim/go-micro/cmd/protoc-gen-micro/v4 + @cd .. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/owncloud/protoc-gen-microweb + @cd .. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 + @cd .. && GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc + +.PHONY: buf-generate +buf-generate: $(BUF) protoc-deps $(SHA1_LOCK_FILE) + @find $(abspath $(CURDIR)/../protogen/proto/) -type f -print0 | sort -z | xargs -0 sha1sum > buf.sha1.lock.tmp + @cmp $(SHA1_LOCK_FILE) buf.sha1.lock.tmp --quiet || $(MAKE) -B $(SHA1_LOCK_FILE) + @rm -f buf.sha1.lock.tmp + +$(SHA1_LOCK_FILE): + @echo "generating protobuf content" + cd ../protogen/proto && $(BUF) generate + find $(abspath $(CURDIR)/../protogen/proto/) -type f -print0 | sort -z | xargs -0 sha1sum > $(SHA1_LOCK_FILE) diff --git a/Makefile b/Makefile index 6932cff78..de9c6924b 100644 --- a/Makefile +++ b/Makefile @@ -163,24 +163,11 @@ go-coverage: echo -n "% coverage $$mod: "; $(MAKE) --no-print-directory -C $$mod go-coverage; \ done -# bingo creates symlinks from the -l option in GOBIN, from where -# we can easily use it with buf. To have the symlinks inside this -# repo and on a known location, we set GOBIN to .bingo in the root -# of the repository (therefore we need to cd ..) -.PHONY: protoc-deps -protoc-deps: $(BINGO) - @GOPATH="" GOBIN=".bingo" $(BINGO) get -l google.golang.org/protobuf/cmd/protoc-gen-go - @GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/asim/go-micro/cmd/protoc-gen-micro/v4 - @GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/owncloud/protoc-gen-microweb - @GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 - @GOPATH="" GOBIN=".bingo" $(BINGO) get -l github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc - -.PHONY: buf-generate -buf-generate: $(BUF) protoc-deps - cd protogen/proto && $(BUF) generate - .PHONY: protobuf -protobuf: buf-generate +protobuf: + @for mod in $(OCIS_MODULES); do \ + echo -n "% protobuf $$mod: "; $(MAKE) --no-print-directory -C $$mod protobuf; \ + done .PHONY: bingo-update bingo-update: $(BINGO) diff --git a/accounts/Makefile b/accounts/Makefile index 9b0678468..456de57a6 100644 --- a/accounts/Makefile +++ b/accounts/Makefile @@ -47,3 +47,9 @@ yarn-build: node_modules .PHONY: node_modules node_modules: yarn install --immutable + +############ protobuf ############ +include ../.make/protobuf.mk + +.PHONY: protobuf +protobuf: buf-generate diff --git a/settings/Makefile b/settings/Makefile index c838ab93a..445db94d4 100644 --- a/settings/Makefile +++ b/settings/Makefile @@ -48,3 +48,9 @@ yarn-build: node_modules .PHONY: node_modules node_modules: yarn install --immutable + +############ protobuf ############ +include ../.make/protobuf.mk + +.PHONY: protobuf +protobuf: buf-generate diff --git a/store/Makefile b/store/Makefile index 8fbe07b30..9c9323a4b 100644 --- a/store/Makefile +++ b/store/Makefile @@ -30,3 +30,9 @@ ci-go-generate: protobuf # CI runs ci-node-generate automatically before this ta .PHONY: ci-node-generate ci-node-generate: + +############ protobuf ############ +include ../.make/protobuf.mk + +.PHONY: protobuf +protobuf: buf-generate diff --git a/thumbnails/Makefile b/thumbnails/Makefile index a083f9316..5ae6d2740 100644 --- a/thumbnails/Makefile +++ b/thumbnails/Makefile @@ -29,3 +29,9 @@ ci-go-generate: protobuf # CI runs ci-node-generate automatically before this ta .PHONY: ci-node-generate ci-node-generate: + +############ protobuf ############ +include ../.make/protobuf.mk + +.PHONY: protobuf +protobuf: buf-generate