From 243042100694eccb52247d463d1802c672a6bd12 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 7 Feb 2024 11:23:45 +0100 Subject: [PATCH 1/8] make: Update easyjson / prococ generators if dependencies changed. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b584fad..5a73eef 100644 --- a/Makefile +++ b/Makefile @@ -53,14 +53,14 @@ endif hook: [ ! -d "$(CURDIR)/.git/hooks" ] || ln -sf "$(CURDIR)/scripts/pre-commit.hook" "$(CURDIR)/.git/hooks/pre-commit" -$(GOPATHBIN)/easyjson: +$(GOPATHBIN)/easyjson: go.mod go.sum [ "$(GOPROXY)" = "off" ] || $(GO) get -u -d github.com/mailru/easyjson/... $(GO) install github.com/mailru/easyjson/... -$(GOPATHBIN)/protoc-gen-go: +$(GOPATHBIN)/protoc-gen-go: go.mod go.sum $(GO) install google.golang.org/protobuf/cmd/protoc-gen-go -$(GOPATHBIN)/protoc-gen-go-grpc: +$(GOPATHBIN)/protoc-gen-go-grpc: go.mod go.sum [ "$(GOPROXY)" = "off" ] || $(GO) get -u -d google.golang.org/grpc/cmd/protoc-gen-go-grpc $(GO) install google.golang.org/grpc/cmd/protoc-gen-go-grpc From 1a0e51499f05f0a3152dbde18e4e7ae81d0f9b3c Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 7 Feb 2024 11:25:46 +0100 Subject: [PATCH 2/8] make: Split GRPC / regular PB file generation so it can be parallelized. --- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5a73eef..11cae9e 100644 --- a/Makefile +++ b/Makefile @@ -105,7 +105,12 @@ coverhtml: vet common PATH="$(GODIR)":$(PATH) "$(GOPATHBIN)/easyjson" -all $*.go %.pb.go: %.proto $(GOPATHBIN)/protoc-gen-go $(GOPATHBIN)/protoc-gen-go-grpc - PATH="$(GODIR)":"$(GOPATHBIN)":$(PATH) protoc --go_out=. --go_opt=paths=source_relative \ + PATH="$(GODIR)":"$(GOPATHBIN)":$(PATH) protoc \ + --go_out=. --go_opt=paths=source_relative \ + $*.proto + +%_grpc.pb.go: %.proto $(GOPATHBIN)/protoc-gen-go $(GOPATHBIN)/protoc-gen-go-grpc + PATH="$(GODIR)":"$(GOPATHBIN)":$(PATH) protoc \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \ $*.proto @@ -120,9 +125,13 @@ common_easyjson: \ 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_sessions.pb.go + grpc_mcu_grpc.pb.go \ + grpc_sessions.pb.go \ + grpc_sessions_grpc.pb.go $(BINDIR): mkdir -p $(BINDIR) From 2b62c9e3c1e8f2e00a8c1b4f807f1e3f5433b6e5 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 7 Feb 2024 11:29:45 +0100 Subject: [PATCH 3/8] make: Automatically detect names of generated proto files. --- Makefile | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 11cae9e..4e36eaa 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,8 @@ VERSION := $(shell "$(CURDIR)/scripts/get-version.sh") TARVERSION := $(shell "$(CURDIR)/scripts/get-version.sh" --tar) PACKAGENAME := github.com/strukturag/nextcloud-spreed-signaling 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),) INTERNALLDFLAGS := -X main.version=$(VERSION) @@ -78,7 +80,7 @@ check-continentmap: get: $(GO) get $(PACKAGE) -fmt: hook | common_proto +fmt: hook | $(PROTO_GO_FILES) $(GOFMT) -s -w *.go client proxy server vet: common @@ -101,7 +103,7 @@ coverhtml: vet common sed -i "/\.pb\.go/d" cover.out && \ $(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 %.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 \ $*.proto -common: common_easyjson common_proto +common: common_easyjson $(PROTO_GO_FILES) common_easyjson: \ api_async_easyjson.go \ @@ -123,16 +125,6 @@ common_easyjson: \ api_proxy_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): mkdir -p $(BINDIR) @@ -148,7 +140,7 @@ proxy: common $(BINDIR) clean: rm -f *_easyjson.go rm -f easyjson-bootstrap*.go - rm -f *.pb.go + rm -f $(PROTO_GO_FILES) build: server proxy From 55aee6e5dc7f616f29934a8cece572552460781f Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 7 Feb 2024 11:31:34 +0100 Subject: [PATCH 4/8] make: Keep generated easyjson files in variable. --- Makefile | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 4e36eaa..39a017c 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,12 @@ PACKAGENAME := github.com/strukturag/nextcloud-spreed-signaling 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)) +EASYJSON_GO_FILES := \ + api_async_easyjson.go \ + api_backend_easyjson.go \ + api_grpc_easyjson.go \ + api_proxy_easyjson.go \ + api_signaling_easyjson.go ifneq ($(VERSION),) INTERNALLDFLAGS := -X main.version=$(VERSION) @@ -116,14 +122,7 @@ coverhtml: vet common --go-grpc_out=. --go-grpc_opt=paths=source_relative \ $*.proto -common: common_easyjson $(PROTO_GO_FILES) - -common_easyjson: \ - api_async_easyjson.go \ - api_backend_easyjson.go \ - api_grpc_easyjson.go \ - api_proxy_easyjson.go \ - api_signaling_easyjson.go +common: $(EASYJSON_GO_FILES) $(PROTO_GO_FILES) $(BINDIR): mkdir -p $(BINDIR) @@ -138,7 +137,7 @@ proxy: common $(BINDIR) $(GO) build $(BUILDARGS) -ldflags '$(INTERNALLDFLAGS)' -o $(BINDIR)/proxy ./proxy/... clean: - rm -f *_easyjson.go + rm -f $(EASYJSON_GO_FILES) rm -f easyjson-bootstrap*.go rm -f $(PROTO_GO_FILES) @@ -164,5 +163,5 @@ tarball: vendor dist: tarball -.NOTPARALLEL: %_easyjson.go +.NOTPARALLEL: $(EASYJSON_GO_FILES) .PHONY: continentmap.go vendor From 4a762a32642db63da59e08007e289e00c15e7066 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 7 Feb 2024 11:39:26 +0100 Subject: [PATCH 5/8] make: Enable ".DELETE_ON_ERROR". --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 39a017c..167cc90 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,7 @@ coverhtml: vet common $(GO) tool cover -html=cover.out -o coverage.html %_easyjson.go: %.go $(GOPATHBIN)/easyjson | $(PROTO_GO_FILES) + rm -f easyjson-bootstrap*.go PATH="$(GODIR)":$(PATH) "$(GOPATHBIN)/easyjson" -all $*.go %.pb.go: %.proto $(GOPATHBIN)/protoc-gen-go $(GOPATHBIN)/protoc-gen-go-grpc @@ -165,3 +166,4 @@ dist: tarball .NOTPARALLEL: $(EASYJSON_GO_FILES) .PHONY: continentmap.go vendor +.DELETE_ON_ERROR: From b710d1704ec03177c5527ec8cac1812799cdea87 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 7 Feb 2024 11:41:59 +0100 Subject: [PATCH 6/8] make: Mark "common" as ".PHONY". --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 167cc90..be35f0f 100644 --- a/Makefile +++ b/Makefile @@ -165,5 +165,5 @@ tarball: vendor dist: tarball .NOTPARALLEL: $(EASYJSON_GO_FILES) -.PHONY: continentmap.go vendor +.PHONY: continentmap.go common vendor .DELETE_ON_ERROR: From 6488ba1cf5e077f1f70289355cd212858b6a3274 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 7 Feb 2024 11:43:41 +0100 Subject: [PATCH 7/8] make: Fix "BINDIR" getting always created. --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index be35f0f..6e17cd5 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ GOFMT := "$(GODIR)/gofmt" GOOS ?= linux GOARCH ?= amd64 GOVERSION := $(shell "$(GO)" env GOVERSION | sed "s|go||" ) -BINDIR := "$(CURDIR)/bin" +BINDIR := $(CURDIR)/bin VENDORDIR := "$(CURDIR)/vendor" VERSION := $(shell "$(CURDIR)/scripts/get-version.sh") TARVERSION := $(shell "$(CURDIR)/scripts/get-version.sh" --tar) @@ -126,16 +126,16 @@ coverhtml: vet common common: $(EASYJSON_GO_FILES) $(PROTO_GO_FILES) $(BINDIR): - mkdir -p $(BINDIR) + mkdir -p "$(BINDIR)" client: common $(BINDIR) - $(GO) build $(BUILDARGS) -ldflags '$(INTERNALLDFLAGS)' -o $(BINDIR)/client ./client/... + $(GO) build $(BUILDARGS) -ldflags '$(INTERNALLDFLAGS)' -o "$(BINDIR)/client" ./client/... server: common $(BINDIR) - $(GO) build $(BUILDARGS) -ldflags '$(INTERNALLDFLAGS)' -o $(BINDIR)/signaling ./server/... + $(GO) build $(BUILDARGS) -ldflags '$(INTERNALLDFLAGS)' -o "$(BINDIR)/signaling" ./server/... proxy: common $(BINDIR) - $(GO) build $(BUILDARGS) -ldflags '$(INTERNALLDFLAGS)' -o $(BINDIR)/proxy ./proxy/... + $(GO) build $(BUILDARGS) -ldflags '$(INTERNALLDFLAGS)' -o "$(BINDIR)/proxy" ./proxy/... clean: rm -f $(EASYJSON_GO_FILES) From f071a647972a1bef1830e9fd922b50b579a96821 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 7 Feb 2024 11:44:23 +0100 Subject: [PATCH 8/8] make: Mark generated files as ".SECONDARY". --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 6e17cd5..735edea 100644 --- a/Makefile +++ b/Makefile @@ -166,4 +166,5 @@ dist: tarball .NOTPARALLEL: $(EASYJSON_GO_FILES) .PHONY: continentmap.go common vendor +.SECONDARY: $(EASYJSON_GO_FILES) $(PROTO_GO_FILES) .DELETE_ON_ERROR: