Added build script

master
Andreas Schneider 6 years ago
parent d7743b6ef2
commit 765f8fc077

@ -0,0 +1,50 @@
// +build ignore
package main
import (
"os"
"os/exec"
"strings"
)
func main() {
env := os.Environ()
wd, err := os.Getwd()
if err != nil {
panic(err)
}
env = append(env, "GOPATH="+wd)
args := []string{"build"}
if len(os.Args) == 2 {
target := os.Args[1]
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)
}
}
Loading…
Cancel
Save