From 09e8804bb82f148abf8b00002f23b371be66c486 Mon Sep 17 00:00:00 2001 From: David Bariod Date: Wed, 1 May 2019 14:53:24 +0200 Subject: [PATCH 1/2] Add a flag to build for all supported platforms --- main.go | 1 + platform_flag.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 9eca6a4..69927cc 100644 --- a/main.go +++ b/main.go @@ -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 combination") flags.StringVar(&ldflags, "ldflags", "", "linker flags") flags.StringVar(&tags, "tags", "", "go build tags") flags.StringVar(&outputTpl, "output", "{{.Dir}}_{{.OS}}_{{.Arch}}", "output path") diff --git a/platform_flag.go b/platform_flag.go index d69d922..c1f4a79 100644 --- a/platform_flag.go +++ b/platform_flag.go @@ -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. @@ -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) From 95bddca88317d1474d8aca8ae9f09f5c67a1c858 Mon Sep 17 00:00:00 2001 From: David Bariod Date: Fri, 10 May 2019 06:30:45 +0200 Subject: [PATCH 2/2] Add the -all flag documentation in the command line help message --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 69927cc..fdb9167 100644 --- a/main.go +++ b/main.go @@ -35,7 +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 combination") + 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") @@ -218,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