Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
  2. IMAGE_NAME := mtg
  3. APP_NAME := $(IMAGE_NAME)
  4. CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
  5. GOLANGCI_LINT_VERSION := v1.31.0
  6. VERSION_GO := $(shell go version)
  7. VERSION_DATE := $(shell date -Ru)
  8. VERSION_TAG := $(shell git describe --tags --always)
  9. COMMON_BUILD_FLAGS := -mod=readonly -ldflags="-s -w -X 'main.version=$(VERSION_TAG) ($(VERSION_GO)) [$(VERSION_DATE)]'"
  10. GOBIN := $(ROOT_DIR)/.bin
  11. GOTOOL := env "GOBIN=$(GOBIN)" "PATH=$(ROOT_DIR)/.bin:$(PATH)"
  12. # -----------------------------------------------------------------------------
  13. .PHONY: all
  14. all: build
  15. .PHONY: build
  16. build: $(APP_NAME)
  17. $(APP_NAME):
  18. @go build $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  19. static-$(APP_NAME):
  20. @env CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  21. $(APP_NAME)-%: GOOS=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f1 -d-)
  22. $(APP_NAME)-%: GOARCH=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f2 -d-)
  23. $(APP_NAME)-%: ccbuilds
  24. @env "GOOS=$(GOOS)" "GOARCH=$(GOARCH)" \
  25. go build \
  26. $(COMMON_BUILD_FLAGS) \
  27. -o "./ccbuilds/$(APP_NAME)-$(GOOS)-$(GOARCH)"
  28. ccbuilds:
  29. @rm -rf ./ccbuilds && mkdir -p ./ccbuilds
  30. vendor: go.mod go.sum
  31. @$(MOD_ON) go mod vendor
  32. .PHONY: test
  33. test:
  34. @go test -v ./...
  35. .PHONY: citest
  36. citest:
  37. @go test -coverprofile=coverage.txt -covermode=atomic -race -v ./...
  38. .PHONY: crosscompile
  39. crosscompile: $(CC_BINARIES)
  40. .PHONY: clean
  41. clean:
  42. @git clean -xfd && \
  43. git reset --hard >/dev/null && \
  44. git submodule foreach --recursive sh -c 'git clean -xfd && git reset --hard' >/dev/null
  45. .PHONY: lint
  46. lint:
  47. @$(GOTOOL) golangci-lint run
  48. .PHONY: docker
  49. docker:
  50. @docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)"
  51. .PHONY: doc
  52. doc:
  53. @$(GOTOOL) godoc -http 0.0.0.0:10000
  54. .PHONY: install-tools
  55. install-tools: install-tools-lint install-tools-godoc
  56. .PHONY: install-tools-lint
  57. install-tools-lint:
  58. @mkdir -p "$(GOBIN)" || true && \
  59. curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
  60. | bash -s -- -b "$(GOBIN)" "$(GOLANGCI_LINT_VERSION)"
  61. .PHONY: install-tools-godoc
  62. install-tools-godoc:
  63. @mkdir -p "$(GOBIN)" || true && \
  64. $(GOTOOL) go get -u golang.org/x/tools/cmd/godoc
  65. .PHONY: update-deps
  66. upgrade-deps:
  67. $go get -u && go mod tidy