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 selected commits from fyne repo #23

Merged
merged 11 commits into from
Oct 17, 2024
9 changes: 8 additions & 1 deletion cmd/fyne/internal/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -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
8 changes: 8 additions & 0 deletions cmd/fyne/internal/commands/package-unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ type unixData struct {
Comment string
Keywords string
ExecParams string

SourceRepo, SourceDir string
}

func (p *Packager) packageUNIX() error {
Expand Down Expand Up @@ -74,6 +76,12 @@ func (p *Packager) packageUNIX() error {
Categories: formatDesktopFileList(linuxBSD.Categories),
ExecParams: linuxBSD.ExecParams,
}

if p.sourceMetadata != nil {
tplData.SourceRepo = p.sourceMetadata.Repo
tplData.SourceDir = p.sourceMetadata.Dir
}

err = templates.DesktopFileUNIX.Execute(deskFile, tplData)
if err != nil {
return fmt.Errorf("failed to write desktop entry string: %w", err)
Expand Down
23 changes: 23 additions & 0 deletions cmd/fyne/internal/commands/package-unix_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package commands

import (
"bytes"
"strings"
"testing"

"fyne.io/tools/cmd/fyne/internal/templates"
"github.com/stretchr/testify/assert"
)

Expand All @@ -11,3 +14,23 @@ func TestFormatDesktopFileList(t *testing.T) {
assert.Equal(t, "One;", formatDesktopFileList([]string{"One"}))
assert.Equal(t, "One;Two;", formatDesktopFileList([]string{"One", "Two"}))
}

func TestDesktopFileSource(t *testing.T) {
tplData := unixData{
Name: "Testing",
}
buf := &bytes.Buffer{}

err := templates.DesktopFileUNIX.Execute(buf, tplData)
assert.Nil(t, err)
assert.False(t, strings.Contains(buf.String(), "[X-Fyne"))

tplData.SourceRepo = "https://example.com"
tplData.SourceDir = "cmd/name"

err = templates.DesktopFileUNIX.Execute(buf, tplData)
assert.Nil(t, err)
assert.True(t, strings.Contains(buf.String(), "[X-Fyne"))
assert.True(t, strings.Contains(buf.String(), "Repo=https://example.com"))
assert.True(t, strings.Contains(buf.String(), "Dir=cmd/name"))
}
3 changes: 3 additions & 0 deletions cmd/fyne/internal/commands/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ type Packager struct {

customMetadata keyValueFlag
linuxAndBSDMetadata *metadata.LinuxAndBSD
sourceMetadata *metadata.AppSource
}

// NewPackager returns a command that can handle the packaging a GUI apps built using Fyne from local source code.
Expand Down Expand Up @@ -340,6 +341,8 @@ func (p *Packager) validate() (err error) {
}

p.appData.mergeMetadata(data)
p.sourceMetadata = data.Source

p.linuxAndBSDMetadata = data.LinuxAndBSD
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/fyne/internal/metadata/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type FyneApp struct {
Details AppDetails
Development map[string]string `toml:",omitempty"`
Release map[string]string `toml:",omitempty"`
Source *AppSource `toml:",omitempty"`
LinuxAndBSD *LinuxAndBSD `toml:",omitempty"`
}

Expand All @@ -17,6 +18,10 @@ type AppDetails struct {
Build int `toml:",omitempty"`
}

type AppSource struct {
Repo, Dir string `toml:",omitempty"`
}

// LinuxAndBSD describes specific metadata for desktop files on Linux and BSD.
type LinuxAndBSD struct {
GenericName string `toml:",omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions cmd/fyne/internal/metadata/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ func TestLoadAppMetadata(t *testing.T) {
assert.Equal(t, data.Development["Test"], "Value2")
assert.Equal(t, data.Development["InDevelopmentOnly"], "Value4")
assert.NotContains(t, data.Development, "InReleaseOnly")

assert.NotNil(t, data.Source)
assert.Equal(t, data.Source.Repo, "https://github.com/fyne-io/fyne")
assert.Equal(t, data.Source.Dir, "internal/metadata/testdata")
}
4 changes: 4 additions & 0 deletions cmd/fyne/internal/metadata/testdata/FyneApp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Icon = "https://conf.fyne.io/assets/img/fyne.png"
Version = "1.0.0"
Build = 1

[Source]
Repo = "https://github.com/fyne-io/fyne"
Dir = "internal/metadata/testdata"

[Release]
Test = "Value1"
InReleaseOnly = "Value3"
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/internal/mobile/README.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This directory is a partial clone of the golang.org/x/mobile/cmd/gomobile package.
It also includes the golang.org/x/mobile/internal/bindata as a subpackage.

The full project, it's license and command line tools can be found at https://github.com/golang/mobile
The full project, its license and command line tools can be found at https://github.com/golang/mobile

This package is for the purpose of removing a runtime dependency and will be removed in due course.
4 changes: 2 additions & 2 deletions cmd/fyne/internal/mobile/binres/binres.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func addAttributeNamespace(attr xml.Attr, nattr *Attribute, tbl *Table, pool *Po
return fmt.Errorf("invalid bool value %q", attr.Value)
}
case DataIntDec, DataFloat, DataFraction:
// TODO DataFraction needs it's own case statement. minSdkVersion identifies as DataFraction
// TODO DataFraction needs its own case statement. minSdkVersion identifies as DataFraction
// but has accepted input in the past such as android:minSdkVersion="L"
// Other use-cases for DataFraction are currently unknown as applicable to manifest generation
// but this provides minimum support for writing out minSdkVersion="15" correctly.
Expand Down Expand Up @@ -851,7 +851,7 @@ func (bx *XML) kind(t ResType) (unmarshaler, error) {
}
}

// MarshalBinary formats the XML in memory to it's text appearance
// MarshalBinary formats the XML in memory to its text appearance
func (bx *XML) MarshalBinary() ([]byte, error) {
bx.typ = ResXML
bx.headerByteSize = 8
Expand Down
3 changes: 2 additions & 1 deletion cmd/fyne/internal/mobile/binres/binres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bytes"
"encoding"
"encoding/xml"
"errors"
"fmt"
"math"
"os"
Expand Down Expand Up @@ -246,7 +247,7 @@ func compareElements(have, want *XML) error {
}
}
if buf.Len() > 0 {
return fmt.Errorf(buf.String())
return errors.New(buf.String())
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/internal/mobile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func runBuildImpl(cmd *command) (*packages.Package, error) {
}
return pkg, nil
}
target := 33
target := 35
if !buildRelease {
target = 29 // TODO once we have gomobile debug signing working for v2 android signs
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/fyne/internal/mobile/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Package mobile is a partial clone of the golang.org/x/mobile/cmd/gomobile package.
It also includes the golang.org/x/mobile/internal/bindata as a subpackage.

The full project, it's license and command line tools can be found at https://github.com/golang/mobile
The full project, its license and command line tools can be found at https://github.com/golang/mobile

This package is for the purpose of removing a runtime dependency and will be removed in due course.
*/
Expand Down
4 changes: 2 additions & 2 deletions cmd/fyne/internal/templates/bundled.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion cmd/fyne/internal/templates/data/app.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ Icon={{.Name}}
Comment={{.Comment}}{{end}}
{{- if ne .Categories ""}}
Categories={{.Categories}}{{end}}
{{if ne .Keywords ""}}Keywords={{.Keywords}}{{else}}Keywords=fyne;{{end}}
Keywords={{if ne .Keywords ""}}{{.Keywords}}{{else}}fyne;{{end}}

{{if or (ne .SourceRepo "") (ne .SourceDir "") -}}
[X-Fyne Source]
Repo={{.SourceRepo}}
Dir={{.SourceDir}}

{{end -}}
1 change: 0 additions & 1 deletion cmd/fyne/internal/templates/data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
.centered-container {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
justify-content: center;
min-height: 100vh;
Expand Down