sing-box/cmd/internal/build/main.go

36 lines
737 B
Go
Raw Normal View History

2022-12-11 14:38:01 +08:00
package main
import (
"os"
"os/exec"
2023-03-08 15:08:59 +08:00
"strings"
2022-12-11 14:38:01 +08:00
2022-10-25 12:55:00 +08:00
"github.com/sagernet/sing-box/cmd/internal/build_shared"
C "github.com/sagernet/sing-box/constant"
2022-12-11 14:38:01 +08:00
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing/common"
2022-12-11 14:38:01 +08:00
)
func main() {
2022-10-25 12:55:00 +08:00
build_shared.FindSDK()
2022-12-11 14:38:01 +08:00
currentTag, err := common.Exec("git", "describe", "--tags", "--abbrev=0").Read()
if err != nil {
log.Fatal(err)
}
2023-03-08 15:08:59 +08:00
currentTag = strings.TrimSpace(currentTag)
if "v"+C.Version != currentTag {
2023-03-08 15:08:59 +08:00
log.Fatal("version mismatch, update constant.Version (", C.Version, ")", " to ", currentTag[1:])
}
2022-12-11 14:38:01 +08:00
command := exec.Command(os.Args[1], os.Args[2:]...)
command.Stdout = os.Stdout
command.Stderr = os.Stderr
err = command.Run()
2022-12-11 14:38:01 +08:00
if err != nil {
log.Fatal(err)
}
}