Skip to content

Commit

Permalink
[fyne-cli] Add support for passing custom build tags
Browse files Browse the repository at this point in the history
Fixes #1538
  • Loading branch information
lucor committed Nov 24, 2020
1 parent c9aa6fd commit 19ce989
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion cmd/fyne/commands/build.go
Expand Up @@ -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 {
Expand All @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions cmd/fyne/commands/package.go
Expand Up @@ -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.
Expand All @@ -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) {
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions cmd/fyne/commands/release.go
Expand Up @@ -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) {
Expand Down

0 comments on commit 19ce989

Please sign in to comment.