WindowsRoot.hs 811 Bytes
Newer Older
1
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
Andrey Mokhov's avatar
Andrey Mokhov committed
2
module Oracles.WindowsRoot (windowsRoot, windowsRootOracle) where
3

4
import Base
5
6
7
8
9
10
11
12
13
14
15
16

newtype WindowsRoot = WindowsRoot ()
    deriving (Show, Typeable, Eq, Hashable, Binary, NFData)

-- Looks up cygwin/msys root on Windows
windowsRoot :: Action String
windowsRoot = askOracle $ WindowsRoot ()

-- Oracle for windowsRoot. This operation requires caching as looking up
-- the root is slow (at least the current implementation).
windowsRootOracle :: Rules ()
windowsRootOracle = do
Andrey Mokhov's avatar
Andrey Mokhov committed
17
    root <- newCache $ \_ -> do
18
19
20
21
        Stdout out <- quietly $ cmd ["cygpath", "-m", "/"]
        let root = dropWhileEnd isSpace out
        putOracle $ "Detected root on Windows: " ++ root
        return root
Andrey Mokhov's avatar
Andrey Mokhov committed
22
    _ <- addOracle $ \WindowsRoot{} -> root ()
23
    return ()