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
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Makefile 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. APP_DEPS := version.go
  6. GOLANGCI_LINT_VERSION := v1.10.2
  7. COMMON_BUILD_FLAGS := -ldflags="-s -w"
  8. MOD_ON := env GO111MODULE=on
  9. MOD_OFF := env GO111MODULE=auto
  10. # -----------------------------------------------------------------------------
  11. $(APP_NAME): $(APP_DEPS)
  12. @$(MOD_ON) go build $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  13. static-$(APP_NAME): $(APP_DEPS)
  14. @$(MOD_ON) env CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  15. $(APP_NAME)-%: GOOS=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f1 -d-)
  16. $(APP_NAME)-%: GOARCH=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f2 -d-)
  17. $(APP_NAME)-%: $(APP_DEPS) ccbuilds
  18. @$(MOD_ON) env "GOOS=$(GOOS)" "GOARCH=$(GOARCH)" \
  19. go build \
  20. $(COMMON_BUILD_FLAGS) \
  21. -o "./ccbuilds/$(APP_NAME)-$(GOOS)-$(GOARCH)"
  22. ccbuilds:
  23. @rm -rf ./ccbuilds && mkdir -p ./ccbuilds
  24. version.go:
  25. @$(MOD_ON) go generate main.go
  26. vendor: go.mod go.sum
  27. @$(MOD_ON) go mod vendor
  28. # -----------------------------------------------------------------------------
  29. .PHONY: all
  30. all: $(APP_NAME)
  31. .PHONY: static
  32. static: static-$(APP_NAME)
  33. .PHONY: crosscompile
  34. crosscompile: $(CC_BINARIES)
  35. .PHONY: crosscompile-dir
  36. crosscompile-dir:
  37. @rm -rf "$(CC_DIR)" && mkdir -p "$(CC_DIR)"
  38. .PHONY: test
  39. test: vendor $(APP_DEPS)
  40. @$(MOD_ON) go test -v ./...
  41. .PHONY: lint
  42. lint: vendor $(APP_DEPS)
  43. @$(MOD_OFF) golangci-lint run
  44. .PHONY: critic
  45. critic: vendor $(APP_DEPS)
  46. @$(MOD_OFF) gocritic check-project "$(ROOT_DIR)"
  47. .PHONY: clean
  48. clean:
  49. @git clean -xfd && \
  50. git reset --hard >/dev/null && \
  51. git submodule foreach --recursive sh -c 'git clean -xfd && git reset --hard' >/dev/null
  52. .PHONY: docker
  53. docker:
  54. @docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)"
  55. .PHONY: prepare
  56. prepare: install-lint install-critic
  57. .PHONY: install-lint
  58. install-lint:
  59. @curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
  60. | $(MOD_OFF) bash -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION)
  61. .PHONY: install-critic
  62. install-critic:
  63. @$(MOD_OFF) go get -u github.com/go-critic/go-critic/...