From edef73f580b800bb3544cc66b4136634474ba622 Mon Sep 17 00:00:00 2001 From: axel paulander Date: Sat, 15 Aug 2020 21:32:48 +0200 Subject: [PATCH] cmd/gogio: add -icon flag for specifying the app icon file Before users were limited to only use a appicon.png in the root directory. Now the user is free to use any png anywhere on the system with the help of the -icon flag. Signed-off-by: Axel Paulander --- cmd/gogio/androidbuild.go | 5 ++++- cmd/gogio/help.go | 7 ++++--- cmd/gogio/iosbuild.go | 5 ++++- cmd/gogio/main.go | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cmd/gogio/androidbuild.go b/cmd/gogio/androidbuild.go index 5150ef7d..69299614 100644 --- a/cmd/gogio/androidbuild.go +++ b/cmd/gogio/androidbuild.go @@ -350,7 +350,10 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo, extraJars, pe return err } } - icon := filepath.Join(bi.dir, "appicon.png") + icon := *iconPath + if icon == "" { + icon = filepath.Join(bi.dir, "appicon.png") + } iconSnip := "" if _, err := os.Stat(icon); err == nil { err := buildIcons(resDir, icon, []iconVariant{ diff --git a/cmd/gogio/help.go b/cmd/gogio/help.go index 1cd41f73..b3701a76 100644 --- a/cmd/gogio/help.go +++ b/cmd/gogio/help.go @@ -15,9 +15,6 @@ programs for platforms where additional metadata or support files are required. The package argument specifies an import path or a single Go source file to package. Any run arguments are appended to os.Args at runtime. -If the package contains an appicon.png file, it is used as the app icon on -supported platforms. - Compiled Java class files from jar files in the package directory are included in Android builds. @@ -42,6 +39,10 @@ will output an app directory suitable for a simulator. The other buildmode is archive, which will output an .aar library for Android or a .framework for iOS and tvOS. +The -icon flag specifies a path to a PNG image to use as app icon on iOS and Android. +If left unspecified, the appicon.png file from the main package is used +(if it exists). + The -appid flag specifies the package name for Android or the bundle id for iOS and tvOS. A bundle id must be provisioned through Xcode before the gogio tool can use it. diff --git a/cmd/gogio/iosbuild.go b/cmd/gogio/iosbuild.go index 20cde3d6..495236f5 100644 --- a/cmd/gogio/iosbuild.go +++ b/cmd/gogio/iosbuild.go @@ -222,7 +222,10 @@ int main(int argc, char * argv[]) { if err := ioutil.WriteFile(plistFile, []byte(infoPlist), 0660); err != nil { return err } - icon := filepath.Join(bi.dir, "appicon.png") + icon := *iconPath + if icon == "" { + icon = filepath.Join(bi.dir, "appicon.png") + } if _, err := os.Stat(icon); err == nil { assetPlist, err := iosIcons(bi, tmpDir, app, icon) if err != nil { diff --git a/cmd/gogio/main.go b/cmd/gogio/main.go index 2af7273c..cc04cb5d 100644 --- a/cmd/gogio/main.go +++ b/cmd/gogio/main.go @@ -34,6 +34,7 @@ var ( linkMode = flag.String("linkmode", "", "set the -linkmode flag of the go tool") extraLdflags = flag.String("ldflags", "", "extra flags to the Go linker") extraTags = flag.String("tags", "", "extra tags to the Go tool") + iconPath = flag.String("icon", "", "Specify an icon for iOS and Android") ) type buildInfo struct {