2015-10-17 18:50:51 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func buildV2Ray(targetFile string, version string, goOS GoOS, goArch GoArch) error {
|
|
|
|
ldFlags := "-s"
|
2015-10-18 07:14:34 -04:00
|
|
|
if version != "custom" {
|
2015-10-17 18:50:51 -04:00
|
|
|
year, month, day := time.Now().UTC().Date()
|
|
|
|
today := fmt.Sprintf("%04d%02d%02d", year, int(month), day)
|
|
|
|
ldFlags = ldFlags + " -X github.com/v2ray/v2ray-core.version=" + version + " -X github.com/v2ray/v2ray-core.build=" + today
|
|
|
|
}
|
2016-07-27 15:55:01 -04:00
|
|
|
cmd := exec.Command("go", "build", "-tags", "json", "-o", targetFile, "-compiler", "gc", "-ldflags", ldFlags, "github.com/v2ray/v2ray-core/shell/point/main")
|
2015-10-17 18:50:51 -04:00
|
|
|
cmd.Env = append(cmd.Env, "GOOS="+string(goOS), "GOARCH="+string(goArch))
|
|
|
|
cmd.Env = append(cmd.Env, os.Environ()...)
|
2015-10-18 07:14:34 -04:00
|
|
|
output, err := cmd.CombinedOutput()
|
|
|
|
if len(output) > 0 {
|
|
|
|
fmt.Println(string(output))
|
|
|
|
}
|
2015-10-17 18:50:51 -04:00
|
|
|
return err
|
|
|
|
}
|