1
0
mirror of https://github.com/golang/go synced 2024-11-26 04:37:59 -07:00

misc/android: evaluate symlinks before comparing GOROOT and GOPATH

Should fix Android builders on Darwin hosts.

Change-Id: I1554849bdf2ad2440529af7f93566fa6f11d5407
Reviewed-on: https://go-review.googlesource.com/c/164697
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Elias Naur 2019-03-01 01:03:20 +01:00
parent 38642b9fce
commit d24c3124ca

View File

@ -156,8 +156,12 @@ func subdir() (pkgpath string, underGoRoot bool) {
if err != nil {
log.Fatal(err)
}
if root := runtime.GOROOT(); strings.HasPrefix(cwd, root) {
subdir, err := filepath.Rel(root, cwd)
goroot, err := filepath.EvalSymlinks(runtime.GOROOT())
if err != nil {
log.Fatal(err)
}
if strings.HasPrefix(cwd, goroot) {
subdir, err := filepath.Rel(goroot, cwd)
if err != nil {
log.Fatal(err)
}
@ -165,10 +169,14 @@ func subdir() (pkgpath string, underGoRoot bool) {
}
for _, p := range filepath.SplitList(build.Default.GOPATH) {
if !strings.HasPrefix(cwd, p) {
pabs, err := filepath.EvalSymlinks(p)
if err != nil {
log.Fatal(err)
}
if !strings.HasPrefix(cwd, pabs) {
continue
}
subdir, err := filepath.Rel(p, cwd)
subdir, err := filepath.Rel(pabs, cwd)
if err == nil {
return subdir, false
}