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
, Expression
, GHC
, Oracles
, Oracles.AbsoluteCommand
, Oracles.ArgsHash
, Oracles.Config
, Oracles.Config.Flag
, Oracles.Config.Setting
, Oracles.Dependencies
, Oracles.LookupInPath
, Oracles.ModuleFiles
, Oracles.PackageData
, Oracles.PackageDeps
......
......@@ -98,7 +98,7 @@ builderPath builder = do
case (path, windows) of
("", _) -> return path
(p, True) -> fixAbsolutePathOnWindows (p -<.> exe)
(p, False) -> lookupInPathOracle (p -<.> exe)
(p, False) -> lookupInPath (p -<.> exe)
getBuilderPath :: Builder -> ReaderT a Action FilePath
getBuilderPath = lift . builderPath
......
module Oracles (
module Oracles.AbsoluteCommand,
module Oracles.Config,
module Oracles.Config.Flag,
module Oracles.Config.Setting,
module Oracles.Dependencies,
module Oracles.LookupInPath,
module Oracles.PackageData,
module Oracles.PackageDeps,
module Oracles.WindowsRoot
) where
import Oracles.AbsoluteCommand
import Oracles.Config
import Oracles.Config.Flag
import Oracles.Config.Setting
import Oracles.Dependencies
import Oracles.LookupInPath
import Oracles.PackageData
import Oracles.PackageDeps
import Oracles.WindowsRoot
{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
module Oracles.AbsoluteCommand (
lookupInPathOracle, absoluteCommandOracle
module Oracles.LookupInPath (
lookupInPath, lookupInPathOracle
) where
import Base
newtype AbsoluteCommand = AbsoluteCommand String
newtype LookupInPath = LookupInPath String
deriving (Show, Typeable, Eq, Hashable, Binary, NFData)
-- | Fetches the absolute FilePath to a given FilePath from the
-- Oracle.
absoluteCommand :: FilePath -> Action FilePath
absoluteCommand = askOracle . AbsoluteCommand
commandPath :: FilePath -> Action FilePath
commandPath = askOracle . LookupInPath
-- | Lookup a @command@ in @PATH@ environment.
lookupInPathOracle :: FilePath -> Action FilePath
lookupInPathOracle c
lookupInPath :: FilePath -> Action FilePath
lookupInPath c
| c /= takeFileName c = return c
| otherwise = absoluteCommand c
| otherwise = commandPath c
absoluteCommandOracle :: Rules ()
absoluteCommandOracle = do
lookupInPathOracle :: Rules ()
lookupInPathOracle = do
o <- newCache $ \c -> do
envPaths <- wordsWhen (== ':') <$> getEnvWithDefault "" "PATH"
let candidates = map (-/- c) envPaths
......@@ -28,5 +28,5 @@ absoluteCommandOracle = do
fullCommand <- head <$> filterM doesFileExist candidates
putOracle $ "Found '" ++ c ++ "' at " ++ "'" ++ fullCommand ++ "'"
return fullCommand
_ <- addOracle $ \(AbsoluteCommand c) -> o c
_ <- addOracle $ \(LookupInPath c) -> o c
return ()
......@@ -7,10 +7,10 @@ import Oracles.ModuleFiles
oracleRules :: Rules ()
oracleRules = do
absoluteCommandOracle -- see Oracles.WindowsRoot
argsHashOracle -- see Oracles.ArgsHash
configOracle -- see Oracles.Config
dependenciesOracle -- see Oracles.Dependencies
lookupInPathOracle -- see Oracles.LookupInPath
moduleFilesOracle -- see Oracles.ModuleFiles
packageDataOracle -- see Oracles.PackageData
packageDepsOracle -- see Oracles.PackageDeps
......
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