[commit: ghc] wip/nfs-locking: Take 2 (a7da5e0)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:59:15 UTC 2017


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

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

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

commit a7da5e01637652109a75b05371b5e5864df8e836
Author: Moritz Angermann <moritz.angermann at gmail.com>
Date:   Thu Jan 7 11:06:37 2016 +0800

    Take 2


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

a7da5e01637652109a75b05371b5e5864df8e836
 shaking-up-ghc.cabal       |  1 +
 src/Oracles/WindowsRoot.hs | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/shaking-up-ghc.cabal b/shaking-up-ghc.cabal
index 00fb408..f9990e9 100644
--- a/shaking-up-ghc.cabal
+++ b/shaking-up-ghc.cabal
@@ -114,6 +114,7 @@ executable ghc-shake
                        , extra >= 1.4
                        , mtl >= 2.2
                        , shake >= 0.15
+                       , split >= 0.2
                        , transformers >= 0.4
                        , unordered-containers >= 0.2
     default-language:    Haskell2010
diff --git a/src/Oracles/WindowsRoot.hs b/src/Oracles/WindowsRoot.hs
index 195f591..473a235 100644
--- a/src/Oracles/WindowsRoot.hs
+++ b/src/Oracles/WindowsRoot.hs
@@ -4,6 +4,7 @@ module Oracles.WindowsRoot (
     ) where
 
 import Data.Char (isSpace)
+import Data.List.Split (splitOn)
 import Base
 import Oracles.Config.Setting
 
@@ -40,12 +41,13 @@ fixAbsolutePathOnWindows path = do
 
 -- | Lookup a @command@ in @PATH@ environment.
 lookupInPath :: FilePath -> Action FilePath
-lookupInPath command
-    | command /= takeFileName command = return command
+lookupInPath c
+    | c /= takeFileName c = return c
     | otherwise = do
-        Stdout out <- quietly $ cmd ["which", command]
-        let path = dropWhileEnd isSpace out
-        return path
+        envPaths <- splitOn ":" <$> getEnvWithDefault "" "PATH"
+        let candidates = map (-/- c) envPaths in
+            -- this will crash if we do not find any valid candidate.
+            head <$> filterM doesFileExist candidates
 
 -- Oracle for windowsRoot. This operation requires caching as looking up
 -- the root is slow (at least the current implementation).



More information about the ghc-commits mailing list