make: Automatically detect names of generated proto files.

This commit is contained in:
Joachim Bauch 2024-02-07 11:29:45 +01:00
parent 1a0e51499f
commit 2b62c9e3c1
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02

View file

@ -13,6 +13,8 @@ VERSION := $(shell "$(CURDIR)/scripts/get-version.sh")
TARVERSION := $(shell "$(CURDIR)/scripts/get-version.sh" --tar) TARVERSION := $(shell "$(CURDIR)/scripts/get-version.sh" --tar)
PACKAGENAME := github.com/strukturag/nextcloud-spreed-signaling PACKAGENAME := github.com/strukturag/nextcloud-spreed-signaling
ALL_PACKAGES := $(PACKAGENAME) $(PACKAGENAME)/client $(PACKAGENAME)/proxy $(PACKAGENAME)/server ALL_PACKAGES := $(PACKAGENAME) $(PACKAGENAME)/client $(PACKAGENAME)/proxy $(PACKAGENAME)/server
PROTO_FILES := $(basename $(wildcard *.proto))
PROTO_GO_FILES := $(addsuffix .pb.go,$(PROTO_FILES)) $(addsuffix _grpc.pb.go,$(PROTO_FILES))
ifneq ($(VERSION),) ifneq ($(VERSION),)
INTERNALLDFLAGS := -X main.version=$(VERSION) INTERNALLDFLAGS := -X main.version=$(VERSION)
@ -78,7 +80,7 @@ check-continentmap:
get: get:
$(GO) get $(PACKAGE) $(GO) get $(PACKAGE)
fmt: hook | common_proto fmt: hook | $(PROTO_GO_FILES)
$(GOFMT) -s -w *.go client proxy server $(GOFMT) -s -w *.go client proxy server
vet: common vet: common
@ -101,7 +103,7 @@ coverhtml: vet common
sed -i "/\.pb\.go/d" cover.out && \ sed -i "/\.pb\.go/d" cover.out && \
$(GO) tool cover -html=cover.out -o coverage.html $(GO) tool cover -html=cover.out -o coverage.html
%_easyjson.go: %.go $(GOPATHBIN)/easyjson | common_proto %_easyjson.go: %.go $(GOPATHBIN)/easyjson | $(PROTO_GO_FILES)
PATH="$(GODIR)":$(PATH) "$(GOPATHBIN)/easyjson" -all $*.go PATH="$(GODIR)":$(PATH) "$(GOPATHBIN)/easyjson" -all $*.go
%.pb.go: %.proto $(GOPATHBIN)/protoc-gen-go $(GOPATHBIN)/protoc-gen-go-grpc %.pb.go: %.proto $(GOPATHBIN)/protoc-gen-go $(GOPATHBIN)/protoc-gen-go-grpc
@ -114,7 +116,7 @@ coverhtml: vet common
--go-grpc_out=. --go-grpc_opt=paths=source_relative \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \
$*.proto $*.proto
common: common_easyjson common_proto common: common_easyjson $(PROTO_GO_FILES)
common_easyjson: \ common_easyjson: \
api_async_easyjson.go \ api_async_easyjson.go \
@ -123,16 +125,6 @@ common_easyjson: \
api_proxy_easyjson.go \ api_proxy_easyjson.go \
api_signaling_easyjson.go api_signaling_easyjson.go
common_proto: \
grpc_backend.pb.go \
grpc_backend_grpc.pb.go \
grpc_internal.pb.go \
grpc_internal_grpc.pb.go \
grpc_mcu.pb.go \
grpc_mcu_grpc.pb.go \
grpc_sessions.pb.go \
grpc_sessions_grpc.pb.go
$(BINDIR): $(BINDIR):
mkdir -p $(BINDIR) mkdir -p $(BINDIR)
@ -148,7 +140,7 @@ proxy: common $(BINDIR)
clean: clean:
rm -f *_easyjson.go rm -f *_easyjson.go
rm -f easyjson-bootstrap*.go rm -f easyjson-bootstrap*.go
rm -f *.pb.go rm -f $(PROTO_GO_FILES)
build: server proxy build: server proxy