forked from aksdb/CalAnonSync
Added build script
This commit is contained in:
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…
Reference in New Issue