mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
cmd/gogio: restore package path handling
A previous change converted the package argument to gogio to an absolute path. However, gogio supports all package paths that may appear in Go import statements. For example, the path "gioui.org/cmd/example/kitchen" should not be converted. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+6
-12
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -22,8 +21,8 @@ type buildInfo struct {
|
||||
version int
|
||||
}
|
||||
|
||||
func newBuildInfo(pkgAbsPath string) (*buildInfo, error) {
|
||||
pkgMetadata, err := getPkgMetadata(pkgAbsPath)
|
||||
func newBuildInfo(pkgPath string) (*buildInfo, error) {
|
||||
pkgMetadata, err := getPkgMetadata(pkgPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -35,7 +34,7 @@ func newBuildInfo(pkgAbsPath string) (*buildInfo, error) {
|
||||
minsdk: *minsdk,
|
||||
name: getPkgName(pkgMetadata),
|
||||
pkgDir: pkgMetadata.Dir,
|
||||
pkgPath: pkgAbsPath,
|
||||
pkgPath: pkgPath,
|
||||
tags: *extraTags,
|
||||
target: *target,
|
||||
version: *version,
|
||||
@@ -43,11 +42,6 @@ func newBuildInfo(pkgAbsPath string) (*buildInfo, error) {
|
||||
return bi, nil
|
||||
}
|
||||
|
||||
func getPkgAbsPath() string {
|
||||
absPath, _ := filepath.Abs(flag.Arg(0))
|
||||
return absPath
|
||||
}
|
||||
|
||||
func getArchs() []string {
|
||||
if *archNames != "" {
|
||||
return strings.Split(*archNames, ",")
|
||||
@@ -88,12 +82,12 @@ type packageMetadata struct {
|
||||
Dir string
|
||||
}
|
||||
|
||||
func getPkgMetadata(absPath string) (*packageMetadata, error) {
|
||||
pkgImportPath, err := runCmd(exec.Command("go", "list", "-f", "{{.ImportPath}}", absPath))
|
||||
func getPkgMetadata(pkgPath string) (*packageMetadata, error) {
|
||||
pkgImportPath, err := runCmd(exec.Command("go", "list", "-f", "{{.ImportPath}}", pkgPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pkgDir, err := runCmd(exec.Command("go", "list", "-f", "{{.Dir}}", absPath))
|
||||
pkgDir, err := runCmd(exec.Command("go", "list", "-f", "{{.Dir}}", pkgPath))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user