From: Elias Naur Date: Fri, 1 Mar 2019 00:03:20 +0000 (+0100) Subject: misc/android: evaluate symlinks before comparing GOROOT and GOPATH X-Git-Tag: go1.13beta1~1292 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d24c3124cab290f5f7e1c75be4c6cbe6dd05a85c;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/misc/android/go_android_exec.go b/misc/android/go_android_exec.go index fa84f00f67..845ed6e99c 100644 --- a/misc/android/go_android_exec.go +++ b/misc/android/go_android_exec.go @@ -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 }