From 771594519fd4bf1d26e0e900d6f7f5be02a74cbe Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Thu, 10 Feb 2022 21:41:40 +1100 Subject: [PATCH] [mac] Better support for multi-builds --- v2/cmd/wails/internal/commands/build/build.go | 16 +++++++++++----- v2/pkg/commands/build/build.go | 1 + v2/pkg/commands/build/packager.go | 5 ++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/v2/cmd/wails/internal/commands/build/build.go b/v2/cmd/wails/internal/commands/build/build.go index 8e6f0147..3fb32cbc 100644 --- a/v2/cmd/wails/internal/commands/build/build.go +++ b/v2/cmd/wails/internal/commands/build/build.go @@ -2,9 +2,6 @@ package build import ( "fmt" - "github.com/wailsapp/wails/v2/internal/colour" - "github.com/wailsapp/wails/v2/internal/project" - "github.com/wailsapp/wails/v2/internal/system" "io" "os" "os/exec" @@ -14,6 +11,10 @@ import ( "text/tabwriter" "time" + "github.com/wailsapp/wails/v2/internal/colour" + "github.com/wailsapp/wails/v2/internal/project" + "github.com/wailsapp/wails/v2/internal/system" + "github.com/wailsapp/wails/v2/cmd/wails/internal" "github.com/wailsapp/wails/v2/internal/gomod" @@ -187,7 +188,6 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) { w.Init(os.Stdout, 8, 8, 0, '\t', 0) // Write out the system information - fmt.Fprintf(w, "\n") fmt.Fprintf(w, "App Type: \t%s\n", buildOptions.OutputType) fmt.Fprintf(w, "Platforms: \t%s\n", platform) fmt.Fprintf(w, "Compiler: \t%s\n", compilerPath) @@ -274,6 +274,12 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) { logger.Println("Crosscompiling to Mac not currently supported.\n") return } + macTargets := targets.Filter(func(platform string) bool { + return strings.HasPrefix(platform, "darwin") + }) + if macTargets.Length() == 2 { + buildOptions.BundleName = fmt.Sprintf("%s-%s.app", desiredFilename, buildOptions.Arch) + } } if targets.Length() > 1 { @@ -281,7 +287,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) { switch buildOptions.Platform { case "windows": desiredFilename = fmt.Sprintf("%s-%s", desiredFilename, buildOptions.Arch) - default: + case "linux", "darwin": desiredFilename = fmt.Sprintf("%s-%s-%s", desiredFilename, buildOptions.Platform, buildOptions.Arch) } } diff --git a/v2/pkg/commands/build/build.go b/v2/pkg/commands/build/build.go index b32a31ef..083fcb62 100644 --- a/v2/pkg/commands/build/build.go +++ b/v2/pkg/commands/build/build.go @@ -53,6 +53,7 @@ type Options struct { RunDelve bool // Indicates if we should run delve after the build WailsJSDir string // Directory to generate the wailsjs module ForceBuild bool // Force + BundleName string // Bundlename for Mac } // Build the project! diff --git a/v2/pkg/commands/build/packager.go b/v2/pkg/commands/build/packager.go index d18d0dfa..3fbfcd20 100644 --- a/v2/pkg/commands/build/packager.go +++ b/v2/pkg/commands/build/packager.go @@ -85,7 +85,10 @@ func packageApplicationForDarwin(options *Options) error { var err error // Create directory structure - bundlename := options.ProjectData.Name + ".app" + bundlename := options.BundleName + if bundlename == "" { + bundlename = options.ProjectData.Name + ".app" + } contentsDirectory := filepath.Join(options.BuildDirectory, bundlename, "/Contents") exeDir := filepath.Join(contentsDirectory, "/MacOS")