1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00

101 lines
2.0 KiB
Go
Raw Normal View History

package buildtarget
import (
"github.com/apex/log"
"github.com/goreleaser/goreleaser/config"
)
// All returns all valid build targets for a given build
func All(build config.Build) (targets []Target) {
for _, target := range allBuildTargets(build) {
if !valid(target) {
2017-07-09 13:16:38 -03:00
log.WithField("target", target.PrettyString()).
2017-08-20 17:46:30 -03:00
Debug("skipped invalid build")
continue
}
if ignored(build, target) {
2017-07-09 13:16:38 -03:00
log.WithField("target", target.PrettyString()).
2017-08-20 17:46:30 -03:00
Debug("skipped ignored build")
continue
}
targets = append(targets, target)
}
return
}
func allBuildTargets(build config.Build) (targets []Target) {
for _, goos := range build.Goos {
for _, goarch := range build.Goarch {
if goarch == "arm" {
for _, goarm := range build.Goarm {
targets = append(targets, New(goos, goarch, goarm))
}
continue
}
targets = append(targets, New(goos, goarch, ""))
}
}
return
}
func ignored(build config.Build, target Target) bool {
for _, ig := range build.Ignore {
if ig.Goos != "" && ig.Goos != target.OS {
continue
}
if ig.Goarch != "" && ig.Goarch != target.Arch {
continue
}
if ig.Goarm != "" && ig.Goarm != target.Arm {
continue
}
return true
}
return false
}
func valid(target Target) bool {
var s = target.OS + target.Arch
for _, a := range validTargets {
if a == s {
return true
}
}
return false
}
// list from https://golang.org/doc/install/source#environment
var validTargets = []string{
"androidarm",
"darwin386",
"darwinamd64",
// "darwinarm", - requires admin rights and other ios stuff
// "darwinarm64", - requires admin rights and other ios stuff
"dragonflyamd64",
"freebsd386",
"freebsdamd64",
"freebsdarm",
"linux386",
"linuxamd64",
"linuxarm",
"linuxarm64",
"linuxppc64",
"linuxppc64le",
"linuxmips",
"linuxmipsle",
"linuxmips64",
"linuxmips64le",
2017-07-26 01:04:03 -06:00
"linuxs390x",
"netbsd386",
"netbsdamd64",
"netbsdarm",
"openbsd386",
"openbsdamd64",
"openbsdarm",
"plan9386",
"plan9amd64",
"solarisamd64",
"windows386",
"windowsamd64",
}