1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00

trim gopath for cleaner stack trace

This commit is contained in:
Darien Raymond 2017-02-23 11:59:32 +01:00
parent 3d72bb7f86
commit cadedeb26b
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -8,13 +8,22 @@ import (
)
func buildV2Ray(targetFile string, version string, goOS GoOS, goArch GoArch) error {
goPath := os.Getenv("GOPATH")
ldFlags := "-s"
if version != "custom" {
year, month, day := time.Now().UTC().Date()
today := fmt.Sprintf("%04d%02d%02d", year, int(month), day)
ldFlags = ldFlags + " -X v2ray.com/core.version=" + version + " -X v2ray.com/core.build=" + today
}
cmd := exec.Command("go", "build", "-tags", "json", "-o", targetFile, "-compiler", "gc", "-ldflags", ldFlags, "v2ray.com/core/main")
cmd := exec.Command(
"go", "build",
"-tags", "json",
"-o", targetFile,
"-compiler", "gc",
"-ldflags", ldFlags,
"-gcflags", "-trimpath="+goPath,
"-asmflags", "-trimpath="+goPath,
"v2ray.com/core/main")
cmd.Env = append(cmd.Env, "GOOS="+string(goOS), "GOARCH="+string(goArch), "CGO_ENABLED=0")
cmd.Env = append(cmd.Env, os.Environ()...)
output, err := cmd.CombinedOutput()