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.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
  2. IMAGE_NAME := mtg
  3. APP_NAME := $(IMAGE_NAME)
  4. GOLANGCI_LINT_VERSION := v1.42.0
  5. VERSION_GO := $(shell go version)
  6. VERSION_DATE := $(shell date -Ru)
  7. VERSION_TAG := $(shell git describe --tags --always)
  8. COMMON_BUILD_FLAGS := -trimpath -mod=readonly -ldflags="-extldflags '-static' -s -w -X 'main.version=$(VERSION_TAG) ($(VERSION_GO)) [$(VERSION_DATE)]'"
  9. GOBIN := $(ROOT_DIR)/.bin
  10. GOTOOL := env "GOBIN=$(GOBIN)" "PATH=$(ROOT_DIR)/.bin:$(PATH)"
  11. # -----------------------------------------------------------------------------
  12. .PHONY: all
  13. all: build
  14. .PHONY: build
  15. build:
  16. @go build $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  17. $(APP_NAME): build
  18. .PHONY: static
  19. static:
  20. @env CGO_ENABLED=0 GOOS=linux go build \
  21. $(COMMON_BUILD_FLAGS) \
  22. -tags netgo \
  23. -a \
  24. -o "$(APP_NAME)"
  25. vendor: go.mod go.sum
  26. @$(MOD_ON) go mod vendor
  27. .bin:
  28. @mkdir -p "$(GOBIN)" || true
  29. .PHONY: fmt
  30. fmt:
  31. @$(GOTOOL) gofumpt -w -s -extra "$(ROOT_DIR)"
  32. .PHONY: test
  33. test:
  34. @go test -v ./...
  35. .PHONY: citest
  36. citest:
  37. @go test -coverprofile=coverage.txt -covermode=atomic -parallel 2 -race -v ./...
  38. .PHONY: clean
  39. clean:
  40. @git clean -xfd && \
  41. git reset --hard >/dev/null && \
  42. git submodule foreach --recursive sh -c 'git clean -xfd && git reset --hard' >/dev/null
  43. .PHONY: lint
  44. lint:
  45. @$(GOTOOL) golangci-lint run
  46. .PHONY: release
  47. release:
  48. @$(GOTOOL) goreleaser release --snapshot --rm-dist && \
  49. find "$(ROOT_DIR)/dist" -type d | grep -vP "dist$$" | xargs -r rm -rf && \
  50. rm -f "$(ROOT_DIR)/dist/config.yaml"
  51. .PHONY: docker
  52. docker:
  53. @docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)"
  54. .PHONY: doc
  55. doc:
  56. @$(GOTOOL) godoc -http 0.0.0.0:10000
  57. .PHONY: install-tools
  58. install-tools: install-tools-lint install-tools-godoc install-tools-gofumpt install-tools-goreleaser
  59. .PHONY: install-tools-lint
  60. install-tools-lint: .bin
  61. @curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
  62. | bash -s -- -b "$(GOBIN)" "$(GOLANGCI_LINT_VERSION)"
  63. .PHONY: install-tools-godoc
  64. install-tools-godoc: .bin
  65. @$(GOTOOL) go install golang.org/x/tools/cmd/godoc@latest
  66. .PHONY: install-tools-gofumpt
  67. install-tools-gofumpt: .bin
  68. @$(GOTOOL) go install mvdan.cc/gofumpt@latest
  69. .PHONY: goreleaser
  70. install-tools-goreleaser: .bin
  71. @$(GOTOOL) go install github.com/goreleaser/goreleaser@latest
  72. .PHONY: update-deps
  73. update-deps:
  74. @go get -u && go mod tidy