2013-10-24 02:00:57 +04:00
|
|
|
// +build gotask
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jingweno/gotask/tasking"
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
2013-10-24 03:15:56 +04:00
|
|
|
// Cross-compiles gh for all supported platforms.
|
|
|
|
//
|
|
|
|
// Cross-compiles gh for all supported platforms. The build artifacts
|
|
|
|
// will be in target/VERSION. This only works on darwin with Vagrant setup.
|
|
|
|
func TaskCrossCompileAll(t *tasking.T) {
|
|
|
|
t.Log("Removing build target...")
|
|
|
|
err := os.RemoveAll("target")
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Can't remove build target: %s\n", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2013-11-07 23:47:02 +04:00
|
|
|
// for current
|
|
|
|
t.Logf("Compiling for %s...\n", runtime.GOOS)
|
2013-10-24 03:15:56 +04:00
|
|
|
TaskCrossCompile(t)
|
|
|
|
if t.Failed() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// for linux
|
|
|
|
t.Log("Compiling for linux...")
|
|
|
|
err = t.Exec("vagrant ssh -c 'cd ~/src/github.com/jingweno/gh && git pull origin master && gotask cross-compile'")
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Can't compile on linux: %s\n", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cross-compiles gh for current operating system.
|
2013-10-24 02:00:57 +04:00
|
|
|
//
|
2013-10-24 02:20:47 +04:00
|
|
|
// Cross-compiles gh for current operating system. The build artifacts will be in target/VERSION
|
|
|
|
func TaskCrossCompile(t *tasking.T) {
|
2013-10-24 02:00:57 +04:00
|
|
|
t.Log("Updating goxc...")
|
|
|
|
err := t.Exec("go get -u github.com/laher/goxc")
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Can't update goxc: %s\n", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2013-11-10 19:12:41 +04:00
|
|
|
// TODO: use a dependency manager that has versioning
|
2013-11-10 19:20:21 +04:00
|
|
|
if runtime.GOOS != "windows" {
|
|
|
|
t.Log("Updating dependencies...")
|
|
|
|
err = t.Exec("go get -u ./...")
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Can't update goxc: %s\n", err)
|
|
|
|
return
|
|
|
|
}
|
2013-11-10 19:12:41 +04:00
|
|
|
}
|
|
|
|
|
2013-11-07 23:47:02 +04:00
|
|
|
t.Logf("Cross-compiling gh for %s...\n", runtime.GOOS)
|
2013-10-24 02:00:57 +04:00
|
|
|
err = t.Exec("goxc", "-wd=.", "-os="+runtime.GOOS, "-c="+runtime.GOOS)
|
|
|
|
if err != nil {
|
2013-10-24 02:16:13 +04:00
|
|
|
t.Errorf("Can't cross-compile gh: %s\n", err)
|
2013-10-24 02:00:57 +04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|