mage: support ppc64, arm, 386 and arm64 binaries

This commit is contained in:
Cadey Ratio 2017-12-02 18:44:20 -08:00
parent ef62f2782e
commit 71e9986283
1 changed files with 28 additions and 16 deletions

22
mage.go
View File

@ -19,12 +19,15 @@ import (
)
var wd string
var arches []string
func init() {
lwd, err := os.Getwd()
qod.ANE(err)
wd = lwd
arches = []string{"amd64", "ppc64", "386", "arm", "arm64"}
}
const pkgBase = "git.xeserv.us/xena/route/"
@ -120,8 +123,9 @@ func Docker() {
// Linux builds binaries for linux
func Linux() {
buildBins("linux", "amd64")
buildBins("linux", "ppc64")
for _, arch := range arches {
buildBins("linux", arch)
}
Plugin()
}
@ -167,8 +171,13 @@ func Package() {
ver, err := gitTag()
qod.ANE(err)
for _, arch := range arches {
for _, osname := range []string{"linux", "windows", "darwin"} {
dir, err := ioutil.TempDir("", "route-package-"+osname)
if arch != "amd64" && osname != "linux" {
continue
}
dir, err := ioutil.TempDir("", "route-package-"+osname+"-"+arch)
qod.ANE(err)
qod.Printlnf("%s", dir)
@ -176,13 +185,16 @@ func Package() {
if osname == "windows" {
file = file + ".exe"
}
shouldWork(ctx, nil, filepath.Join(wd, "bin", osname), "cp", "-rf", file, dir)
shouldWork(ctx, nil, filepath.Join(wd, "bin", osname, arch), "cp", "-rf", file, dir)
}
shouldWork(ctx, nil, wd, "cp", "-rf", "doc", dir)
shouldWork(ctx, nil, wd, "cp", "-rf", "README.md", dir)
shouldWork(ctx, nil, wd, "cp", "-rf", "LICENSE", dir)
shouldWork(ctx, nil, wd, "cp", "-rf", "Gopkg.lock", dir)
shouldWork(ctx, nil, dir, "tar", "czf", filepath.Join(wd, "bin", fmt.Sprintf("route-%s-%s.tar.gz", ver, osname)), ".")
shouldWork(ctx, nil, dir, "tar", "czf", filepath.Join(wd, "bin", fmt.Sprintf("route-%s-%s-%s.tar.gz", ver, osname, arch)), ".")
}
}
}