forked from aksdb/CalAnonSync
65 lines
1.1 KiB
Go
65 lines
1.1 KiB
Go
// +build ignore
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
var reproducible = flag.Bool("r", false, "If set, the build will remove local directories from the debug infos.")
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
env := os.Environ()
|
|
wd, err := os.Getwd()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
env = append(env, "GOPATH="+wd, "CGO_ENABLED=0")
|
|
|
|
args := []string{"build", "-ldflags=-s -w"}
|
|
|
|
if *reproducible {
|
|
args = append(args,
|
|
"-asmflags=all=-trimpath="+wd,
|
|
"-gcflags=all=-trimpath="+wd,
|
|
"-a",
|
|
)
|
|
}
|
|
|
|
if len(flag.Args()) == 1 {
|
|
target := flag.Arg(0)
|
|
targetParts := strings.Split(target, "/")
|
|
if len(targetParts) != 2 {
|
|
println("Invalid target specification. Example: windows/386")
|
|
os.Exit(1)
|
|
}
|
|
env = append(env,
|
|
"GOOS="+targetParts[0],
|
|
"GOARCH"+targetParts[1],
|
|
)
|
|
ext := ""
|
|
if targetParts[0] == "windows" {
|
|
ext = ".exe"
|
|
}
|
|
args = append(args, "-o", "calanonsync-"+targetParts[0]+"-"+targetParts[1]+ext)
|
|
}
|
|
|
|
args = append(args, "calanonsync")
|
|
|
|
cmd := exec.Command("go", args...)
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
cmd.Env = env
|
|
|
|
err = cmd.Run()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|