1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-20 14:35:23 +00:00

set version details use ldflags

This commit is contained in:
tnextday 2019-12-17 15:34:13 +08:00
parent 0be2dbc37b
commit e626d19ba1
2 changed files with 13 additions and 15 deletions

View File

@ -13,10 +13,12 @@ package core
//go:generate errorgen //go:generate errorgen
import ( import (
"runtime"
"v2ray.com/core/common/serial" "v2ray.com/core/common/serial"
) )
const ( var (
version = "4.21.3" version = "4.21.3"
build = "Custom" build = "Custom"
codename = "V2Fly, a community-driven edition of V2Ray." codename = "V2Fly, a community-driven edition of V2Ray."
@ -32,7 +34,7 @@ func Version() string {
// VersionStatement returns a list of strings representing the full version info. // VersionStatement returns a list of strings representing the full version info.
func VersionStatement() []string { func VersionStatement() []string {
return []string{ return []string{
serial.Concat("V2Ray ", Version(), " (", codename, ") ", build), serial.Concat("V2Ray ", Version(), " (", codename, ") ", build, " (", runtime.Version(), " ", runtime.GOOS, "/", runtime.GOARCH, ")"),
intro, intro,
} }
} }

View File

@ -17,9 +17,11 @@ __root="$(cd "$(dirname "${__dir}")" && pwd)" # <-- change this as it depends on
NOW=$(date '+%Y%m%d-%H%M%S') NOW=$(date '+%Y%m%d-%H%M%S')
TMP=$(mktemp -d) TMP=$(mktemp -d)
SRCDIR=$(pwd)
CODENAME="user" CODENAME="user"
BUILDNAME=$NOW BUILDNAME=$NOW
VERSIONTAG=$(git describe --tags)
GOPATH=$(go env GOPATH) GOPATH=$(go env GOPATH)
cleanup () { rm -rf $TMP; } cleanup () { rm -rf $TMP; }
@ -28,27 +30,21 @@ trap cleanup INT TERM ERR
get_source() { get_source() {
echo ">>> Getting v2ray sources ..." echo ">>> Getting v2ray sources ..."
go get -insecure -v -t v2ray.com/core/... go get -insecure -v -t v2ray.com/core/...
SRCDIR="$GOPATH/src/v2ray.com/core"
} }
build_v2() { build_v2() {
pushd $GOPATH/src/v2ray.com/core pushd $SRCDIR
echo ">>> Update source code name ..." LDFLAGS="-X v2ray.com/core.codename=${CODENAME} -X v2ray.com/core.build=${BUILDNAME} -X v2ray.com/core.version=${VERSIONTAG}"
sed -i "s/^[ \t]\+codename.\+$/\tcodename = \"${CODENAME}\"/;s/^[ \t]\+build.\+$/\tbuild = \"${BUILDNAME}\"/;" core.go
echo ">>> Compile v2ray ..." echo ">>> Compile v2ray ..."
pushd $GOPATH/src/v2ray.com/core/main env CGO_ENABLED=0 go build -o $TMP/v2ray${EXESUFFIX} -ldflags "-s -w $LDFLAGS" ./main
env CGO_ENABLED=0 go build -o $TMP/v2ray${EXESUFFIX} -ldflags "-s -w"
if [[ $GOOS == "windows" ]];then if [[ $GOOS == "windows" ]];then
env CGO_ENABLED=0 go build -o $TMP/wv2ray${EXESUFFIX} -ldflags "-s -w -H windowsgui" env CGO_ENABLED=0 go build -o $TMP/wv2ray${EXESUFFIX} -ldflags "-s -w -H windowsgui $LDFLAGS" ./main
fi fi
popd
git checkout -- core.go
popd
echo ">>> Compile v2ctl ..." echo ">>> Compile v2ctl ..."
pushd $GOPATH/src/v2ray.com/core/infra/control/main env CGO_ENABLED=0 go build -o $TMP/v2ctl${EXESUFFIX} -tags confonly -ldflags "-s -w $LDFLAGS" ./infra/control/main
env CGO_ENABLED=0 go build -o $TMP/v2ctl${EXESUFFIX} -tags confonly -ldflags "-s -w"
popd popd
} }
@ -66,7 +62,7 @@ build_dat() {
copyconf() { copyconf() {
echo ">>> Copying config..." echo ">>> Copying config..."
pushd $GOPATH/src/v2ray.com/core/release/config pushd $SRCDIR/release/config
tar c --exclude "*.dat" . | tar x -C $TMP tar c --exclude "*.dat" . | tar x -C $TMP
} }