forked from cerc-io/plugeth
travis, build: enable 386 builds too for linux and osx
This commit is contained in:
parent
bad0de0dcb
commit
2f9f2cbb19
@ -23,10 +23,11 @@ matrix:
|
|||||||
go: 1.7
|
go: 1.7
|
||||||
env:
|
env:
|
||||||
- ubuntu-ppa
|
- ubuntu-ppa
|
||||||
- azure-linux-amd64
|
- azure-linux
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
|
- gcc-multilib
|
||||||
- devscripts
|
- devscripts
|
||||||
- debhelper
|
- debhelper
|
||||||
- dput
|
- dput
|
||||||
@ -34,15 +35,19 @@ matrix:
|
|||||||
- go run build/ci.go debsrc -signer "Felix Lange (Geth CI Testing Key) <fjl@twurst.com>" -upload ppa:lp-fjl/geth-ci-testing
|
- go run build/ci.go debsrc -signer "Felix Lange (Geth CI Testing Key) <fjl@twurst.com>" -upload ppa:lp-fjl/geth-ci-testing
|
||||||
- go run build/ci.go install
|
- go run build/ci.go install
|
||||||
- go run build/ci.go archive -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
- go run build/ci.go archive -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
||||||
|
- go run build/ci.go install -arch 386
|
||||||
|
- go run build/ci.go archive -arch 386 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
|
||||||
|
|
||||||
# This builder does the OSX Azure uploads
|
# This builder does the OSX Azure uploads
|
||||||
- os: osx
|
- os: osx
|
||||||
go: 1.7
|
go: 1.7
|
||||||
env:
|
env:
|
||||||
- azure-osx-amd64
|
- azure-osx
|
||||||
script:
|
script:
|
||||||
- go run build/ci.go install
|
- go run build/ci.go install
|
||||||
- go run build/ci.go archive -type zip -signer OSX_SIGNING_KEY -upload gethstore/builds
|
- go run build/ci.go archive -type zip -signer OSX_SIGNING_KEY -upload gethstore/builds
|
||||||
|
- go run build/ci.go install -arch 386
|
||||||
|
- go run build/ci.go archive -arch 386 -type zip -signer OSX_SIGNING_KEY -upload gethstore/builds
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- go get golang.org/x/tools/cmd/cover
|
- go get golang.org/x/tools/cmd/cover
|
||||||
|
66
build/ci.go
66
build/ci.go
@ -23,12 +23,12 @@ Usage: go run ci.go <command> <command flags/arguments>
|
|||||||
|
|
||||||
Available commands are:
|
Available commands are:
|
||||||
|
|
||||||
install [ packages... ] -- builds packages and executables
|
install [-arch architecture] [ packages... ] -- builds packages and executables
|
||||||
test [ -coverage ] [ -vet ] [ packages... ] -- runs the tests
|
test [ -coverage ] [ -vet ] [ packages... ] -- runs the tests
|
||||||
archive [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts
|
archive [-arch architecture] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts
|
||||||
importkeys -- imports signing keys from env
|
importkeys -- imports signing keys from env
|
||||||
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
|
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
|
||||||
xgo [ options ] -- cross builds according to options
|
xgo [ options ] -- cross builds according to options
|
||||||
|
|
||||||
For all commands, -n prevents execution of external programs (dry run mode).
|
For all commands, -n prevents execution of external programs (dry run mode).
|
||||||
|
|
||||||
@ -40,6 +40,8 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go/parser"
|
||||||
|
"go/token"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@ -130,6 +132,9 @@ func main() {
|
|||||||
// Compiling
|
// Compiling
|
||||||
|
|
||||||
func doInstall(cmdline []string) {
|
func doInstall(cmdline []string) {
|
||||||
|
var (
|
||||||
|
arch = flag.String("arch", "", "Architecture to cross build for")
|
||||||
|
)
|
||||||
flag.CommandLine.Parse(cmdline)
|
flag.CommandLine.Parse(cmdline)
|
||||||
env := build.Env()
|
env := build.Env()
|
||||||
|
|
||||||
@ -146,11 +151,38 @@ func doInstall(cmdline []string) {
|
|||||||
if flag.NArg() > 0 {
|
if flag.NArg() > 0 {
|
||||||
packages = flag.Args()
|
packages = flag.Args()
|
||||||
}
|
}
|
||||||
|
if *arch == "" || *arch == runtime.GOARCH {
|
||||||
goinstall := goTool("install", buildFlags(env)...)
|
goinstall := goTool("install", buildFlags(env)...)
|
||||||
|
goinstall.Args = append(goinstall.Args, "-v")
|
||||||
|
goinstall.Args = append(goinstall.Args, packages...)
|
||||||
|
build.MustRun(goinstall)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Seems we are cross compiling, work around forbidden GOBIN
|
||||||
|
goinstall := goToolArch(*arch, "install", buildFlags(env)...)
|
||||||
goinstall.Args = append(goinstall.Args, "-v")
|
goinstall.Args = append(goinstall.Args, "-v")
|
||||||
|
goinstall.Args = append(goinstall.Args, []string{"-buildmode", "archive"}...)
|
||||||
goinstall.Args = append(goinstall.Args, packages...)
|
goinstall.Args = append(goinstall.Args, packages...)
|
||||||
build.MustRun(goinstall)
|
build.MustRun(goinstall)
|
||||||
|
|
||||||
|
if cmds, err := ioutil.ReadDir("cmd"); err == nil {
|
||||||
|
for _, cmd := range cmds {
|
||||||
|
pkgs, err := parser.ParseDir(token.NewFileSet(), filepath.Join(".", "cmd", cmd.Name()), nil, parser.PackageClauseOnly)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
for name, _ := range pkgs {
|
||||||
|
if name == "main" {
|
||||||
|
gobuild := goToolArch(*arch, "build", buildFlags(env)...)
|
||||||
|
gobuild.Args = append(gobuild.Args, "-v")
|
||||||
|
gobuild.Args = append(gobuild.Args, []string{"-o", filepath.Join(GOBIN, cmd.Name())}...)
|
||||||
|
gobuild.Args = append(gobuild.Args, "."+string(filepath.Separator)+filepath.Join("cmd", cmd.Name()))
|
||||||
|
build.MustRun(gobuild)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildFlags(env build.Environment) (flags []string) {
|
func buildFlags(env build.Environment) (flags []string) {
|
||||||
@ -173,13 +205,22 @@ func buildFlags(env build.Environment) (flags []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func goTool(subcmd string, args ...string) *exec.Cmd {
|
func goTool(subcmd string, args ...string) *exec.Cmd {
|
||||||
|
return goToolArch(runtime.GOARCH, subcmd, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd {
|
||||||
gocmd := filepath.Join(runtime.GOROOT(), "bin", "go")
|
gocmd := filepath.Join(runtime.GOROOT(), "bin", "go")
|
||||||
cmd := exec.Command(gocmd, subcmd)
|
cmd := exec.Command(gocmd, subcmd)
|
||||||
cmd.Args = append(cmd.Args, args...)
|
cmd.Args = append(cmd.Args, args...)
|
||||||
cmd.Env = []string{
|
cmd.Env = []string{
|
||||||
"GO15VENDOREXPERIMENT=1",
|
"GO15VENDOREXPERIMENT=1",
|
||||||
"GOPATH=" + build.GOPATH(),
|
"GOPATH=" + build.GOPATH(),
|
||||||
"GOBIN=" + GOBIN,
|
}
|
||||||
|
if arch == "" || arch == runtime.GOARCH {
|
||||||
|
cmd.Env = append(cmd.Env, "GOBIN="+GOBIN)
|
||||||
|
} else {
|
||||||
|
cmd.Env = append(cmd.Env, "CGO_ENABLED=1")
|
||||||
|
cmd.Env = append(cmd.Env, "GOARCH="+arch)
|
||||||
}
|
}
|
||||||
for _, e := range os.Environ() {
|
for _, e := range os.Environ() {
|
||||||
if strings.HasPrefix(e, "GOPATH=") || strings.HasPrefix(e, "GOBIN=") {
|
if strings.HasPrefix(e, "GOPATH=") || strings.HasPrefix(e, "GOBIN=") {
|
||||||
@ -239,6 +280,7 @@ func doTest(cmdline []string) {
|
|||||||
|
|
||||||
func doArchive(cmdline []string) {
|
func doArchive(cmdline []string) {
|
||||||
var (
|
var (
|
||||||
|
arch = flag.String("arch", runtime.GOARCH, "Architecture cross packaging")
|
||||||
atype = flag.String("type", "zip", "Type of archive to write (zip|tar)")
|
atype = flag.String("type", "zip", "Type of archive to write (zip|tar)")
|
||||||
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. LINUX_SIGNING_KEY)`)
|
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. LINUX_SIGNING_KEY)`)
|
||||||
upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
|
upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
|
||||||
@ -257,7 +299,7 @@ func doArchive(cmdline []string) {
|
|||||||
env := build.Env()
|
env := build.Env()
|
||||||
maybeSkipArchive(env)
|
maybeSkipArchive(env)
|
||||||
|
|
||||||
base := archiveBasename(env)
|
base := archiveBasename(*arch, env)
|
||||||
if err := build.WriteArchive("geth-"+base, ext, gethArchiveFiles); err != nil {
|
if err := build.WriteArchive("geth-"+base, ext, gethArchiveFiles); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -272,9 +314,9 @@ func doArchive(cmdline []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func archiveBasename(env build.Environment) string {
|
func archiveBasename(arch string, env build.Environment) string {
|
||||||
// date := time.Now().UTC().Format("200601021504")
|
// date := time.Now().UTC().Format("200601021504")
|
||||||
platform := runtime.GOOS + "-" + runtime.GOARCH
|
platform := runtime.GOOS + "-" + arch
|
||||||
archive := platform + "-" + build.VERSION()
|
archive := platform + "-" + build.VERSION()
|
||||||
if env.Commit != "" {
|
if env.Commit != "" {
|
||||||
archive += "-" + env.Commit[:8]
|
archive += "-" + env.Commit[:8]
|
||||||
|
Loading…
Reference in New Issue
Block a user