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 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
  2. IMAGE_NAME := mtg
  3. APP_NAME := $(IMAGE_NAME)
  4. VENDOR_FILES := $(shell find "$(ROOT_DIR)/vendor" 2>/dev/null || echo -n "vendor")
  5. CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
  6. APP_DEPS := version.go $(VENDOR_FILES)
  7. GOLANGCI_LINT_VERSION := v1.9.1
  8. COMMON_BUILD_FLAGS := -ldflags="-s -w"
  9. # -----------------------------------------------------------------------------
  10. $(APP_NAME): $(APP_DEPS)
  11. @go build $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  12. static-$(APP_NAME): $(APP_DEPS)
  13. @env CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
  14. $(APP_NAME)-%: GOOS=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f1 -d-)
  15. $(APP_NAME)-%: GOARCH=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f2 -d-)
  16. $(APP_NAME)-%: $(APP_DEPS) ccbuilds
  17. @env "GOOS=$(GOOS)" "GOARCH=$(GOARCH)" \
  18. go build \
  19. $(COMMON_BUILD_FLAGS) \
  20. -o "./ccbuilds/$(APP_NAME)-$(GOOS)-$(GOARCH)"
  21. ccbuilds:
  22. @rm -rf ./ccbuilds && mkdir -p ./ccbuilds
  23. version.go:
  24. @go generate main.go
  25. vendor: Gopkg.lock Gopkg.toml
  26. @dep ensure --vendor-only
  27. # -----------------------------------------------------------------------------
  28. .PHONY: all
  29. all: $(APP_NAME)
  30. .PHONY: static
  31. static: static-$(APP_NAME)
  32. .PHONY: crosscompile
  33. crosscompile: $(CC_BINARIES)
  34. .PHONY: crosscompile-dir
  35. crosscompile-dir:
  36. @rm -rf "$(CC_DIR)" && mkdir -p "$(CC_DIR)"
  37. .PHONY: test
  38. test: vendor version.go
  39. @go test -v ./...
  40. .PHONY: lint
  41. lint: version.go
  42. @golangci-lint run
  43. .PHONY: critic
  44. critic: version.go
  45. @gocritic check-project "$(ROOT_DIR)"
  46. .PHONY: clean
  47. clean:
  48. @git clean -xfd && \
  49. git reset --hard >/dev/null && \
  50. git submodule foreach --recursive sh -c 'git clean -xfd && git reset --hard' >/dev/null
  51. .PHONY: docker
  52. docker:
  53. @docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)"
  54. .PHONY: prepare
  55. prepare: install-dep install-lint install-critic
  56. .PHONY: install-dep
  57. install-dep:
  58. @go get -u github.com/golang/dep/cmd/dep
  59. .PHONY: install-lint
  60. install-lint:
  61. @curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
  62. | bash -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION)
  63. .PHONY: install-critic
  64. install-critic:
  65. @go get -u github.com/go-critic/go-critic/...