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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.10.2
  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. @dep ensure --vendor-only
  57. .PHONY: install-dep
  58. install-dep:
  59. @go get -u github.com/golang/dep/cmd/dep
  60. .PHONY: install-lint
  61. install-lint:
  62. @curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
  63. | bash -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION)
  64. .PHONY: install-critic
  65. install-critic:
  66. @go get -u github.com/go-critic/go-critic/...