Commit aafa855f authored by Elias Naur's avatar Elias Naur

misc/ios: evaluate symlinks before comparing GOROOT and GOPATH

CL 163726 added workarounds to keep the iOS builders happy in
a symlinked temporary dir.

The workarounds also made the tests more realistic and improved
performance. Keep them but also handle symlinks better in the
exec wrapper.

Change-Id: Iaa2c03a1a3fb3aa5aaf62d79d52b63d5d8f11db5
Reviewed-on: https://go-review.googlesource.com/c/164698Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
parent d96b7fbf
...@@ -633,8 +633,12 @@ func subdir() (pkgpath string, underGoRoot bool, err error) { ...@@ -633,8 +633,12 @@ func subdir() (pkgpath string, underGoRoot bool, err error) {
if err != nil { if err != nil {
return "", false, err return "", false, err
} }
if root := runtime.GOROOT(); strings.HasPrefix(cwd, root) { goroot, err := filepath.EvalSymlinks(runtime.GOROOT())
subdir, err := filepath.Rel(root, cwd) if err != nil {
return "", false, err
}
if strings.HasPrefix(cwd, goroot) {
subdir, err := filepath.Rel(goroot, cwd)
if err != nil { if err != nil {
return "", false, err return "", false, err
} }
...@@ -642,10 +646,14 @@ func subdir() (pkgpath string, underGoRoot bool, err error) { ...@@ -642,10 +646,14 @@ func subdir() (pkgpath string, underGoRoot bool, err error) {
} }
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 {
return "", false, 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, nil return subdir, false, nil
} }
......
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