Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Add a flag to build for all supported platforms #131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func realMain() int {
flags.Var(platformFlag.ArchFlagValue(), "arch", "arch to build for or skip")
flags.Var(platformFlag.OSArchFlagValue(), "osarch", "os/arch pairs to build for or skip")
flags.Var(platformFlag.OSFlagValue(), "os", "os to build for or skip")
flags.BoolVar(&platformFlag.All, "all", false, "build for all known os/arch combinations")
flags.StringVar(&ldflags, "ldflags", "", "linker flags")
flags.StringVar(&tags, "tags", "", "go build tags")
flags.StringVar(&outputTpl, "output", "{{.Dir}}_{{.OS}}_{{.Arch}}", "output path")
Expand Down Expand Up @@ -217,6 +218,7 @@ Options:
-os="" Space-separated list of operating systems to build for
-osarch="" Space-separated list of os/arch pairs to build for
-osarch-list List supported os/arch pairs for your Go version
-all Build for all know os/arch combinations
-output="foo" Output path template. See below for more info
-parallel=-1 Amount of parallelism, defaults to number of CPUs
-gocmd="go" Build command, defaults to Go
Expand Down
3 changes: 2 additions & 1 deletion platform_flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type PlatformFlag struct {
OS []string
Arch []string
OSArch []Platform
All bool
}

// Platforms returns the list of platforms that were set by this flag.
Expand Down Expand Up @@ -127,7 +128,7 @@ func (p *PlatformFlag) Platforms(supported []Platform) []Platform {
if prefilter == nil {
prefilter = make([]Platform, 0, len(supported))
for _, v := range supported {
if v.Default {
if v.Default || p.All {
add := v
add.Default = false
prefilter = append(prefilter, add)
Expand Down