mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-22 16:41:30 +00:00
102 lines
2.8 KiB
Makefile
102 lines
2.8 KiB
Makefile
NAME = sing-box
|
|
COMMIT = $(shell git rev-parse --short HEAD)
|
|
TAGS ?= with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_reality_server,with_clash_api
|
|
TAGS_TEST ?= with_gvisor,with_quic,with_wireguard,with_grpc,with_ech,with_utls,with_reality_server,with_shadowsocksr
|
|
|
|
GOHOSTOS = $(shell go env GOHOSTOS)
|
|
GOHOSTARCH = $(shell go env GOHOSTARCH)
|
|
VERSION=$(shell CGO_ENABLED=0 GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go run ./cmd/internal/read_tag)
|
|
|
|
PARAMS = -v -trimpath -tags "$(TAGS)" -ldflags "-X 'github.com/sagernet/sing-box/constant.Version=$(VERSION)' -s -w -buildid="
|
|
MAIN = ./cmd/sing-box
|
|
PREFIX ?= $(shell go env GOPATH)
|
|
|
|
.PHONY: test release
|
|
|
|
build:
|
|
go build $(PARAMS) $(MAIN)
|
|
|
|
install:
|
|
go build -o $(PREFIX)/bin/$(NAME) $(PARAMS) $(MAIN)
|
|
|
|
fmt:
|
|
@gofumpt -l -w .
|
|
@gofmt -s -w .
|
|
@gci write --custom-order -s standard -s "prefix(github.com/sagernet/)" -s "default" .
|
|
|
|
fmt_install:
|
|
go install -v mvdan.cc/gofumpt@latest
|
|
go install -v github.com/daixiang0/gci@latest
|
|
|
|
lint:
|
|
GOOS=linux golangci-lint run ./...
|
|
GOOS=android golangci-lint run ./...
|
|
GOOS=windows golangci-lint run ./...
|
|
GOOS=darwin golangci-lint run ./...
|
|
GOOS=freebsd golangci-lint run ./...
|
|
|
|
lint_install:
|
|
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
|
|
proto:
|
|
@go run ./cmd/internal/protogen
|
|
@gofumpt -l -w .
|
|
@gofumpt -l -w .
|
|
|
|
proto_install:
|
|
go install -v google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
|
go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
|
|
|
snapshot:
|
|
go run ./cmd/internal/build goreleaser release --clean --snapshot || exit 1
|
|
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
|
|
|
|
release:
|
|
go run ./cmd/internal/build goreleaser release --clean --skip-publish || exit 1
|
|
mkdir dist/release
|
|
mv dist/*.tar.gz dist/*.zip dist/*.deb dist/*.rpm dist/release
|
|
ghr --delete --draft --prerelease -p 3 $(shell git describe --tags) dist/release
|
|
rm -r dist
|
|
|
|
release_install:
|
|
go install -v github.com/goreleaser/goreleaser@latest
|
|
go install -v github.com/tcnksm/ghr@latest
|
|
|
|
test:
|
|
@go test -v ./... && \
|
|
cd test && \
|
|
go mod tidy && \
|
|
go test -v -tags "$(TAGS_TEST)" .
|
|
|
|
test_stdio:
|
|
@go test -v ./... && \
|
|
cd test && \
|
|
go mod tidy && \
|
|
go test -v -tags "$(TAGS_TEST),force_stdio" .
|
|
|
|
android:
|
|
go run ./cmd/internal/build_libbox -target android
|
|
|
|
ios:
|
|
go run ./cmd/internal/build_libbox -target ios
|
|
|
|
lib:
|
|
go run ./cmd/internal/build_libbox -target android
|
|
go run ./cmd/internal/build_libbox -target ios
|
|
|
|
lib_install:
|
|
go get -v -d
|
|
go install -v github.com/sagernet/gomobile/cmd/gomobile@v0.0.0-20230701084532-493ee2e45182
|
|
go install -v github.com/sagernet/gomobile/cmd/gobind@v0.0.0-20230701084532-493ee2e45182
|
|
|
|
clean:
|
|
rm -rf bin dist sing-box
|
|
rm -f $(shell go env GOPATH)/sing-box
|
|
|
|
update:
|
|
git fetch
|
|
git reset FETCH_HEAD --hard
|
|
git clean -fdx
|