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||" )
|
2020-05-12 09:46:20 +02: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
|
|
|
|
|
2022-07-27 14:05:25 +02:00
|
|
|
PROTOC_GEN_GRPC_VERSION := v1.2.0
|
|
|
|
|
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),)
|
|
|
|
TESTARGS := $(TESTARGS) -run $(TEST)
|
|
|
|
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"
|
|
|
|
|
2022-04-11 10:22:05 +02:00
|
|
|
$(GOPATHBIN)/easyjson:
|
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
|
|
|
|
2022-06-21 16:04:40 +02:00
|
|
|
$(GOPATHBIN)/protoc-gen-go:
|
|
|
|
$(GO) install google.golang.org/protobuf/cmd/protoc-gen-go
|
|
|
|
|
|
|
|
$(GOPATHBIN)/protoc-gen-go-grpc:
|
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
|
|
|
|
2022-06-21 16:04:40 +02:00
|
|
|
fmt: hook | common_proto
|
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
|
|
|
|
2022-06-21 16:04:40 +02:00
|
|
|
%_easyjson.go: %.go $(GOPATHBIN)/easyjson | common_proto
|
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
|
|
|
|
PATH="$(GODIR)":"$(GOPATHBIN)":$(PATH) protoc --go_out=. --go_opt=paths=source_relative \
|
|
|
|
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
|
|
|
|
$*.proto
|
|
|
|
|
|
|
|
common: common_easyjson common_proto
|
|
|
|
|
|
|
|
common_easyjson: \
|
2022-06-14 17:01:57 +02:00
|
|
|
api_async_easyjson.go \
|
2021-04-09 16:15:00 +02:00
|
|
|
api_backend_easyjson.go \
|
2022-06-28 13:55:24 +02:00
|
|
|
api_grpc_easyjson.go \
|
2021-04-09 16:15:00 +02:00
|
|
|
api_proxy_easyjson.go \
|
2022-06-14 17:01:57 +02:00
|
|
|
api_signaling_easyjson.go
|
2020-05-12 09:46:20 +02:00
|
|
|
|
2022-06-21 16:04:40 +02:00
|
|
|
common_proto: \
|
2022-07-13 11:52:20 +02:00
|
|
|
grpc_backend.pb.go \
|
2022-06-29 13:33:02 +02:00
|
|
|
grpc_internal.pb.go \
|
2022-06-21 16:04:40 +02:00
|
|
|
grpc_mcu.pb.go \
|
|
|
|
grpc_sessions.pb.go
|
|
|
|
|
2021-01-05 08:57:14 +01:00
|
|
|
$(BINDIR):
|
2020-05-12 09:46:20 +02:00
|
|
|
mkdir -p $(BINDIR)
|
2021-01-05 08:57:14 +01:00
|
|
|
|
2021-04-09 16:15:00 +02:00
|
|
|
client: common $(BINDIR)
|
2022-04-05 10:17:33 +02: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)
|
2022-04-05 10:17:33 +02: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)
|
2022-04-05 10:17:33 +02: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:
|
2021-04-09 16:15:00 +02:00
|
|
|
rm -f *_easyjson.go
|
2022-06-24 13:01:03 +02:00
|
|
|
rm -f easyjson-bootstrap*.go
|
2022-06-21 16:04:40 +02:00
|
|
|
rm -f *.pb.go
|
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)
|
|
|
|
EASYJSON_DIR=$$($(GO) list -m -f '{{.Dir}}' github.com/mailru/easyjson); \
|
|
|
|
PROTOBUF_DIR=$$($(GO) list -m -f '{{.Dir}}' google.golang.org/protobuf); \
|
|
|
|
$(GO) mod tidy; \
|
|
|
|
$(GO) mod vendor; \
|
|
|
|
mkdir -p $(VENDORDIR)/github.com/mailru/easyjson/; \
|
|
|
|
cp -rf --no-preserve=mode $$EASYJSON_DIR/easyjson/ $(VENDORDIR)/github.com/mailru/easyjson/; \
|
|
|
|
mkdir -p $(VENDORDIR)/google.golang.org/grpc/cmd/protoc-gen-go-grpc/; \
|
|
|
|
cp -rf --no-preserve=mode $(GOPATH)/pkg/mod/google.golang.org/grpc/cmd/protoc-gen-go-grpc@$(PROTOC_GEN_GRPC_VERSION)/* $(VENDORDIR)/google.golang.org/grpc/cmd/protoc-gen-go-grpc/; \
|
|
|
|
cp -rf --no-preserve=mode $$PROTOBUF_DIR/cmd/ $(VENDORDIR)/google.golang.org/protobuf/; \
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-01-07 09:20:16 +01:00
|
|
|
.NOTPARALLEL: %_easyjson.go
|
2022-07-27 14:05:25 +02:00
|
|
|
.PHONY: continentmap.go vendor
|