From 0ae00aa13864676f4b270da589ca540bc836c239 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 5 Mar 2020 01:05:53 +0900 Subject: [PATCH] cmd/ebitenmobile: Bug fix: .exe was requried on Windows On Windows, executable files must have .exe extension, or exec.LookPath since exec.LookPath checks %PATHEXT%. This fixes the issue that ebitenmobile didn't invoke the original gobind wrapper and then didn't include and compile some Java files. Fixes #1096 --- cmd/ebitenmobile/gomobile.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/ebitenmobile/gomobile.go b/cmd/ebitenmobile/gomobile.go index 17b1953ab..6c49406f8 100644 --- a/cmd/ebitenmobile/gomobile.go +++ b/cmd/ebitenmobile/gomobile.go @@ -59,6 +59,15 @@ func runGo(args ...string) error { return runCommand(gocmd, args, env) } +// exe adds the .exe extension to the given filename. +// Without .exe, the executable won't be found by exec.LookPath on Windows (#1096). +func exe(filename string) string { + if runtime.GOOS == "windows" { + return filename + ".exe" + } + return filename +} + func prepareGomobileCommands() error { tmp, err := ioutil.TempDir("", "ebitenmobile-") if err != nil { @@ -98,10 +107,10 @@ func prepareGomobileCommands() error { if err := runGo("get", "golang.org/x/mobile@"+gomobileHash); err != nil { return err } - if err := runGo("build", "-o", filepath.Join("bin", "gomobile"), "golang.org/x/mobile/cmd/gomobile"); err != nil { + if err := runGo("build", "-o", exe(filepath.Join("bin", "gomobile")), "golang.org/x/mobile/cmd/gomobile"); err != nil { return err } - if err := runGo("build", "-o", filepath.Join("bin", "gobind-original"), "golang.org/x/mobile/cmd/gobind"); err != nil { + if err := runGo("build", "-o", exe(filepath.Join("bin", "gobind-original")), "golang.org/x/mobile/cmd/gobind"); err != nil { return err } @@ -112,7 +121,7 @@ func prepareGomobileCommands() error { return err } - if err := runGo("build", "-o", filepath.Join("bin", "gobind"), "-tags", "ebitenmobilegobind", filepath.Join("src", "gobind.go")); err != nil { + if err := runGo("build", "-o", exe(filepath.Join("bin", "gobind")), "-tags", "ebitenmobilegobind", filepath.Join("src", "gobind.go")); err != nil { return err }