Skip to content

Commit aafa855

Browse files
committed
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>
1 parent d96b7fb commit aafa855

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

misc/ios/go_darwin_arm_exec.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,19 +633,27 @@ func subdir() (pkgpath string, underGoRoot bool, err error) {
633633
if err != nil {
634634
return "", false, err
635635
}
636-
if root := runtime.GOROOT(); strings.HasPrefix(cwd, root) {
637-
subdir, err := filepath.Rel(root, cwd)
636+
goroot, err := filepath.EvalSymlinks(runtime.GOROOT())
637+
if err != nil {
638+
return "", false, err
639+
}
640+
if strings.HasPrefix(cwd, goroot) {
641+
subdir, err := filepath.Rel(goroot, cwd)
638642
if err != nil {
639643
return "", false, err
640644
}
641645
return subdir, true, nil
642646
}
643647

644648
for _, p := range filepath.SplitList(build.Default.GOPATH) {
645-
if !strings.HasPrefix(cwd, p) {
649+
pabs, err := filepath.EvalSymlinks(p)
650+
if err != nil {
651+
return "", false, err
652+
}
653+
if !strings.HasPrefix(cwd, pabs) {
646654
continue
647655
}
648-
subdir, err := filepath.Rel(p, cwd)
656+
subdir, err := filepath.Rel(pabs, cwd)
649657
if err == nil {
650658
return subdir, false, nil
651659
}

0 commit comments

Comments
 (0)