Skip to content

Commit

Permalink
misc/ios: evaluate symlinks before comparing GOROOT and GOPATH
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
eliasnaur committed Mar 1, 2019
1 parent d96b7fb commit aafa855
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions misc/ios/go_darwin_arm_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,19 +633,27 @@ 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
}
return subdir, true, nil
}

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
}
Expand Down

0 comments on commit aafa855

Please sign in to comment.