From b09ad073c4c40a4f3f6430e761256e67e478bc73 Mon Sep 17 00:00:00 2001 From: "Randall C. O'Reilly" Date: Wed, 18 Dec 2024 00:37:10 -0800 Subject: [PATCH] core tool buildDesktop detects presence of a cmd directory and builds in there. Fixes #1381 --- cmd/core/cmd/build.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/core/cmd/build.go b/cmd/core/cmd/build.go index 614fe40a8a..848173b862 100644 --- a/cmd/core/cmd/build.go +++ b/cmd/core/cmd/build.go @@ -78,9 +78,21 @@ func buildDesktop(c *config.Config, platform config.Platform) error { } } ldflags += " " + config.LinkerFlags(c) + + inCmd := false + fi, err := os.Stat("cmd") + if err == nil && fi.IsDir() { + os.Chdir("cmd") + inCmd = true + } + args = append(args, "-ldflags", ldflags, "-o", filepath.Join(c.Build.Output, output)) - err := xc.Run("go", args...) + err = xc.Run("go", args...) + if inCmd { + os.Rename(output, filepath.Join("..", output)) + os.Chdir("../") + } if err != nil { return fmt.Errorf("error building for platform %s/%s: %w", platform.OS, platform.Arch, err) }