forked from fyne-io/fyne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request fyne-io#4715 from andydotxyz/fix/4688
Read from FyneApp.toml when developing with go tools
- Loading branch information
Showing
18 changed files
with
88 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package app | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"fyne.io/fyne/v2" | ||
"fyne.io/fyne/v2/internal/build" | ||
"fyne.io/fyne/v2/internal/metadata" | ||
) | ||
|
||
func checkLocalMetadata() { | ||
if build.NoMetadata || build.Mode == fyne.BuildRelease { | ||
return | ||
} | ||
|
||
dir := getProjectPath() | ||
file := filepath.Join(dir, "FyneApp.toml") | ||
ref, err := os.Open(file) | ||
if err != nil { // no worries, this is just an optional fallback | ||
return | ||
} | ||
defer ref.Close() | ||
|
||
data, err := metadata.Load(ref) | ||
if err != nil || data == nil { | ||
fyne.LogError("failed to parse FyneApp.toml", err) | ||
return | ||
} | ||
|
||
meta.ID = data.Details.ID | ||
meta.Name = data.Details.Name | ||
meta.Version = data.Details.Version | ||
meta.Build = data.Details.Build | ||
|
||
if data.Details.Icon != "" { | ||
res, err := fyne.LoadResourceFromPath(data.Details.Icon) | ||
if err == nil { | ||
meta.Icon = res | ||
} | ||
} | ||
|
||
meta.Release = false | ||
meta.Custom = data.Development | ||
} | ||
|
||
func getProjectPath() string { | ||
exe, err := os.Executable() | ||
work, _ := os.Getwd() | ||
|
||
if err != nil { | ||
fyne.LogError("failed to lookup build executable", err) | ||
return work | ||
} | ||
|
||
temp := os.TempDir() | ||
if strings.Contains(exe, temp) { // this happens with "go run" | ||
return work | ||
} | ||
|
||
// we were called with an executable from "go build" | ||
return filepath.Dir(exe) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//go:build !no_metadata | ||
|
||
package build | ||
|
||
// NoMetadata is false if the compiler flags have not turned off metadata support. | ||
const NoMetadata = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//go:build no_metadata | ||
|
||
package build | ||
|
||
// NoMetadata is true if the compiler flags have turned off metadata support. | ||
const NoMetadata = true |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.