From 0f1d0380dc062a1fe3fdc3d5ba20c4dd5afed486 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 2 May 2018 08:30:23 +0200 Subject: [PATCH] build: Syso stuff needs to happen on build (ref #4909) --- build.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/build.go b/build.go index 79c8e72b8..f1e6de0d5 100644 --- a/build.go +++ b/build.go @@ -429,8 +429,9 @@ func install(target target, tags []string) { os.Setenv("GOOS", goos) os.Setenv("GOARCH", goarch) - // On Windows generate a special file which the Go compiler will automatically use when generating Windows binaries - // to set things like the file icon, version, etc. + // On Windows generate a special file which the Go compiler will + // automatically use when generating Windows binaries to set things like + // the file icon, version, etc. if goos == "windows" { sysoPath, err := shouldBuildSyso(cwd) if err != nil { @@ -454,6 +455,22 @@ func build(target target, tags []string) { os.Setenv("GOOS", goos) os.Setenv("GOARCH", goarch) + + // On Windows generate a special file which the Go compiler will + // automatically use when generating Windows binaries to set things like + // the file icon, version, etc. + if goos == "windows" { + cwd, err := os.Getwd() + if err != nil { + log.Fatal(err) + } + sysoPath, err := shouldBuildSyso(cwd) + if err != nil { + log.Printf("Warning: Windows binaries will not have file information encoded: %v", err) + } + defer shouldCleanupSyso(sysoPath) + } + runPrint("go", args...) }