module GHC.Driver.Config.Finder (
FinderOpts(..),
initFinderOpts
) where
import GHC.Prelude
import GHC.Driver.DynFlags
import GHC.Unit.Finder.Types
import GHC.Data.FastString
import GHC.Data.OsPath
import GHC.Types.Unique.Map
initFinderOpts :: DynFlags -> FinderOpts
initFinderOpts :: DynFlags -> FinderOpts
initFinderOpts DynFlags
flags = FinderOpts
{ finder_importPaths :: [OsPath]
finder_importPaths = (String -> OsPath) -> [String] -> [OsPath]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf ([String] -> [OsPath]) -> [String] -> [OsPath]
forall a b. (a -> b) -> a -> b
$ DynFlags -> [String]
importPaths DynFlags
flags
, finder_lookupHomeInterfaces :: Bool
finder_lookupHomeInterfaces = GhcMode -> Bool
isOneShot (DynFlags -> GhcMode
ghcMode DynFlags
flags)
, finder_bypassHiFileCheck :: Bool
finder_bypassHiFileCheck = GhcMode
MkDepend GhcMode -> GhcMode -> Bool
forall a. Eq a => a -> a -> Bool
== (DynFlags -> GhcMode
ghcMode DynFlags
flags)
, finder_ways :: Ways
finder_ways = DynFlags -> Ways
ways DynFlags
flags
, finder_enableSuggestions :: Bool
finder_enableSuggestions = GeneralFlag -> DynFlags -> Bool
gopt GeneralFlag
Opt_HelpfulErrors DynFlags
flags
, finder_workingDirectory :: Maybe OsPath
finder_workingDirectory = (String -> OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (Maybe String -> Maybe OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> Maybe String
workingDirectory DynFlags
flags
, finder_thisPackageName :: Maybe FastString
finder_thisPackageName = String -> FastString
mkFastString (String -> FastString) -> Maybe String -> Maybe FastString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DynFlags -> Maybe String
thisPackageName DynFlags
flags
, finder_hiddenModules :: UniqSet ModuleName
finder_hiddenModules = DynFlags -> UniqSet ModuleName
hiddenModules DynFlags
flags
, finder_reexportedModules :: UniqMap ModuleName ModuleName
finder_reexportedModules = [(ModuleName, ModuleName)] -> UniqMap ModuleName ModuleName
forall k a. Uniquable k => [(k, a)] -> UniqMap k a
listToUniqMap [(ModuleName
known_as, ModuleName
is_as) | ReexportedModule ModuleName
is_as ModuleName
known_as <- [ReexportedModule] -> [ReexportedModule]
forall a. [a] -> [a]
reverse (DynFlags -> [ReexportedModule]
reexportedModules DynFlags
flags)]
, finder_hieDir :: Maybe OsPath
finder_hieDir = (String -> OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (Maybe String -> Maybe OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> Maybe String
hieDir DynFlags
flags
, finder_hieSuf :: OsPath
finder_hieSuf = HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (String -> OsPath) -> String -> OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> String
hieSuf DynFlags
flags
, finder_hiDir :: Maybe OsPath
finder_hiDir = (String -> OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (Maybe String -> Maybe OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> Maybe String
hiDir DynFlags
flags
, finder_hiSuf :: OsPath
finder_hiSuf = HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (String -> OsPath) -> String -> OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> String
hiSuf_ DynFlags
flags
, finder_bytecodeDir :: Maybe OsPath
finder_bytecodeDir = (String -> OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (Maybe String -> Maybe OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> Maybe String
bytecodeDir DynFlags
flags
, finder_bytecodeSuf :: OsPath
finder_bytecodeSuf = HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (String -> OsPath) -> String -> OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> String
bytecodeSuf DynFlags
flags
, finder_dynHiSuf :: OsPath
finder_dynHiSuf = HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (String -> OsPath) -> String -> OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> String
dynHiSuf_ DynFlags
flags
, finder_objectDir :: Maybe OsPath
finder_objectDir = (String -> OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (Maybe String -> Maybe OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> Maybe String
objectDir DynFlags
flags
, finder_objectSuf :: OsPath
finder_objectSuf = HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (String -> OsPath) -> String -> OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> String
objectSuf_ DynFlags
flags
, finder_dynObjectSuf :: OsPath
finder_dynObjectSuf = HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (String -> OsPath) -> String -> OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> String
dynObjectSuf_ DynFlags
flags
, finder_stubDir :: Maybe OsPath
finder_stubDir = (String -> OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap HasCallStack => String -> OsPath
String -> OsPath
unsafeEncodeUtf (Maybe String -> Maybe OsPath) -> Maybe String -> Maybe OsPath
forall a b. (a -> b) -> a -> b
$ DynFlags -> Maybe String
stubDir DynFlags
flags
}