mirror of
https://github.com/restic/restic.git
synced 2024-12-23 16:26:11 +00:00
Add flag to disable cross-compilation
This commit is contained in:
parent
1dd4c52a8b
commit
877f3f61a0
1 changed files with 37 additions and 27 deletions
|
@ -4,6 +4,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
@ -15,6 +16,12 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var runCrossCompile = flag.Bool("cross-compile", true, "run cross compilation tests")
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flag.Parse()
|
||||||
|
}
|
||||||
|
|
||||||
type CIEnvironment interface {
|
type CIEnvironment interface {
|
||||||
Prepare()
|
Prepare()
|
||||||
RunTests()
|
RunTests()
|
||||||
|
@ -35,7 +42,6 @@ func (env *TravisEnvironment) Prepare() {
|
||||||
run("go", "get", "golang.org/x/tools/cmd/cover")
|
run("go", "get", "golang.org/x/tools/cmd/cover")
|
||||||
run("go", "get", "github.com/mattn/goveralls")
|
run("go", "get", "github.com/mattn/goveralls")
|
||||||
run("go", "get", "github.com/pierrre/gotestcover")
|
run("go", "get", "github.com/pierrre/gotestcover")
|
||||||
run("go", "get", "github.com/mitchellh/gox")
|
|
||||||
runWithEnv(envVendorExperiment, "go", "get", "github.com/minio/minio")
|
runWithEnv(envVendorExperiment, "go", "get", "github.com/minio/minio")
|
||||||
|
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
|
@ -45,26 +51,29 @@ func (env *TravisEnvironment) Prepare() {
|
||||||
run("brew", "cask", "install", "osxfuse")
|
run("brew", "cask", "install", "osxfuse")
|
||||||
}
|
}
|
||||||
|
|
||||||
// only test cross compilation on linux with Travis
|
if *runCrossCompile {
|
||||||
if runtime.GOOS == "linux" {
|
// only test cross compilation on linux with Travis
|
||||||
env.goxArch = []string{"386", "amd64"}
|
run("go", "get", "github.com/mitchellh/gox")
|
||||||
if !strings.HasPrefix(runtime.Version(), "go1.3") {
|
if runtime.GOOS == "linux" {
|
||||||
env.goxArch = append(env.goxArch, "arm")
|
env.goxArch = []string{"386", "amd64"}
|
||||||
|
if !strings.HasPrefix(runtime.Version(), "go1.3") {
|
||||||
|
env.goxArch = append(env.goxArch, "arm")
|
||||||
|
}
|
||||||
|
|
||||||
|
env.goxOS = []string{"linux", "darwin", "freebsd", "openbsd", "windows"}
|
||||||
|
} else {
|
||||||
|
env.goxArch = []string{runtime.GOARCH}
|
||||||
|
env.goxOS = []string{runtime.GOOS}
|
||||||
}
|
}
|
||||||
|
|
||||||
env.goxOS = []string{"linux", "darwin", "freebsd", "openbsd", "windows"}
|
msg("gox: OS %v, ARCH %v\n", env.goxOS, env.goxArch)
|
||||||
} else {
|
|
||||||
env.goxArch = []string{runtime.GOARCH}
|
|
||||||
env.goxOS = []string{runtime.GOOS}
|
|
||||||
}
|
|
||||||
|
|
||||||
msg("gox: OS %v, ARCH %v\n", env.goxOS, env.goxArch)
|
v := runtime.Version()
|
||||||
|
if !strings.HasPrefix(v, "go1.5") && !strings.HasPrefix(v, "go1.6") {
|
||||||
v := runtime.Version()
|
run("gox", "-build-toolchain",
|
||||||
if !strings.HasPrefix(v, "go1.5") && !strings.HasPrefix(v, "go1.6") {
|
"-os", strings.Join(env.goxOS, " "),
|
||||||
run("gox", "-build-toolchain",
|
"-arch", strings.Join(env.goxArch, " "))
|
||||||
"-os", strings.Join(env.goxOS, " "),
|
}
|
||||||
"-arch", strings.Join(env.goxArch, " "))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,14 +104,16 @@ func (env *TravisEnvironment) RunTests() {
|
||||||
os.Setenv("RESTIC_TEST_FUSE", "0")
|
os.Setenv("RESTIC_TEST_FUSE", "0")
|
||||||
}
|
}
|
||||||
|
|
||||||
// compile for all target architectures with tags
|
if *runCrossCompile {
|
||||||
for _, tags := range []string{"release", "debug"} {
|
// compile for all target architectures with tags
|
||||||
run("gox", "-verbose",
|
for _, tags := range []string{"release", "debug"} {
|
||||||
"-os", strings.Join(env.goxOS, " "),
|
run("gox", "-verbose",
|
||||||
"-arch", strings.Join(env.goxArch, " "),
|
"-os", strings.Join(env.goxOS, " "),
|
||||||
"-tags", tags,
|
"-arch", strings.Join(env.goxArch, " "),
|
||||||
"-output", "/tmp/{{.Dir}}_{{.OS}}_{{.Arch}}",
|
"-tags", tags,
|
||||||
"./cmd/restic")
|
"-output", "/tmp/{{.Dir}}_{{.OS}}_{{.Arch}}",
|
||||||
|
"./cmd/restic")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// run the build script
|
// run the build script
|
||||||
|
@ -136,7 +147,6 @@ type AppveyorEnvironment struct{}
|
||||||
|
|
||||||
func (env *AppveyorEnvironment) Prepare() {
|
func (env *AppveyorEnvironment) Prepare() {
|
||||||
msg("preparing environment for Appveyor CI\n")
|
msg("preparing environment for Appveyor CI\n")
|
||||||
runWithEnv(envVendorExperiment, "go", "get", "github.com/minio/minio")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *AppveyorEnvironment) RunTests() {
|
func (env *AppveyorEnvironment) RunTests() {
|
||||||
|
|
Loading…
Reference in a new issue