forked from joejulian/gio
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:
+7
-3
@@ -10,6 +10,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -24,6 +25,7 @@ var (
|
||||
)
|
||||
|
||||
type buildInfo struct {
|
||||
name string
|
||||
pkg string
|
||||
ldflags string
|
||||
archs []string
|
||||
@@ -56,13 +58,15 @@ func main() {
|
||||
default:
|
||||
errorf("invalid -buildmode %s\n", *buildMode)
|
||||
}
|
||||
// Expand relative package paths.
|
||||
pkg, err := runCmd(exec.Command("go", "list", pkg))
|
||||
// Find package name.
|
||||
name, err := runCmd(exec.Command("go", "list", "-f", "{{.ImportPath}}", pkg))
|
||||
if err != nil {
|
||||
errorf("gio: %v", err)
|
||||
}
|
||||
name = filepath.Base(name)
|
||||
bi := &buildInfo{
|
||||
pkg: pkg,
|
||||
name: name,
|
||||
pkg: pkg,
|
||||
}
|
||||
switch *target {
|
||||
case "js":
|
||||
|
||||
Reference in New Issue
Block a user