diff --git a/CHANGELOG.md b/CHANGELOG.md index 24c8bb81c8..a0ad3fd1f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ More detailed release notes can be found on the [releases page](https://github.c ## 1.4.2 - Ongoing +### Added + +* [fyne-cli] Add support for passing custom build tags (#1538) + ### Fixed * [fyne-cli] Android: allow to specify an inline password for the keystore diff --git a/cmd/fyne/commands/build.go b/cmd/fyne/commands/build.go index 1c63559b6f..001f681ed7 100644 --- a/cmd/fyne/commands/build.go +++ b/cmd/fyne/commands/build.go @@ -5,11 +5,13 @@ import ( "os" "os/exec" "runtime" + "strings" ) type builder struct { os, srcdir string release bool + tags []string } func (b *builder) build() error { @@ -32,9 +34,16 @@ func (b *builder) build() error { args = append(args, "build") } } + + // handle build tags + tags := b.tags if b.release { - args = append(args, "-tags", "release") + args = append(tags, "release") + } + if len(tags) > 0 { + args = append(args, "-tags", strings.Join(tags, ",")) } + cmd := exec.Command("go", args...) cmd.Dir = b.srcdir env := os.Environ() diff --git a/cmd/fyne/commands/package.go b/cmd/fyne/commands/package.go index c72a10973b..5fac8b24f6 100644 --- a/cmd/fyne/commands/package.go +++ b/cmd/fyne/commands/package.go @@ -31,6 +31,7 @@ type packager struct { appBuild int install, release bool certificate, profile string // optional flags for releasing + tags string } // NewPackager returns a packager command that can wrap executables into full GUI app packages. @@ -48,6 +49,7 @@ func (p *packager) AddFlags() { flag.StringVar(&p.appVersion, "appVersion", "", "Version number in the form x, x.y or x.y.z semantic version") flag.IntVar(&p.appBuild, "appBuild", 0, "Build number, should be greater than 0 and incremented for each build") flag.BoolVar(&p.release, "release", false, "Should this package be prepared for release? (disable debug etc)") + flag.StringVar(&p.tags, "tags", "", "A comma-separated list of build tags") } func (*packager) PrintHelp(indent string) { @@ -71,10 +73,12 @@ func (p *packager) Run(_ []string) { } func (p *packager) buildPackage() error { + tags := strings.Split(p.tags, ",") b := &builder{ os: p.os, srcdir: p.srcDir, release: p.release, + tags: tags, } return b.build() diff --git a/cmd/fyne/commands/release.go b/cmd/fyne/commands/release.go index 5115ae086e..6bfd7faf28 100644 --- a/cmd/fyne/commands/release.go +++ b/cmd/fyne/commands/release.go @@ -47,6 +47,7 @@ func (r *releaser) AddFlags() { flag.StringVar(&r.profile, "profile", "", "iOS/macOS: name of the provisioning profile for this release build") flag.StringVar(&r.developer, "developer", "", "Windows: the developer identity for your Microsoft store account") flag.StringVar(&r.password, "password", "", "Windows: password for the certificate used to sign the build") + flag.StringVar(&r.tags, "tags", "", "A comma-separated list of build tags") } func (r *releaser) PrintHelp(indent string) {