Restore old makefile and check custom lock file before the generation

This commit is contained in:
Juan Pablo Villafáñez
2022-01-21 14:29:57 +01:00
parent 83b4bf9bcf
commit 4736c88252
6 changed files with 52 additions and 17 deletions

24
.make/protobuf.mk Normal file
View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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