2020-05-12 09:46:20 +02:00
|
|
|
all: build
|
|
|
|
|
|
|
|
GO := $(shell which go)
|
2022-04-05 10:17:33 +02:00
|
|
|
GOPATH := $(shell "$(GO)" env GOPATH)
|
2022-04-05 11:29:56 +02:00
|
|
|
GODIR := $(shell dirname "$(GO)")
|
|
|
|
GOFMT := "$(GODIR)/gofmt"
|
2020-12-18 19:11:55 +01:00
|
|
|
GOOS ?= linux
|
|
|
|
GOARCH ?= amd64
|
2022-03-23 11:11:36 +01:00
|
|
|
GOVERSION := $(shell "$(GO)" env GOVERSION | sed "s|go||" )
|
2024-02-07 11:43:41 +01:00
|
|
|
BINDIR := $(CURDIR)/bin
|
2022-07-27 14:05:25 +02:00
|
|
|
VENDORDIR := "$(CURDIR)/vendor"
|
2020-05-12 09:46:20 +02:00
|
|
|
VERSION := $(shell "$(CURDIR)/scripts/get-version.sh")
|
|
|
|
TARVERSION := $(shell "$(CURDIR)/scripts/get-version.sh" --tar)
|
2022-03-23 13:12:50 +01:00
|
|
|
PACKAGENAME := github.com/strukturag/nextcloud-spreed-signaling
|
2022-03-23 13:28:40 +01:00
|
|
|
ALL_PACKAGES := $(PACKAGENAME) $(PACKAGENAME)/client $(PACKAGENAME)/proxy $(PACKAGENAME)/server
|
2024-02-07 11:29:45 +01:00
|
|
|
PROTO_FILES := $(basename $(wildcard *.proto))
|
|
|
|
PROTO_GO_FILES := $(addsuffix .pb.go,$(PROTO_FILES)) $(addsuffix _grpc.pb.go,$(PROTO_FILES))
|
2024-02-07 11:31:34 +01:00
|
|
|
EASYJSON_GO_FILES := \
|
|
|
|
api_async_easyjson.go \
|
|
|
|
api_backend_easyjson.go \
|
|
|
|
api_grpc_easyjson.go \
|
|
|
|
api_proxy_easyjson.go \
|
|
|
|
api_signaling_easyjson.go
|
2022-03-23 13:28:40 +01:00
|
|
|
|
2020-05-12 09:46:20 +02:00
|
|
|
ifneq ($(VERSION),)
|
|
|
|
INTERNALLDFLAGS := -X main.version=$(VERSION)
|
|
|
|
else
|
|
|
|
INTERNALLDFLAGS :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(RACE),)
|
|
|
|
BUILDARGS := -race
|
|
|
|
else
|
|
|
|
BUILDARGS :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(CI),)
|
|
|
|
TESTARGS := -race
|
|
|
|
else
|
|
|
|
TESTARGS :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(TIMEOUT),)
|
|
|
|
TIMEOUT := 60s
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(TEST),)
|
2023-12-22 22:37:12 +01:00
|
|
|
TESTARGS := $(TESTARGS) -run "$(TEST)"
|
2020-05-12 09:46:20 +02:00
|
|
|
endif
|
|
|
|
|
2020-07-31 13:49:52 +02:00
|
|
|
ifneq ($(COUNT),)
|
|
|
|
TESTARGS := $(TESTARGS) -count $(COUNT)
|
|
|
|
endif
|
|
|
|
|
2021-07-03 14:47:11 +02:00
|
|
|
ifeq ($(GOARCH), amd64)
|
2022-04-05 10:17:33 +02:00
|
|
|
GOPATHBIN := $(GOPATH)/bin
|
2021-07-03 14:47:11 +02:00
|
|
|
else
|
2022-04-05 10:17:33 +02:00
|
|
|
GOPATHBIN := $(GOPATH)/bin/$(GOOS)_$(GOARCH)
|
2021-07-03 14:47:11 +02:00
|
|
|
endif
|
|
|
|
|
2020-05-12 09:46:20 +02:00
|
|
|
hook:
|
|
|
|
[ ! -d "$(CURDIR)/.git/hooks" ] || ln -sf "$(CURDIR)/scripts/pre-commit.hook" "$(CURDIR)/.git/hooks/pre-commit"
|
|
|
|
|
2024-02-07 11:23:45 +01:00
|
|
|
$(GOPATHBIN)/easyjson: go.mod go.sum
|
2022-07-27 14:05:25 +02:00
|
|
|
[ "$(GOPROXY)" = "off" ] || $(GO) get -u -d github.com/mailru/easyjson/...
|
2022-04-05 10:17:33 +02:00
|
|
|
$(GO) install github.com/mailru/easyjson/...
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2024-02-07 11:23:45 +01:00
|
|
|
$(GOPATHBIN)/protoc-gen-go: go.mod go.sum
|
2022-06-21 16:04:40 +02:00
|
|
|
$(GO) install google.golang.org/protobuf/cmd/protoc-gen-go
|
|
|
|
|
2024-02-07 11:23:45 +01:00
|
|
|
$(GOPATHBIN)/protoc-gen-go-grpc: go.mod go.sum
|
2022-07-27 14:05:25 +02:00
|
|
|
[ "$(GOPROXY)" = "off" ] || $(GO) get -u -d google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
2022-06-21 16:04:40 +02:00
|
|
|
$(GO) install google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
|
|
|
|
2021-04-09 16:15:00 +02:00
|
|
|
continentmap.go:
|
2020-05-12 09:46:20 +02:00
|
|
|
$(CURDIR)/scripts/get_continent_map.py $@
|
|
|
|
|
2020-07-31 11:41:40 +02:00
|
|
|
check-continentmap:
|
|
|
|
set -e ;\
|
|
|
|
TMP=$$(mktemp -d) ;\
|
|
|
|
echo Make sure to remove $$TMP on error ;\
|
|
|
|
$(CURDIR)/scripts/get_continent_map.py $$TMP/continentmap.go ;\
|
2021-04-09 16:15:00 +02:00
|
|
|
diff -u continentmap.go $$TMP/continentmap.go ;\
|
2020-07-31 11:41:40 +02:00
|
|
|
rm -rf $$TMP
|
|
|
|
|
2020-05-12 09:46:20 +02:00
|
|
|
get:
|
2022-04-05 10:17:33 +02:00
|
|
|
$(GO) get $(PACKAGE)
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2024-02-07 11:29:45 +01:00
|
|
|
fmt: hook | $(PROTO_GO_FILES)
|
2022-02-25 09:20:26 +01:00
|
|
|
$(GOFMT) -s -w *.go client proxy server
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2021-04-09 16:15:00 +02:00
|
|
|
vet: common
|
2022-03-23 13:28:40 +01:00
|
|
|
$(GO) vet $(ALL_PACKAGES)
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2021-04-09 16:15:00 +02:00
|
|
|
test: vet common
|
2022-03-23 13:28:40 +01:00
|
|
|
$(GO) test -v -timeout $(TIMEOUT) $(TESTARGS) $(ALL_PACKAGES)
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2021-04-09 16:15:00 +02:00
|
|
|
cover: vet common
|
2020-05-12 09:46:20 +02:00
|
|
|
rm -f cover.out && \
|
2022-04-05 10:17:33 +02:00
|
|
|
$(GO) test -v -timeout $(TIMEOUT) -coverprofile cover.out $(ALL_PACKAGES) && \
|
2020-05-12 09:46:20 +02:00
|
|
|
sed -i "/_easyjson/d" cover.out && \
|
2022-06-21 16:04:40 +02:00
|
|
|
sed -i "/\.pb\.go/d" cover.out && \
|
2022-04-05 10:17:33 +02:00
|
|
|
$(GO) tool cover -func=cover.out
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2021-04-09 16:15:00 +02:00
|
|
|
coverhtml: vet common
|
2020-05-12 09:46:20 +02:00
|
|
|
rm -f cover.out && \
|
2022-04-05 10:17:33 +02:00
|
|
|
$(GO) test -v -timeout $(TIMEOUT) -coverprofile cover.out $(ALL_PACKAGES) && \
|
2020-05-12 09:46:20 +02:00
|
|
|
sed -i "/_easyjson/d" cover.out && \
|
2022-06-21 16:04:40 +02:00
|
|
|
sed -i "/\.pb\.go/d" cover.out && \
|
2022-04-05 10:17:33 +02:00
|
|
|
$(GO) tool cover -html=cover.out -o coverage.html
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2024-02-07 11:29:45 +01:00
|
|
|
%_easyjson.go: %.go $(GOPATHBIN)/easyjson | $(PROTO_GO_FILES)
|
2024-02-07 11:39:26 +01:00
|
|
|
rm -f easyjson-bootstrap*.go
|
2022-04-05 11:29:56 +02:00
|
|
|
PATH="$(GODIR)":$(PATH) "$(GOPATHBIN)/easyjson" -all $*.go
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2022-06-21 16:04:40 +02:00
|
|
|
%.pb.go: %.proto $(GOPATHBIN)/protoc-gen-go $(GOPATHBIN)/protoc-gen-go-grpc
|
2024-02-07 11:25:46 +01:00
|
|
|
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 \
|
2022-06-21 16:04:40 +02:00
|
|
|
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
|
|
|
|
$*.proto
|
|
|
|
|
2024-02-07 11:31:34 +01:00
|
|
|
common: $(EASYJSON_GO_FILES) $(PROTO_GO_FILES)
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2021-01-05 08:57:14 +01:00
|
|
|
$(BINDIR):
|
2024-02-07 11:43:41 +01:00
|
|
|
mkdir -p "$(BINDIR)"
|
2021-01-05 08:57:14 +01:00
|
|
|
|
2021-04-09 16:15:00 +02:00
|
|
|
client: common $(BINDIR)
|
2024-02-07 11:43:41 +01:00
|
|
|
$(GO) build $(BUILDARGS) -ldflags '$(INTERNALLDFLAGS)' -o "$(BINDIR)/client" ./client/...
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2021-04-09 16:15:00 +02:00
|
|
|
server: common $(BINDIR)
|
2024-02-07 11:43:41 +01:00
|
|
|
$(GO) build $(BUILDARGS) -ldflags '$(INTERNALLDFLAGS)' -o "$(BINDIR)/signaling" ./server/...
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2021-04-09 16:15:00 +02:00
|
|
|
proxy: common $(BINDIR)
|
2024-02-07 11:43:41 +01:00
|
|
|
$(GO) build $(BUILDARGS) -ldflags '$(INTERNALLDFLAGS)' -o "$(BINDIR)/proxy" ./proxy/...
|
2020-08-07 11:01:09 +02:00
|
|
|
|
2020-05-12 09:46:20 +02:00
|
|
|
clean:
|
2024-02-07 11:31:34 +01:00
|
|
|
rm -f $(EASYJSON_GO_FILES)
|
2022-06-24 13:01:03 +02:00
|
|
|
rm -f easyjson-bootstrap*.go
|
2024-02-07 11:29:45 +01:00
|
|
|
rm -f $(PROTO_GO_FILES)
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2020-08-07 11:01:09 +02:00
|
|
|
build: server proxy
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2022-07-27 14:05:25 +02:00
|
|
|
vendor: go.mod go.sum common
|
|
|
|
set -e ;\
|
|
|
|
rm -rf $(VENDORDIR)
|
|
|
|
$(GO) mod tidy; \
|
2023-06-07 17:18:25 +02:00
|
|
|
$(GO) mod vendor
|
2022-07-27 14:05:25 +02:00
|
|
|
|
|
|
|
tarball: vendor
|
2020-05-12 09:46:20 +02:00
|
|
|
git archive \
|
|
|
|
--prefix=nextcloud-spreed-signaling-$(TARVERSION)/ \
|
2022-07-27 14:05:25 +02:00
|
|
|
-o nextcloud-spreed-signaling-$(TARVERSION).tar \
|
2020-05-12 09:46:20 +02:00
|
|
|
HEAD
|
2022-07-27 14:05:25 +02:00
|
|
|
tar rf nextcloud-spreed-signaling-$(TARVERSION).tar \
|
|
|
|
-C $(CURDIR) \
|
|
|
|
--mtime="$(shell git log -1 --date=iso8601-strict --format=%cd HEAD)" \
|
|
|
|
--transform "s//nextcloud-spreed-signaling-$(TARVERSION)\//" \
|
|
|
|
vendor
|
|
|
|
gzip --force nextcloud-spreed-signaling-$(TARVERSION).tar
|
2020-05-12 09:46:20 +02:00
|
|
|
|
|
|
|
dist: tarball
|
|
|
|
|
2024-02-07 11:31:34 +01:00
|
|
|
.NOTPARALLEL: $(EASYJSON_GO_FILES)
|
2024-02-07 11:41:59 +01:00
|
|
|
.PHONY: continentmap.go common vendor
|
2024-02-07 11:44:23 +01:00
|
|
|
.SECONDARY: $(EASYJSON_GO_FILES) $(PROTO_GO_FILES)
|
2024-02-07 11:39:26 +01:00
|
|
|
.DELETE_ON_ERROR:
|