Commit 6f88557b authored by Moritz Angermann's avatar Moritz Angermann
Browse files

Renames absoluteCommand to lookupInPath

parent 1d3de4cf
...@@ -22,12 +22,12 @@ executable ghc-shake ...@@ -22,12 +22,12 @@ executable ghc-shake
, Expression , Expression
, GHC , GHC
, Oracles , Oracles
, Oracles.AbsoluteCommand
, Oracles.ArgsHash , Oracles.ArgsHash
, Oracles.Config , Oracles.Config
, Oracles.Config.Flag , Oracles.Config.Flag
, Oracles.Config.Setting , Oracles.Config.Setting
, Oracles.Dependencies , Oracles.Dependencies
, Oracles.LookupInPath
, Oracles.ModuleFiles , Oracles.ModuleFiles
, Oracles.PackageData , Oracles.PackageData
, Oracles.PackageDeps , Oracles.PackageDeps
......
...@@ -98,7 +98,7 @@ builderPath builder = do ...@@ -98,7 +98,7 @@ builderPath builder = do
case (path, windows) of case (path, windows) of
("", _) -> return path ("", _) -> return path
(p, True) -> fixAbsolutePathOnWindows (p -<.> exe) (p, True) -> fixAbsolutePathOnWindows (p -<.> exe)
(p, False) -> lookupInPathOracle (p -<.> exe) (p, False) -> lookupInPath (p -<.> exe)
getBuilderPath :: Builder -> ReaderT a Action FilePath getBuilderPath :: Builder -> ReaderT a Action FilePath
getBuilderPath = lift . builderPath getBuilderPath = lift . builderPath
......
module Oracles ( module Oracles (
module Oracles.AbsoluteCommand,
module Oracles.Config, module Oracles.Config,
module Oracles.Config.Flag, module Oracles.Config.Flag,
module Oracles.Config.Setting, module Oracles.Config.Setting,
module Oracles.Dependencies, module Oracles.Dependencies,
module Oracles.LookupInPath,
module Oracles.PackageData, module Oracles.PackageData,
module Oracles.PackageDeps, module Oracles.PackageDeps,
module Oracles.WindowsRoot module Oracles.WindowsRoot
) where ) where
import Oracles.AbsoluteCommand
import Oracles.Config import Oracles.Config
import Oracles.Config.Flag import Oracles.Config.Flag
import Oracles.Config.Setting import Oracles.Config.Setting
import Oracles.Dependencies import Oracles.Dependencies
import Oracles.LookupInPath
import Oracles.PackageData import Oracles.PackageData
import Oracles.PackageDeps import Oracles.PackageDeps
import Oracles.WindowsRoot import Oracles.WindowsRoot
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-} {-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
module Oracles.AbsoluteCommand ( module Oracles.LookupInPath (
lookupInPathOracle, absoluteCommandOracle lookupInPath, lookupInPathOracle
) where ) where
import Base import Base
newtype AbsoluteCommand = AbsoluteCommand String newtype LookupInPath = LookupInPath String
deriving (Show, Typeable, Eq, Hashable, Binary, NFData) deriving (Show, Typeable, Eq, Hashable, Binary, NFData)
-- | Fetches the absolute FilePath to a given FilePath from the -- | Fetches the absolute FilePath to a given FilePath from the
-- Oracle. -- Oracle.
absoluteCommand :: FilePath -> Action FilePath commandPath :: FilePath -> Action FilePath
absoluteCommand = askOracle . AbsoluteCommand commandPath = askOracle . LookupInPath
-- | Lookup a @command@ in @PATH@ environment. -- | Lookup a @command@ in @PATH@ environment.
lookupInPathOracle :: FilePath -> Action FilePath lookupInPath :: FilePath -> Action FilePath
lookupInPathOracle c lookupInPath c
| c /= takeFileName c = return c | c /= takeFileName c = return c
| otherwise = absoluteCommand c | otherwise = commandPath c
absoluteCommandOracle :: Rules () lookupInPathOracle :: Rules ()
absoluteCommandOracle = do lookupInPathOracle = do
o <- newCache $ \c -> do o <- newCache $ \c -> do
envPaths <- wordsWhen (== ':') <$> getEnvWithDefault "" "PATH" envPaths <- wordsWhen (== ':') <$> getEnvWithDefault "" "PATH"
let candidates = map (-/- c) envPaths let candidates = map (-/- c) envPaths
...@@ -28,5 +28,5 @@ absoluteCommandOracle = do ...@@ -28,5 +28,5 @@ absoluteCommandOracle = do
fullCommand <- head <$> filterM doesFileExist candidates fullCommand <- head <$> filterM doesFileExist candidates
putOracle $ "Found '" ++ c ++ "' at " ++ "'" ++ fullCommand ++ "'" putOracle $ "Found '" ++ c ++ "' at " ++ "'" ++ fullCommand ++ "'"
return fullCommand return fullCommand
_ <- addOracle $ \(AbsoluteCommand c) -> o c _ <- addOracle $ \(LookupInPath c) -> o c
return () return ()
...@@ -7,11 +7,11 @@ import Oracles.ModuleFiles ...@@ -7,11 +7,11 @@ import Oracles.ModuleFiles
oracleRules :: Rules () oracleRules :: Rules ()
oracleRules = do oracleRules = do
absoluteCommandOracle -- see Oracles.WindowsRoot argsHashOracle -- see Oracles.ArgsHash
argsHashOracle -- see Oracles.ArgsHash configOracle -- see Oracles.Config
configOracle -- see Oracles.Config dependenciesOracle -- see Oracles.Dependencies
dependenciesOracle -- see Oracles.Dependencies lookupInPathOracle -- see Oracles.LookupInPath
moduleFilesOracle -- see Oracles.ModuleFiles moduleFilesOracle -- see Oracles.ModuleFiles
packageDataOracle -- see Oracles.PackageData packageDataOracle -- see Oracles.PackageData
packageDepsOracle -- see Oracles.PackageDeps packageDepsOracle -- see Oracles.PackageDeps
windowsRootOracle -- see Oracles.WindowsRoot windowsRootOracle -- see Oracles.WindowsRoot
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment