import path fall back.
This commit is contained in:
parent
15c3d74f6d
commit
a07ce7edcc
7
Cabal.hs
7
Cabal.hs
@ -17,12 +17,15 @@ import Types
|
|||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
||||||
|
importDirs :: [String]
|
||||||
|
importDirs = ["..","../..","../../..","../../../..","../../../../.."]
|
||||||
|
|
||||||
initializeGHC :: Options -> FilePath -> [String] -> Bool -> Ghc (FilePath,LogReader)
|
initializeGHC :: Options -> FilePath -> [String] -> Bool -> Ghc (FilePath,LogReader)
|
||||||
initializeGHC opt fileName ghcOptions logging = do
|
initializeGHC opt fileName ghcOptions logging = do
|
||||||
(owdir,mdirfile) <- liftIO getDirs
|
(owdir,mdirfile) <- liftIO getDirs
|
||||||
case mdirfile of
|
case mdirfile of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
logReader <- initSession opt ghcOptions Nothing logging
|
logReader <- initSession opt ghcOptions importDirs logging
|
||||||
return (fileName,logReader)
|
return (fileName,logReader)
|
||||||
Just (cdir,cfile) -> do
|
Just (cdir,cfile) -> do
|
||||||
midirs <- parseCabalFile cfile
|
midirs <- parseCabalFile cfile
|
||||||
@ -31,7 +34,7 @@ initializeGHC opt fileName ghcOptions logging = do
|
|||||||
Nothing -> [cdir,owdir]
|
Nothing -> [cdir,owdir]
|
||||||
Just dirs -> dirs ++ [owdir]
|
Just dirs -> dirs ++ [owdir]
|
||||||
file = ajustFileName fileName owdir cdir
|
file = ajustFileName fileName owdir cdir
|
||||||
logReader <- initSession opt ghcOptions (Just idirs) logging
|
logReader <- initSession opt ghcOptions idirs logging
|
||||||
return (file,logReader)
|
return (file,logReader)
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
11
Types.hs
11
Types.hs
@ -31,22 +31,23 @@ initSession0 :: Options -> Ghc [PackageId]
|
|||||||
initSession0 opt = getSessionDynFlags >>=
|
initSession0 opt = getSessionDynFlags >>=
|
||||||
setSessionDynFlags . setPackageConfFlags opt
|
setSessionDynFlags . setPackageConfFlags opt
|
||||||
|
|
||||||
initSession :: Options -> [String] -> Maybe [FilePath] -> Bool -> Ghc LogReader
|
initSession :: Options -> [String] -> [FilePath] -> Bool -> Ghc LogReader
|
||||||
initSession opt cmdOpts midirs logging = do
|
initSession opt cmdOpts idirs logging = do
|
||||||
dflags <- getSessionDynFlags
|
dflags <- getSessionDynFlags
|
||||||
let opts = map noLoc cmdOpts
|
let opts = map noLoc cmdOpts
|
||||||
(dflags',_,_) <- parseDynamicFlags dflags opts
|
(dflags',_,_) <- parseDynamicFlags dflags opts
|
||||||
(dflags'',readLog) <- liftIO . setLogger logging . setPackageConfFlags opt . setFlags dflags' $ midirs
|
(dflags'',readLog) <- liftIO . setLogger logging . setPackageConfFlags opt . setFlags dflags' $ idirs
|
||||||
setSessionDynFlags dflags''
|
setSessionDynFlags dflags''
|
||||||
return readLog
|
return readLog
|
||||||
|
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|
||||||
setFlags :: DynFlags -> Maybe [FilePath] -> DynFlags
|
setFlags :: DynFlags -> [FilePath] -> DynFlags
|
||||||
setFlags d midirs = maybe d' (\x -> d' { importPaths = x }) midirs
|
setFlags d idirs = d'
|
||||||
where
|
where
|
||||||
d' = d {
|
d' = d {
|
||||||
packageFlags = ghcPackage : packageFlags d
|
packageFlags = ghcPackage : packageFlags d
|
||||||
|
, importPaths = idirs
|
||||||
, ghcLink = NoLink
|
, ghcLink = NoLink
|
||||||
, hscTarget = HscInterpreted
|
, hscTarget = HscInterpreted
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user