Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
Fix absolute paths starting with /c/ on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
snowleopard committed Dec 20, 2015
1 parent 361c3c2 commit 30d3d63
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 30d3d63

Please sign in to comment.