From cde040369cfca37e1acfc90f63d4d49928711a65 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 13 Jul 2019 20:19:25 +0200 Subject: [PATCH] cmd/gio: use the import path as basis for the output file Before this change `go list ` was used to sanitize the import path of the package argument. That doesn't work well for building Go source files directly: gio -target android helloworld.go where `go list helloworld.go` simply returns "command-line-arguments". A better way is to leave the package path alone, and compute the output file separately from the import path, as reported by `go list -f {{.ImportPath}} `. Signed-off-by: Elias Naur --- cmd/gio/androidbuild.go | 6 +++--- cmd/gio/gio.go | 10 +++++++--- cmd/gio/iosbuild.go | 4 ++-- cmd/gio/jsbuild.go | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cmd/gio/androidbuild.go b/cmd/gio/androidbuild.go index 339bc54b..d8b9f9b9 100644 --- a/cmd/gio/androidbuild.go +++ b/cmd/gio/androidbuild.go @@ -158,7 +158,7 @@ func compileAndroid(tmpDir string, tools *androidTools, bi *buildInfo) (err erro func archiveAndroid(tmpDir string, bi *buildInfo) (err error) { aarFile := *destPath if aarFile == "" { - aarFile = fmt.Sprintf("%s.aar", filepath.Base(bi.pkg)) + aarFile = fmt.Sprintf("%s.aar", bi.name) } if filepath.Ext(aarFile) != ".aar" { return fmt.Errorf("the specified output %q does not end in '.aar'", aarFile) @@ -276,7 +276,7 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo) (err error) { } // Link APK. - appName := strings.Title(filepath.Base(bi.pkg)) + appName := strings.Title(bi.name) manifestSrc := fmt.Sprintf(` diff --git a/cmd/gio/jsbuild.go b/cmd/gio/jsbuild.go index 336881bf..03862aae 100644 --- a/cmd/gio/jsbuild.go +++ b/cmd/gio/jsbuild.go @@ -13,7 +13,7 @@ import ( func buildJS(bi *buildInfo) error { out := *destPath if out == "" { - out = filepath.Base(bi.pkg) + out = bi.name } if err := os.MkdirAll(out, 0700); err != nil { return err