go/gcimporter15: interpret relative srcDir relative to cwd
This is a backport of the respective changes in golang.org/cl/19393. For golang/go#14215. Change-Id: I8d60dd6daa827a60597f3af925e6732914537319 Reviewed-on: https://go-review.googlesource.com/19394 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
fe74a41861
commit
7ed774bdc0
|
|
@ -42,7 +42,8 @@ var pkgExts = [...]string{".a", ".o"}
|
||||||
|
|
||||||
// FindPkg returns the filename and unique package id for an import
|
// FindPkg returns the filename and unique package id for an import
|
||||||
// path based on package information provided by build.Import (using
|
// path based on package information provided by build.Import (using
|
||||||
// the build.Default build.Context).
|
// the build.Default build.Context). A relative srcDir is interpreted
|
||||||
|
// relative to the current working directory.
|
||||||
// If no file was found, an empty filename is returned.
|
// If no file was found, an empty filename is returned.
|
||||||
//
|
//
|
||||||
func FindPkg(path, srcDir string) (filename, id string) {
|
func FindPkg(path, srcDir string) (filename, id string) {
|
||||||
|
|
@ -55,6 +56,9 @@ func FindPkg(path, srcDir string) (filename, id string) {
|
||||||
default:
|
default:
|
||||||
// "x" -> "$GOPATH/pkg/$GOOS_$GOARCH/x.ext", "x"
|
// "x" -> "$GOPATH/pkg/$GOOS_$GOARCH/x.ext", "x"
|
||||||
// Don't require the source files to be present.
|
// Don't require the source files to be present.
|
||||||
|
if abs, err := filepath.Abs(srcDir); err == nil { // see issue 14282
|
||||||
|
srcDir = abs
|
||||||
|
}
|
||||||
bp, _ := build.Import(path, srcDir, build.FindOnly|build.AllowBinary)
|
bp, _ := build.Import(path, srcDir, build.FindOnly|build.AllowBinary)
|
||||||
if bp.PkgObj == "" {
|
if bp.PkgObj == "" {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue