From e9acb2bec0d4758f1cd7bdcb33dbd3a2d7a15f8b Mon Sep 17 00:00:00 2001 From: Jingwen Owen Ou Date: Wed, 23 Oct 2013 16:15:56 -0700 Subject: [PATCH] Add task to cross compile on darwin and linux --- gh_task.go | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/gh_task.go b/gh_task.go index 9df35d27..5ff61b36 100644 --- a/gh_task.go +++ b/gh_task.go @@ -8,7 +8,35 @@ import ( "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 func TaskCrossCompile(t *tasking.T) { @@ -19,14 +47,7 @@ func TaskCrossCompile(t *tasking.T) { return } - t.Log("Removing build target...") - err = os.RemoveAll("target") - if err != nil { - t.Errorf("Can't remove build target: %s\n", err) - return - } - - t.Log("Cross-compiling gh...") + t.Log("Cross-compiling gh for mac...") err = t.Exec("goxc", "-wd=.", "-os="+runtime.GOOS, "-c="+runtime.GOOS) if err != nil { t.Errorf("Can't cross-compile gh: %s\n", err) -- GitLab