cmd/gio: use the import path as basis for the output file

Before this change `go list <pkg>` 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}} <pkg>`.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-07-13 20:19:25 +02:00
parent 41990e3275
commit cde040369c
4 changed files with 13 additions and 9 deletions
+3 -3
View File
@@ -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(`<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="%s"
@@ -355,7 +355,7 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo) (err error) {
func signAPK(tmpDir string, tools *androidTools, bi *buildInfo) error {
apkFile := *destPath
if apkFile == "" {
apkFile = fmt.Sprintf("%s.apk", filepath.Base(bi.pkg))
apkFile = fmt.Sprintf("%s.apk", bi.name)
}
if filepath.Ext(apkFile) != ".apk" {
return fmt.Errorf("the specified output %q does not end in '.apk'", apkFile)