Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fyne-cli] Add support for passing custom build tags #1602

Merged
merged 1 commit into from Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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