prepareAutogen skips its work if a cabal file does not exist.
This commit is contained in:
parent
9ed4aa8fdf
commit
1545f05d87
@ -28,6 +28,7 @@ import Data.List (intercalate)
|
|||||||
import Data.List.Split (splitOn)
|
import Data.List.Split (splitOn)
|
||||||
import Data.Version (showVersion)
|
import Data.Version (showVersion)
|
||||||
import Language.Haskell.GhcMod
|
import Language.Haskell.GhcMod
|
||||||
|
import Language.Haskell.GhcMod.Internal (cradle)
|
||||||
import Paths_ghc_mod
|
import Paths_ghc_mod
|
||||||
import System.Console.GetOpt
|
import System.Console.GetOpt
|
||||||
import System.Directory (setCurrentDirectory)
|
import System.Directory (setCurrentDirectory)
|
||||||
@ -87,7 +88,7 @@ run opt ref = flip E.catches handlers $ do
|
|||||||
let rootdir = cradleRootDir cradle0
|
let rootdir = cradleRootDir cradle0
|
||||||
-- c = cradle0 { cradleCurrentDir = rootdir } TODO: ?????
|
-- c = cradle0 { cradleCurrentDir = rootdir } TODO: ?????
|
||||||
setCurrentDirectory rootdir
|
setCurrentDirectory rootdir
|
||||||
prepareAutogen
|
prepareAutogen cradle0
|
||||||
-- Asynchronous db loading starts here.
|
-- Asynchronous db loading starts here.
|
||||||
symdbreq <- newSymDbReq opt
|
symdbreq <- newSymDbReq opt
|
||||||
(res, _) <- runGhcModT opt $ getCurrentWorld >>= loop symdbreq ref
|
(res, _) <- runGhcModT opt $ getCurrentWorld >>= loop symdbreq ref
|
||||||
@ -129,7 +130,7 @@ loop symdbreq ref world = do
|
|||||||
when changed $ do
|
when changed $ do
|
||||||
liftIO $ ungetCommand ref cmdArg
|
liftIO $ ungetCommand ref cmdArg
|
||||||
E.throw Restart
|
E.throw Restart
|
||||||
liftIO $ prepareAutogen
|
cradle >>= liftIO . prepareAutogen
|
||||||
let (cmd,arg') = break (== ' ') cmdArg
|
let (cmd,arg') = break (== ' ') cmdArg
|
||||||
arg = dropWhile (== ' ') arg'
|
arg = dropWhile (== ' ') arg'
|
||||||
(ret,ok) <- case cmd of
|
(ret,ok) <- case cmd of
|
||||||
|
@ -21,15 +21,16 @@ import Control.Applicative ((<$>))
|
|||||||
import Control.Concurrent (threadDelay)
|
import Control.Concurrent (threadDelay)
|
||||||
import Control.Concurrent.Async (Async, async, wait)
|
import Control.Concurrent.Async (Async, async, wait)
|
||||||
import Control.Exception (Exception)
|
import Control.Exception (Exception)
|
||||||
import Control.Monad (unless)
|
import Control.Monad (unless, when)
|
||||||
import CoreMonad (liftIO)
|
import CoreMonad (liftIO)
|
||||||
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
|
import Data.IORef (IORef, newIORef, readIORef, writeIORef)
|
||||||
import Data.List (isPrefixOf)
|
import Data.List (isPrefixOf)
|
||||||
|
import Data.Maybe (isJust)
|
||||||
import Data.Time (UTCTime)
|
import Data.Time (UTCTime)
|
||||||
import Data.Typeable (Typeable)
|
import Data.Typeable (Typeable)
|
||||||
import System.Directory (getModificationTime, doesDirectoryExist, getDirectoryContents)
|
import System.Directory (getModificationTime, doesDirectoryExist, getDirectoryContents)
|
||||||
import System.Process
|
|
||||||
import System.IO (openBinaryFile, IOMode(..))
|
import System.IO (openBinaryFile, IOMode(..))
|
||||||
|
import System.Process
|
||||||
|
|
||||||
import Language.Haskell.GhcMod
|
import Language.Haskell.GhcMod
|
||||||
import Language.Haskell.GhcMod.Internal
|
import Language.Haskell.GhcMod.Internal
|
||||||
@ -168,8 +169,8 @@ watch n hdl = do
|
|||||||
threadDelay 100000
|
threadDelay 100000
|
||||||
watch (n - 1) hdl
|
watch (n - 1) hdl
|
||||||
|
|
||||||
prepareAutogen :: IO ()
|
prepareAutogen :: Cradle -> IO ()
|
||||||
prepareAutogen = do
|
prepareAutogen crdl = when (isJust $ cradleCabalFile crdl) $ do
|
||||||
prepared <- isAutogenPrepared
|
prepared <- isAutogenPrepared
|
||||||
unless prepared $ do
|
unless prepared $ do
|
||||||
hdl <- build
|
hdl <- build
|
||||||
|
Loading…
Reference in New Issue
Block a user