]> Cypherpunks repositories - gostls13.git/commitdiff
misc/ios: evaluate symlinks before comparing GOROOT and GOPATH
authorElias Naur <mail@eliasnaur.com>
Fri, 1 Mar 2019 00:15:24 +0000 (01:15 +0100)
committerElias Naur <mail@eliasnaur.com>
Fri, 1 Mar 2019 00:54:35 +0000 (00:54 +0000)
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>
misc/ios/go_darwin_arm_exec.go

index d1bf9fd150a5521904e9b1c54b920f579334e408..3eb1757e8f84a0cd50c82a3c17438497bf1d6786 100644 (file)
@@ -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
                }