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

Sync with fyne-io/fyne develop branch #22

Closed
wants to merge 4 commits into from
Closed
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
8 changes: 2 additions & 6 deletions cmd/fyne/internal/commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ func (b *Builder) build() error {
env := os.Environ()

if goos == "darwin" {
appendEnv(&env, "CGO_CFLAGS", "-mmacosx-version-min=10.13")
appendEnv(&env, "CGO_LDFLAGS", "-mmacosx-version-min=10.13")
appendEnv(&env, "CGO_CFLAGS", "-mmacosx-version-min=10.11")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should not go back versions - the new repo has a higher OS requirement and that is OK.

appendEnv(&env, "CGO_LDFLAGS", "-mmacosx-version-min=10.11")
}

ldFlags := extractLdflagsFromGoFlags()
Expand Down Expand Up @@ -443,9 +443,5 @@ func normaliseVersion(str string) string {
if pos := strings.Index(str, "-0.20"); pos != -1 {
str = str[:pos] + "-dev"
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, and a couple of other things, have been added to the tools repo only and should not be reverted

if pos := strings.Index(str, "-rc"); pos != -1 {
str = str[:pos] + "-dev"
}
return version.Normalize(str)
}
2 changes: 1 addition & 1 deletion cmd/fyne/internal/commands/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func openOutputFile(filePath string, noheader bool) (file *os.File, close func()
}

func sanitiseName(file, prefix string) string {
titled := strings.Title(file) //lint:ignore SA1019 It is fine for our uses.
titled := strings.Title(file) //lint:ignore SA1019 This is fine for our use case.
name := filenameRegex.ReplaceAllString(titled, "")

return prefix + name
Expand Down
13 changes: 10 additions & 3 deletions cmd/fyne/internal/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"flag"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/urfave/cli/v2"
"golang.org/x/sys/execabs"

//lint:ignore SA1019 The recommended replacement does not solve the use-case
"golang.org/x/tools/go/vcs"
Expand All @@ -35,6 +35,12 @@ func Get() *cli.Command {
Usage: "For darwin and Windows targets an appID in the form of a reversed domain name is required, for ios this must match a valid provisioning profile",
Destination: &g.AppID,
},
&cli.StringFlag{
Name: "installDir",
Aliases: []string{"o"},
Usage: "A specific location to install to, rather than the OS default.",
Destination: &g.installDir,
},
},
Action: func(ctx *cli.Context) error {
if ctx.Args().Len() != 1 {
Expand All @@ -50,6 +56,7 @@ func Get() *cli.Command {
// Getter is the command that can handle downloading and installing Fyne apps to the current platform.
type Getter struct {
*appData
installDir string
}

// NewGetter returns a command that can handle the download and install of GUI apps built using Fyne.
Expand Down Expand Up @@ -81,7 +88,7 @@ func (g *Getter) Get(pkg string) error {
if repo.VCS.Name != "Git" {
return errors.New("unsupported VCS: " + repo.VCS.Name)
}
cmd := exec.Command("git", "clone", repo.Repo, "--depth=1", path)
cmd := execabs.Command("git", "clone", repo.Repo, "--depth=1", path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The execabs is not needed any more I think, because Go 1.19 fixed the underlying issues.

cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr

err = cmd.Run()
Expand All @@ -98,7 +105,7 @@ func (g *Getter) Get(pkg string) error {
path = filepath.Join(path, dir)
}

install := &Installer{appData: g.appData, srcDir: path, release: true}
install := &Installer{appData: g.appData, installDir: g.installDir, srcDir: path, release: true}
if err := install.validate(); err != nil {
return fmt.Errorf("failed to set up installer: %w", err)
}
Expand Down
18 changes: 9 additions & 9 deletions cmd/fyne/internal/commands/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"flag"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"

"fyne.io/fyne/v2"
"fyne.io/tools/cmd/fyne/internal/mobile"

"github.com/urfave/cli/v2"
"golang.org/x/sys/execabs"
)

// Install returns the cli command for installing fyne applications
Expand All @@ -22,13 +22,13 @@ func Install() *cli.Command {
return &cli.Command{
Name: "install",
Usage: "Packages an application and installs an application.",
Description: `The install command packages an application for the current platform and copies it
into the system location for applications. This can be overridden with installDir`,
Description: `The install command packages an application for the current platform or one of the mobile targets.
It will copy the package to the system location for applications or a location specified by installDir.`,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "target",
Aliases: []string{"os"},
Usage: "The mobile platform to target (android, android/arm, android/arm64, android/amd64, android/386, ios, iossimulator).",
Usage: "Instead of the current system, target a mobile platform (android, android/arm, android/arm64, android/amd64, android/386, ios, iossimulator).",
Destination: &i.os,
},
&cli.StringFlag{
Expand Down Expand Up @@ -148,7 +148,7 @@ func (i *Installer) install() error {
return i.installAndroid()
}

return errors.New("Unsupported target operating system \"" + i.os + "\"")
return errors.New("Unsupported target operating system \"" + i.os + "\".\nTo install on the current platform simply omit the target/os parameter.")
}

if i.installDir == "" {
Expand Down Expand Up @@ -216,12 +216,12 @@ func (i *Installer) installIOS() error {
}

func (i *Installer) runMobileInstall(tool, target string, args ...string) error {
_, err := exec.LookPath(tool)
_, err := execabs.LookPath(tool)
if err != nil {
return err
}

cmd := exec.Command(tool, append(args, target)...)
cmd := execabs.Command(tool, append(args, target)...)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
return cmd.Run()
Expand All @@ -240,7 +240,7 @@ func (i *Installer) validate() error {
}

func (i *Installer) installToIOSSimulator(target string) error {
cmd := exec.Command(
cmd := execabs.Command(
"xcrun", "simctl", "install",
"booted", // Install to the booted simulator.
target)
Expand All @@ -253,7 +253,7 @@ func (i *Installer) installToIOSSimulator(target string) error {
}

func (i *Installer) runInIOSSimulator() error {
cmd := exec.Command("xcrun", "simctl", "launch", "booted", i.Packager.AppID)
cmd := execabs.Command("xcrun", "simctl", "launch", "booted", i.Packager.AppID)
out, err := cmd.CombinedOutput()
if err != nil {
os.Stderr.Write(out)
Expand Down
7 changes: 4 additions & 3 deletions cmd/fyne/internal/commands/package-mobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"bytes"
"fmt"
"os"
"os/exec"
"path/filepath"
"strconv"

"fyne.io/fyne/v2"
"fyne.io/tools/cmd/fyne/internal/mobile"
"fyne.io/tools/cmd/fyne/internal/templates"

"golang.org/x/sys/execabs"
)

func (p *Packager) packageAndroid(arch string, tags []string) error {
Expand All @@ -37,7 +38,7 @@ func (p *Packager) packageIOS(target string, tags []string) error {

iconDir := util.EnsureSubDir(assetDir, "AppIcon.appiconset")
contentFile, _ := os.Create(filepath.Join(iconDir, "Contents.json"))

defer contentFile.Close()
err = templates.XCAssetsDarwin.Execute(contentFile, nil)
if err != nil {
return fmt.Errorf("failed to write xcassets content template: %w", err)
Expand Down Expand Up @@ -77,7 +78,7 @@ func runCmdCaptureOutput(name string, args ...string) error {
outbuf = &bytes.Buffer{}
errbuf = &bytes.Buffer{}
)
cmd := exec.Command(name, args...)
cmd := execabs.Command(name, args...)
cmd.Stdout = outbuf
cmd.Stderr = errbuf
err := cmd.Run()
Expand Down
6 changes: 3 additions & 3 deletions cmd/fyne/internal/commands/package-unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"bytes"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"

"fyne.io/tools/cmd/fyne/internal/metadata"
"fyne.io/tools/cmd/fyne/internal/templates"

"golang.org/x/sys/execabs"
)

type unixData struct {
Expand Down Expand Up @@ -57,7 +58,6 @@ func (p *Packager) packageUNIX() error {
appsDir := util.EnsureSubDir(shareDir, "applications")
desktop := filepath.Join(appsDir, p.Name+".desktop")
deskFile, _ := os.Create(desktop)
defer deskFile.Close()

linuxBSD := metadata.LinuxAndBSD{}
if p.linuxAndBSDMetadata != nil {
Expand Down Expand Up @@ -89,7 +89,7 @@ func (p *Packager) packageUNIX() error {
}

var buf bytes.Buffer
tarCmd := exec.Command("tar", "-Jcf", filepath.Join(p.dir, p.Name+".tar.xz"), "-C", filepath.Join(p.dir, tempDir), "usr", "Makefile")
tarCmd := execabs.Command("tar", "-Jcf", filepath.Join(p.dir, p.Name+".tar.xz"), "-C", filepath.Join(p.dir, tempDir), "usr", "Makefile")
tarCmd.Stderr = &buf
if err = tarCmd.Run(); err != nil {
return fmt.Errorf("failed to create archive with tar: %s - %w", buf.String(), err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/fyne/internal/commands/package-windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"image"
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
Expand All @@ -14,6 +13,7 @@ import (
"fyne.io/tools/cmd/fyne/internal/templates"
"github.com/fyne-io/image/ico"
"github.com/josephspurrier/goversioninfo"
"golang.org/x/sys/execabs"
)

type windowsData struct {
Expand Down Expand Up @@ -153,7 +153,7 @@ func escapePowerShellArguments(args ...string) string {
func runAsAdminWindows(args ...string) error {
cmd := escapePowerShellArguments(args...)

return exec.Command("powershell.exe", "Start-Process", "cmd.exe", "-Verb", "runAs", "-ArgumentList", cmd).Run()
return execabs.Command("powershell.exe", "Start-Process", "cmd.exe", "-Verb", "runAs", "-ArgumentList", cmd).Run()
}

func fixedVersionInfo(ver string) (ret goversioninfo.FileVersion) {
Expand Down
6 changes: 4 additions & 2 deletions cmd/fyne/internal/commands/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,20 @@ func (p *Packager) packageWithoutValidate() error {
}

func (p *Packager) buildPackage(runner runner, tags []string) ([]string, error) {
target := p.exe

b := &Builder{
os: p.os,
srcdir: p.srcDir,
target: p.exe,
target: target,
release: p.release,
tags: tags,
runner: runner,

appData: p.appData,
}

return []string{p.exe}, b.build()
return []string{target}, b.build()
}

func (p *Packager) combinedVersion() string {
Expand Down
22 changes: 11 additions & 11 deletions cmd/fyne/internal/commands/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"text/template"
Expand All @@ -15,6 +14,7 @@ import (
"fyne.io/tools/cmd/fyne/internal/templates"

"github.com/urfave/cli/v2"
"golang.org/x/sys/execabs"
)

var macAppStoreCategories = []string{
Expand Down Expand Up @@ -306,14 +306,14 @@ func (r *Releaser) packageIOSRelease() error {
}
defer cleanup()

cmd := exec.Command("codesign", "-f", "-vv", "-s", r.certificate, "--entitlements",
cmd := execabs.Command("codesign", "-f", "-vv", "-s", r.certificate, "--entitlements",
"entitlements.plist", "Payload/"+appName+"/")
if err := cmd.Run(); err != nil {
fyne.LogError("Codesign failed", err)
return errors.New("unable to codesign application bundle")
}

return exec.Command("zip", "-r", appName[:len(appName)-4]+".ipa", "Payload/").Run()
return execabs.Command("zip", "-r", appName[:len(appName)-4]+".ipa", "Payload/").Run()
}

func (r *Releaser) packageMacOSRelease() error {
Expand All @@ -330,14 +330,14 @@ func (r *Releaser) packageMacOSRelease() error {
}
defer cleanup()

cmd := exec.Command("codesign", "-vfs", appCert, "--entitlement", "entitlements.plist", r.Name+".app")
cmd := execabs.Command("codesign", "-vfs", appCert, "--entitlement", "entitlements.plist", r.Name+".app")
err = cmd.Run()
if err != nil {
fyne.LogError("Codesign failed", err)
return errors.New("unable to codesign application bundle")
}

cmd = exec.Command("productbuild", "--component", r.Name+".app", "/Applications/",
cmd = execabs.Command("productbuild", "--component", r.Name+".app", "/Applications/",
"--product", r.Name+".app/Contents/Info.plist", unsignedPath)
err = cmd.Run()
if err != nil {
Expand All @@ -346,7 +346,7 @@ func (r *Releaser) packageMacOSRelease() error {
}
defer os.Remove(unsignedPath)

cmd = exec.Command("productsign", "--sign", installCert, unsignedPath, r.Name+".pkg")
cmd = execabs.Command("productsign", "--sign", installCert, unsignedPath, r.Name+".pkg")
return cmd.Run()
}

Expand Down Expand Up @@ -382,7 +382,7 @@ func (r *Releaser) packageWindowsRelease(outFile string) error {
return errors.New("cannot find makeappx.exe, make sure you have installed the Windows SDK")
}

cmd := exec.Command(filepath.Join(binDir, "makeappx.exe"), "pack", "/d", payload, "/p", outFile)
cmd := execabs.Command(filepath.Join(binDir, "makeappx.exe"), "pack", "/d", payload, "/p", outFile)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
Expand Down Expand Up @@ -421,7 +421,7 @@ func (r *Releaser) signAndroid(path string) error {
args = append(args, r.keyName)
}

cmd := exec.Command(signer, args...)
cmd := execabs.Command(signer, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
Expand All @@ -434,7 +434,7 @@ func (r *Releaser) signWindows(appx string) error {
return errors.New("cannot find signtool.exe, make sure you have installed the Windows SDK")
}

cmd := exec.Command(filepath.Join(binDir, "signtool.exe"),
cmd := execabs.Command(filepath.Join(binDir, "signtool.exe"),
"sign", "/a", "/v", "/fd", "SHA256", "/f", r.certificate, "/p", r.password, appx)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down Expand Up @@ -527,7 +527,7 @@ func (r *Releaser) zipAlign(path string) error {
}

cmd := filepath.Join(util.AndroidBuildToolsPath(), "zipalign")
err = exec.Command(cmd, "4", unaligned, path).Run()
err = execabs.Command(cmd, "4", unaligned, path).Run()
if err != nil {
_ = os.Rename(path, unaligned) // ignore error, return previous
return err
Expand All @@ -536,7 +536,7 @@ func (r *Releaser) zipAlign(path string) error {
}

func findWindowsSDKBin() (string, error) {
inPath, err := exec.LookPath("makeappx.exe")
inPath, err := execabs.LookPath("makeappx.exe")
if err == nil {
return inPath, nil
}
Expand Down
6 changes: 4 additions & 2 deletions cmd/fyne/internal/commands/runner.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package commands

import "os/exec"
import (
"golang.org/x/sys/execabs"
)

type runner interface {
runOutput(arg ...string) ([]byte, error)
Expand All @@ -23,7 +25,7 @@ func (c *command) setEnv(env []string) {
}

func (c *command) runOutput(arg ...string) ([]byte, error) {
cmd := exec.Command(c.exe, arg...)
cmd := execabs.Command(c.exe, arg...)
cmd.Dir = c.dir
if c.env != nil {
cmd.Env = c.env
Expand Down
Loading