提交 e9acb2be 编写于 作者: J Jingwen Owen Ou

Add task to cross compile on darwin and linux

上级 d718f3be
...@@ -8,7 +8,35 @@ import ( ...@@ -8,7 +8,35 @@ import (
"runtime" "runtime"
) )
// Cross-compiles gh // 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
}
// for darwin
t.Log("Compiling for darwin...")
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.
// //
// Cross-compiles gh for current operating system. The build artifacts will be in target/VERSION // Cross-compiles gh for current operating system. The build artifacts will be in target/VERSION
func TaskCrossCompile(t *tasking.T) { func TaskCrossCompile(t *tasking.T) {
...@@ -19,14 +47,7 @@ func TaskCrossCompile(t *tasking.T) { ...@@ -19,14 +47,7 @@ func TaskCrossCompile(t *tasking.T) {
return return
} }
t.Log("Removing build target...") t.Log("Cross-compiling gh for mac...")
err = os.RemoveAll("target")
if err != nil {
t.Errorf("Can't remove build target: %s\n", err)
return
}
t.Log("Cross-compiling gh...")
err = t.Exec("goxc", "-wd=.", "-os="+runtime.GOOS, "-c="+runtime.GOOS) err = t.Exec("goxc", "-wd=.", "-os="+runtime.GOOS, "-c="+runtime.GOOS)
if err != nil { if err != nil {
t.Errorf("Can't cross-compile gh: %s\n", err) t.Errorf("Can't cross-compile gh: %s\n", err)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册