diff options
author | Elias Naur <mail@eliasnaur.com> | 2019-03-01 01:15:24 +0100 |
---|---|---|
committer | Elias Naur <mail@eliasnaur.com> | 2019-03-01 00:54:35 +0000 |
commit | aafa855fd3f50f8d5c69a9f0e1ff06c50cfdcd64 (patch) | |
tree | 543272bdf4f5d230edce1588b065f68aac1d19ef /misc/ios | |
parent | d96b7fbf98bfac4861cda1b5c17a002ce8d62aa5 (diff) | |
download | go-aafa855fd3f50f8d5c69a9f0e1ff06c50cfdcd64.tar.gz go-aafa855fd3f50f8d5c69a9f0e1ff06c50cfdcd64.zip |
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/164698
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Diffstat (limited to 'misc/ios')
-rw-r--r-- | misc/ios/go_darwin_arm_exec.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/misc/ios/go_darwin_arm_exec.go b/misc/ios/go_darwin_arm_exec.go index d1bf9fd150..3eb1757e8f 100644 --- a/misc/ios/go_darwin_arm_exec.go +++ b/misc/ios/go_darwin_arm_exec.go @@ -633,8 +633,12 @@ func subdir() (pkgpath string, underGoRoot bool, err error) { if err != nil { return "", false, err } - if root := runtime.GOROOT(); strings.HasPrefix(cwd, root) { - subdir, err := filepath.Rel(root, cwd) + goroot, err := filepath.EvalSymlinks(runtime.GOROOT()) + if err != nil { + return "", false, err + } + if strings.HasPrefix(cwd, goroot) { + subdir, err := filepath.Rel(goroot, cwd) if err != nil { return "", false, err } @@ -642,10 +646,14 @@ func subdir() (pkgpath string, underGoRoot bool, err error) { } 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 } - subdir, err := filepath.Rel(p, cwd) + subdir, err := filepath.Rel(pabs, cwd) if err == nil { return subdir, false, nil } |