[commit: ghc] wip/nfs-locking: Fix absolute paths starting with /c/ on Windows. (30d3d63)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:12:46 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/30d3d63bf7423e7da637981810dd62261868d7d2/ghc

>---------------------------------------------------------------

commit 30d3d63bf7423e7da637981810dd62261868d7d2
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Sun Dec 20 15:18:44 2015 +0000

    Fix absolute paths starting with /c/ on Windows.


>---------------------------------------------------------------

30d3d63bf7423e7da637981810dd62261868d7d2
 src/Builder.hs | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/Builder.hs b/src/Builder.hs
index 007dae3..f15054d 100644
--- a/src/Builder.hs
+++ b/src/Builder.hs
@@ -95,16 +95,22 @@ needBuilder laxDependencies builder = do
         GhcM _ -> True
         _      -> False
 
--- On Windows: if the path starts with "/", prepend it with the correct path to
--- the root, e.g: "/usr/local/bin/ghc.exe" => "C:/msys/usr/local/bin/ghc.exe".
+-- TODO: this is fragile, e.g. we currently only handle C: drive
+-- On Windows:
+-- * if the path starts with "/c/" change the prefix to "C:/"
+-- * otherwise, if the path starts with "/", prepend it with the correct path
+-- to the root, e.g: "/usr/local/bin/ghc.exe" => "C:/msys/usr/local/bin/ghc.exe"
 fixAbsolutePathOnWindows :: FilePath -> Action FilePath
 fixAbsolutePathOnWindows path = do
     windows <- windowsHost
     -- Note, below is different from FilePath.isAbsolute:
     if (windows && "/" `isPrefixOf` path)
     then do
-        root <- windowsRoot
-        return . unifyPath $ root ++ drop 1 path
+        if ("/c/" `isPrefixOf` path)
+        then return $ "C:" ++ drop 2 path
+        else do
+            root <- windowsRoot
+            return . unifyPath $ root ++ drop 1 path
     else
         return path
 



More information about the ghc-commits mailing list