Commit d24c3124 authored by Elias Naur's avatar Elias Naur

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 38642b9f
...@@ -156,8 +156,12 @@ func subdir() (pkgpath string, underGoRoot bool) { ...@@ -156,8 +156,12 @@ func subdir() (pkgpath string, underGoRoot bool) {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
if root := runtime.GOROOT(); strings.HasPrefix(cwd, root) { goroot, err := filepath.EvalSymlinks(runtime.GOROOT())
subdir, err := filepath.Rel(root, cwd) if err != nil {
log.Fatal(err)
}
if strings.HasPrefix(cwd, goroot) {
subdir, err := filepath.Rel(goroot, cwd)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
...@@ -165,10 +169,14 @@ func subdir() (pkgpath string, underGoRoot bool) { ...@@ -165,10 +169,14 @@ func subdir() (pkgpath string, underGoRoot bool) {
} }
for _, p := range filepath.SplitList(build.Default.GOPATH) { 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 continue
} }
subdir, err := filepath.Rel(p, cwd) subdir, err := filepath.Rel(pabs, cwd)
if err == nil { if err == nil {
return subdir, false return subdir, false
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment