Makefile 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. NAME = sing-box
  2. COMMIT = $(shell git rev-parse --short HEAD)
  3. TAGS ?= with_quic,with_clash_api
  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 github.com/golangci/golangci-lint/cmd/golangci-lint@latest
  28. test:
  29. @go test -v . && \
  30. pushd test && \
  31. go test -v . && \
  32. popd
  33. clean:
  34. rm -rf bin dist
  35. rm -f $(shell go env GOPATH)/sing-box
  36. update:
  37. git fetch
  38. git reset FETCH_HEAD --hard
  39. git clean -fdx