2022-08-13 10:36:49 +00:00
|
|
|
NAME = sing-box
|
|
|
|
COMMIT = $(shell git rev-parse --short HEAD)
|
2022-08-21 05:03:19 +00:00
|
|
|
TAGS ?= with_quic,with_wireguard,with_clash_api
|
2022-08-14 16:25:49 +00:00
|
|
|
PARAMS = -v -trimpath -tags '$(TAGS)' -ldflags \
|
2022-08-12 14:53:46 +00:00
|
|
|
'-X "github.com/sagernet/sing-box/constant.Commit=$(COMMIT)" \
|
|
|
|
-w -s -buildid='
|
2022-08-13 10:36:49 +00:00
|
|
|
MAIN = ./cmd/sing-box
|
2022-08-12 14:53:46 +00:00
|
|
|
|
|
|
|
.PHONY: test release
|
|
|
|
|
|
|
|
build:
|
|
|
|
go build $(PARAMS) $(MAIN)
|
|
|
|
|
|
|
|
install:
|
|
|
|
go install $(PARAMS) $(MAIN)
|
|
|
|
|
|
|
|
fmt:
|
2022-08-13 10:36:49 +00:00
|
|
|
@gofumpt -l -w .
|
|
|
|
@gofmt -s -w .
|
|
|
|
@gci write -s "standard,prefix(github.com/sagernet/),default" .
|
2022-08-12 14:53:46 +00:00
|
|
|
|
2022-08-14 16:25:49 +00:00
|
|
|
fmt_install:
|
|
|
|
go install -v mvdan.cc/gofumpt@latest
|
|
|
|
go install -v github.com/daixiang0/gci@v0.4.0
|
2022-08-12 14:53:46 +00:00
|
|
|
|
|
|
|
lint:
|
|
|
|
GOOS=linux golangci-lint run ./...
|
2022-08-17 12:15:35 +00:00
|
|
|
GOOS=android golangci-lint run ./...
|
2022-08-12 14:53:46 +00:00
|
|
|
GOOS=windows golangci-lint run ./...
|
|
|
|
GOOS=darwin golangci-lint run ./...
|
|
|
|
GOOS=freebsd golangci-lint run ./...
|
|
|
|
|
2022-08-14 16:25:49 +00:00
|
|
|
lint_install:
|
2022-08-21 05:03:19 +00:00
|
|
|
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
|
|
|
|
|
|
snapshot:
|
|
|
|
goreleaser release --rm-dist --snapshot
|
|
|
|
mkdir dist/release
|
|
|
|
mv dist/*.tar.gz dist/*.zip dist/*.deb dist/*.rpm dist/release
|
|
|
|
ghr --delete --draft --prerelease -p 1 nightly dist/release
|
|
|
|
rm -r dist
|
|
|
|
|
|
|
|
snapshot_install:
|
|
|
|
go install -v github.com/goreleaser/goreleaser@latest
|
|
|
|
go install -v github.com/tcnksm/ghr@latest
|
2022-08-14 16:25:49 +00:00
|
|
|
|
2022-08-12 14:53:46 +00:00
|
|
|
test:
|
2022-08-13 10:36:49 +00:00
|
|
|
@go test -v . && \
|
2022-08-17 12:10:59 +00:00
|
|
|
pushd test && \
|
2022-08-22 04:02:16 +00:00
|
|
|
go mod tidy && \
|
|
|
|
go test -v -tags '$(TAGS)' . && \
|
2022-08-17 12:10:59 +00:00
|
|
|
popd
|
2022-08-12 14:53:46 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf bin dist
|
|
|
|
rm -f $(shell go env GOPATH)/sing-box
|
|
|
|
|
|
|
|
update:
|
|
|
|
git fetch
|
|
|
|
git reset FETCH_HEAD --hard
|
|
|
|
git clean -fdx
|