mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-24 17:41:29 +00:00
Print tags in version command
This commit is contained in:
parent
189f02c802
commit
9aa7a20d96
|
@ -9,7 +9,7 @@ builds:
|
||||||
gcflags:
|
gcflags:
|
||||||
- all=-trimpath={{.Env.GOPATH}}
|
- all=-trimpath={{.Env.GOPATH}}
|
||||||
ldflags:
|
ldflags:
|
||||||
- -X github.com/sagernet/sing-box/constant.Commit={{ .ShortCommit }} -s -w -buildid=
|
- -s -w -buildid=
|
||||||
tags:
|
tags:
|
||||||
- with_quic
|
- with_quic
|
||||||
- with_wireguard
|
- with_wireguard
|
||||||
|
|
|
@ -10,7 +10,7 @@ RUN set -ex \
|
||||||
&& export COMMIT=$(git rev-parse --short HEAD) \
|
&& export COMMIT=$(git rev-parse --short HEAD) \
|
||||||
&& go build -v -trimpath -tags 'no_gvisor,with_quic,with_wireguard,with_acme' \
|
&& go build -v -trimpath -tags 'no_gvisor,with_quic,with_wireguard,with_acme' \
|
||||||
-o /go/bin/sing-box \
|
-o /go/bin/sing-box \
|
||||||
-ldflags "-X github.com/sagernet/sing-box/constant.Commit=${COMMIT} -w -s -buildid=" \
|
-ldflags "-s -w -buildid=" \
|
||||||
./cmd/sing-box
|
./cmd/sing-box
|
||||||
FROM alpine AS dist
|
FROM alpine AS dist
|
||||||
LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
|
LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -1,9 +1,7 @@
|
||||||
NAME = sing-box
|
NAME = sing-box
|
||||||
COMMIT = $(shell git rev-parse --short HEAD)
|
COMMIT = $(shell git rev-parse --short HEAD)
|
||||||
TAGS ?= with_quic,with_wireguard,with_clash_api
|
TAGS ?= with_quic,with_wireguard,with_clash_api
|
||||||
PARAMS = -v -trimpath -tags '$(TAGS)' -ldflags \
|
PARAMS = -v -trimpath -tags '$(TAGS)' -ldflags '-s -w -buildid='
|
||||||
'-X "github.com/sagernet/sing-box/constant.Commit=$(COMMIT)" \
|
|
||||||
-w -s -buildid='
|
|
||||||
MAIN = ./cmd/sing-box
|
MAIN = ./cmd/sing-box
|
||||||
|
|
||||||
.PHONY: test release
|
.PHONY: test release
|
||||||
|
|
|
@ -3,9 +3,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
C "github.com/sagernet/sing-box/constant"
|
C "github.com/sagernet/sing-box/constant"
|
||||||
F "github.com/sagernet/sing/common/format"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -25,30 +25,40 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func printVersion(cmd *cobra.Command, args []string) {
|
func printVersion(cmd *cobra.Command, args []string) {
|
||||||
var version string
|
if nameOnly {
|
||||||
if !nameOnly {
|
os.Stdout.WriteString(C.Version + "\n")
|
||||||
version = "sing-box "
|
return
|
||||||
}
|
}
|
||||||
version += F.ToString(C.Version)
|
version := "sing-box version " + C.Version + "\n\n"
|
||||||
if C.Commit != "" {
|
version += "Environment: " + runtime.Version() + " " + runtime.GOOS + "/" + runtime.GOARCH + "\n"
|
||||||
version += "." + C.Commit
|
|
||||||
}
|
var tags string
|
||||||
if !nameOnly {
|
var revision string
|
||||||
version += " ("
|
|
||||||
version += runtime.Version()
|
debugInfo, loaded := debug.ReadBuildInfo()
|
||||||
version += ", "
|
if loaded {
|
||||||
version += runtime.GOOS
|
for _, setting := range debugInfo.Settings {
|
||||||
version += "/"
|
switch setting.Key {
|
||||||
version += runtime.GOARCH
|
case "-tags":
|
||||||
version += ", "
|
tags = setting.Value
|
||||||
version += "CGO "
|
case "vcs.revision":
|
||||||
if C.CGO_ENABLED {
|
revision = setting.Value
|
||||||
version += "enabled"
|
}
|
||||||
} else {
|
|
||||||
version += "disabled"
|
|
||||||
}
|
}
|
||||||
version += ")"
|
|
||||||
}
|
}
|
||||||
version += "\n"
|
|
||||||
|
if tags != "" {
|
||||||
|
version += "Tags: " + tags + "\n"
|
||||||
|
}
|
||||||
|
if revision != "" {
|
||||||
|
version += "Revision: " + revision + "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
if C.CGO_ENABLED {
|
||||||
|
version += "CGO: enabled\n"
|
||||||
|
} else {
|
||||||
|
version += "CGO: disabled\n"
|
||||||
|
}
|
||||||
|
|
||||||
os.Stdout.WriteString(version)
|
os.Stdout.WriteString(version)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
package constant
|
package constant
|
||||||
|
|
||||||
var (
|
var Version = "1.1-beta4"
|
||||||
Version = "1.1-beta4"
|
|
||||||
Commit = ""
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in a new issue