From 8e3cb27bfe1147ab5a8aaa76691579769476d4fc Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Wed, 16 Mar 2022 21:40:58 +1100 Subject: [PATCH] #1265 Support CGO_LDFLAGS --- .../templates/ides/goland/workspace.tmpl.xml | 6 +++++- .../commands/initialise/templates/templates.go | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/v2/cmd/wails/internal/commands/initialise/templates/ides/goland/workspace.tmpl.xml b/v2/cmd/wails/internal/commands/initialise/templates/ides/goland/workspace.tmpl.xml index 88bc6322..8587a93b 100644 --- a/v2/cmd/wails/internal/commands/initialise/templates/ides/goland/workspace.tmpl.xml +++ b/v2/cmd/wails/internal/commands/initialise/templates/ides/goland/workspace.tmpl.xml @@ -38,6 +38,8 @@ + + @@ -50,10 +52,11 @@ + value="-gcflags "all=-N -l" -ldflags "{{.WindowsFlags}}" -tags desktop,production,debug -o {{.PathToDesktopBinary}}"/> + @@ -70,6 +73,7 @@ + diff --git a/v2/cmd/wails/internal/commands/initialise/templates/templates.go b/v2/cmd/wails/internal/commands/initialise/templates/templates.go index 1287fc43..8c52f23c 100644 --- a/v2/cmd/wails/internal/commands/initialise/templates/templates.go +++ b/v2/cmd/wails/internal/commands/initialise/templates/templates.go @@ -66,6 +66,7 @@ type Options struct { GoSDKPath string WindowsFlags string CGOEnabled string + CGOLDFlags string OutputFile string } @@ -409,19 +410,20 @@ func installIDEFiles(o ideOptions) error { } binaryName := filepath.Base(o.options.TargetDir) - if runtime.GOOS == "windows" { - // yay windows + o.options.WindowsFlags = "" + o.options.CGOEnabled = "1" + + switch runtime.GOOS { + case "windows": binaryName += ".exe" + o.options.WindowsFlags = " -H windowsgui" + o.options.CGOEnabled = "0" + case "darwin": + o.options.CGOLDFlags = "-framework UniformTypeIdentifiers" } o.options.PathToDesktopBinary = filepath.ToSlash(filepath.Join("build", "bin", binaryName)) - o.options.WindowsFlags = "" - o.options.CGOEnabled = "1" - if runtime.GOOS == "windows" { - o.options.WindowsFlags = " -H windowsgui" - o.options.CGOEnabled = "0" - } err = installer.Extract(o.targetDir, o.options) if err != nil { return err