Add flag to disable cross-compilation

This commit is contained in:
Alexander Neumann 2016-01-17 18:33:03 +01:00
parent 1dd4c52a8b
commit 877f3f61a0
1 changed files with 37 additions and 27 deletions

View File

@ -4,6 +4,7 @@ package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
@ -15,6 +16,12 @@ import (
"sync"
)
var runCrossCompile = flag.Bool("cross-compile", true, "run cross compilation tests")
func init() {
flag.Parse()
}
type CIEnvironment interface {
Prepare()
RunTests()
@ -35,7 +42,6 @@ func (env *TravisEnvironment) Prepare() {
run("go", "get", "golang.org/x/tools/cmd/cover")
run("go", "get", "github.com/mattn/goveralls")
run("go", "get", "github.com/pierrre/gotestcover")
run("go", "get", "github.com/mitchellh/gox")
runWithEnv(envVendorExperiment, "go", "get", "github.com/minio/minio")
if runtime.GOOS == "darwin" {
@ -45,7 +51,9 @@ func (env *TravisEnvironment) Prepare() {
run("brew", "cask", "install", "osxfuse")
}
if *runCrossCompile {
// only test cross compilation on linux with Travis
run("go", "get", "github.com/mitchellh/gox")
if runtime.GOOS == "linux" {
env.goxArch = []string{"386", "amd64"}
if !strings.HasPrefix(runtime.Version(), "go1.3") {
@ -67,6 +75,7 @@ func (env *TravisEnvironment) Prepare() {
"-arch", strings.Join(env.goxArch, " "))
}
}
}
func goVersionAtLeast151() bool {
v := runtime.Version()
@ -95,6 +104,7 @@ func (env *TravisEnvironment) RunTests() {
os.Setenv("RESTIC_TEST_FUSE", "0")
}
if *runCrossCompile {
// compile for all target architectures with tags
for _, tags := range []string{"release", "debug"} {
run("gox", "-verbose",
@ -104,6 +114,7 @@ func (env *TravisEnvironment) RunTests() {
"-output", "/tmp/{{.Dir}}_{{.OS}}_{{.Arch}}",
"./cmd/restic")
}
}
// run the build script
run("go", "run", "build.go")
@ -136,7 +147,6 @@ type AppveyorEnvironment struct{}
func (env *AppveyorEnvironment) Prepare() {
msg("preparing environment for Appveyor CI\n")
runWithEnv(envVendorExperiment, "go", "get", "github.com/minio/minio")
}
func (env *AppveyorEnvironment) RunTests() {