sing-box/Makefile

95 lines
2.7 KiB
Makefile
Raw Permalink Normal View History

2022-08-13 10:36:49 +00:00
NAME = sing-box
COMMIT = $(shell git rev-parse --short HEAD)
TAGS ?= with_gvisor,with_quic,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
2023-03-13 11:46:08 +00:00
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)
2023-03-19 08:57:07 +00:00
PARAMS = -v -trimpath -tags "$(TAGS)" -ldflags "-X 'github.com/sagernet/sing-box/constant.Version=$(VERSION)' -s -w -buildid="
2022-08-13 10:36:49 +00:00
MAIN = ./cmd/sing-box
2023-03-11 11:18:12 +00:00
PREFIX ?= $(shell go env GOPATH)
2022-08-12 14:53:46 +00:00
.PHONY: test release
build:
go build $(PARAMS) $(MAIN)
install:
2023-03-11 11:18:12 +00:00
go build -o $(PREFIX)/bin/$(NAME) $(PARAMS) $(MAIN)
2022-08-12 14:53:46 +00:00
fmt:
2022-08-13 10:36:49 +00:00
@gofumpt -l -w .
@gofmt -s -w .
2023-02-09 13:01:48 +00:00
@gci write --custom-order -s "standard,prefix(github.com/sagernet/),default" .
2022-08-12 14:53:46 +00:00
fmt_install:
go install -v mvdan.cc/gofumpt@latest
2023-02-09 13:01:48 +00:00
go install -v github.com/daixiang0/gci@latest
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 ./...
lint_install:
2022-08-21 05:03:19 +00:00
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest
2022-08-22 10:53:47 +00:00
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
2022-08-21 05:03:19 +00:00
snapshot:
2022-12-11 06:38:01 +00:00
go run ./cmd/internal/build goreleaser release --rm-dist --snapshot || exit 1
2022-08-21 05:03:19 +00:00
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
2022-08-26 08:33:12 +00:00
release:
2022-12-11 06:38:01 +00:00
go run ./cmd/internal/build goreleaser release --rm-dist --skip-publish || exit 1
2022-08-26 08:33:12 +00:00
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:
2022-08-21 05:03:19 +00:00
go install -v github.com/goreleaser/goreleaser@latest
go install -v github.com/tcnksm/ghr@latest
2022-08-12 14:53:46 +00:00
test:
2022-09-21 10:46:20 +00:00
@go test -v ./... && \
2022-09-14 04:56:45 +00:00
cd test && \
2022-08-22 04:02:16 +00:00
go mod tidy && \
2022-09-21 10:46:20 +00:00
go test -v -tags "$(TAGS_TEST)" .
2022-09-25 14:16:24 +00:00
2022-09-21 10:46:20 +00:00
test_stdio:
@go test -v ./... && \
cd test && \
go mod tidy && \
go test -v -tags "$(TAGS_TEST),force_stdio" .
2022-08-12 14:53:46 +00:00
2022-10-25 04:55:00 +00:00
lib:
go run ./cmd/internal/build_libbox
lib_install:
go get -v -d
go install -v github.com/sagernet/gomobile/cmd/gomobile@v0.0.0-20221130124640-349ebaa752ca
go install -v github.com/sagernet/gomobile/cmd/gobind@v0.0.0-20221130124640-349ebaa752ca
2022-08-12 14:53:46 +00:00
clean:
2022-09-25 14:16:24 +00:00
rm -rf bin dist sing-box
2022-08-12 14:53:46 +00:00
rm -f $(shell go env GOPATH)/sing-box
update:
git fetch
git reset FETCH_HEAD --hard
git clean -fdx