Makefile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. NAME = sing-box
  2. COMMIT = $(shell git rev-parse --short HEAD)
  3. TAGS ?= with_quic,with_wireguard,with_clash_api,with_daemon
  4. PARAMS = -v -trimpath -tags '$(TAGS)' -ldflags \
  5. '-X "github.com/sagernet/sing-box/constant.Commit=$(COMMIT)" \
  6. -w -s -buildid='
  7. MAIN = ./cmd/sing-box
  8. .PHONY: test release
  9. build:
  10. go build $(PARAMS) $(MAIN)
  11. install:
  12. go install $(PARAMS) $(MAIN)
  13. fmt:
  14. @gofumpt -l -w .
  15. @gofmt -s -w .
  16. @gci write -s "standard,prefix(github.com/sagernet/),default" .
  17. fmt_install:
  18. go install -v mvdan.cc/gofumpt@latest
  19. go install -v github.com/daixiang0/[email protected]
  20. lint:
  21. GOOS=linux golangci-lint run ./...
  22. GOOS=android golangci-lint run ./...
  23. GOOS=windows golangci-lint run ./...
  24. GOOS=darwin golangci-lint run ./...
  25. GOOS=freebsd golangci-lint run ./...
  26. lint_install:
  27. go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
  28. proto:
  29. @go run ./cmd/internal/protogen
  30. @gofumpt -l -w .
  31. @gofumpt -l -w .
  32. proto_install:
  33. go install -v google.golang.org/protobuf/cmd/protoc-gen-go@latest
  34. go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
  35. snapshot:
  36. goreleaser release --rm-dist --snapshot
  37. mkdir dist/release
  38. mv dist/*.tar.gz dist/*.zip dist/*.deb dist/*.rpm dist/release
  39. ghr --delete --draft --prerelease -p 1 nightly dist/release
  40. rm -r dist
  41. snapshot_install:
  42. go install -v github.com/goreleaser/goreleaser@latest
  43. go install -v github.com/tcnksm/ghr@latest
  44. test:
  45. @go test -v . && \
  46. pushd test && \
  47. go mod tidy && \
  48. go test -v -tags with_quic,with_wireguard,with_grpc . && \
  49. popd
  50. clean:
  51. rm -rf bin dist
  52. rm -f $(shell go env GOPATH)/sing-box
  53. update:
  54. git fetch
  55. git reset FETCH_HEAD --hard
  56. git clean -fdx