#1265 Support CGO_LDFLAGS

This commit is contained in:
Lea Anthony
2022-03-16 21:40:58 +11:00
parent 78212603bc
commit 8e3cb27bfe
2 changed files with 15 additions and 9 deletions
@@ -38,6 +38,8 @@
<useCustomBuildTags value="true"/>
<envs>
<env name="CGO_ENABLED" value="&quot;{{.CGOEnabled}}&quot;"/>
<env name="CGO_LDFLAGS" value="&quot;{{.CGOLDFlags}}&quot;"/>
</envs>
<kind value="DIRECTORY"/>
<directory value="$PROJECT_DIR$"/>
@@ -50,10 +52,11 @@
<module name="{{.ProjectName}}"/>
<working_directory value="$PROJECT_DIR$"/>
<go_parameters
value="-ldflags &quot;{{.WindowsFlags}}&quot; -tags desktop,production,debug -o {{.PathToDesktopBinary}}"/>
value="-gcflags &quot;all=-N -l&quot; -ldflags &quot;{{.WindowsFlags}}&quot; -tags desktop,production,debug -o {{.PathToDesktopBinary}}"/>
<useCustomBuildTags value="true"/>
<envs>
<env name="CGO_ENABLED" value="&quot;{{.CGOEnabled}}&quot;"/>
<env name="CGO_LDFLAGS" value="&quot;{{.CGOLDFlags}}&quot;"/>
</envs>
<kind value="DIRECTORY"/>
<directory value="$PROJECT_DIR$"/>
@@ -70,6 +73,7 @@
<useCustomBuildTags value="true"/>
<envs>
<env name="CGO_ENABLED" value="&quot;{{.CGOEnabled}}&quot;"/>
<env name="CGO_LDFLAGS" value="&quot;{{.CGOLDFlags}}&quot;"/>
</envs>
<kind value="DIRECTORY"/>
<directory value="$PROJECT_DIR$"/>
@@ -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