sing-box/Makefile

113 lines
3.1 KiB
Makefile
Raw Normal View History

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