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
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

Makefile 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.37.1
  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:
  17. @go build $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  18. $(APP_NAME): build
  19. .PHONY: static
  20. static:
  21. @env CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  22. $(APP_NAME)-%: GOOS=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f1 -d-)
  23. $(APP_NAME)-%: GOARCH=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f2 -d-)
  24. $(APP_NAME)-%: ccbuilds
  25. @env "GOOS=$(GOOS)" "GOARCH=$(GOARCH)" \
  26. go build \
  27. $(COMMON_BUILD_FLAGS) \
  28. -o "./ccbuilds/$(APP_NAME)-$(GOOS)-$(GOARCH)"
  29. .PHONY: ccbuilds
  30. ccbuilds:
  31. @rm -rf ./ccbuilds && mkdir -p ./ccbuilds
  32. vendor: go.mod go.sum
  33. @$(MOD_ON) go mod vendor
  34. .PHONY: fmt
  35. fmt:
  36. @$(GOTOOL) gofumpt -w -s -extra "$(ROOT_DIR)"
  37. .PHONY: test
  38. test:
  39. @go test -v ./...
  40. .PHONY: citest
  41. citest:
  42. @go test -coverprofile=coverage.txt -covermode=atomic -race -v ./...
  43. .PHONY: crosscompile
  44. crosscompile: $(CC_BINARIES)
  45. .PHONY: clean
  46. clean:
  47. @git clean -xfd && \
  48. git reset --hard >/dev/null && \
  49. git submodule foreach --recursive sh -c 'git clean -xfd && git reset --hard' >/dev/null
  50. .PHONY: lint
  51. lint:
  52. @$(GOTOOL) golangci-lint run
  53. .PHONY: docker
  54. docker:
  55. @docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)"
  56. .PHONY: doc
  57. doc:
  58. @$(GOTOOL) godoc -http 0.0.0.0:10000
  59. .PHONY: install-tools
  60. install-tools: install-tools-lint install-tools-godoc install-tools-gofumpt
  61. .PHONY: install-tools-lint
  62. install-tools-lint:
  63. @mkdir -p "$(GOBIN)" || true && \
  64. curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
  65. | bash -s -- -b "$(GOBIN)" "$(GOLANGCI_LINT_VERSION)"
  66. .PHONY: install-tools-godoc
  67. install-tools-godoc:
  68. @mkdir -p "$(GOBIN)" || true && \
  69. $(GOTOOL) go get -u golang.org/x/tools/cmd/godoc
  70. .PHONY: install-tools-gofumpt
  71. install-tools-gofumpt:
  72. @mkdir -p "$(GOBIN)" || true && \
  73. $(GOTOOL) go get -u mvdan.cc/gofumpt
  74. .PHONY: update-deps
  75. upgrade-deps:
  76. $go get -u && go mod tidy