force reconfigure when cabal file changes
This commit is contained in:
parent
169340c126
commit
b9eb79068c
@ -112,37 +112,34 @@ devel opts passThroughArgs = withManager $ \manager -> do
|
|||||||
|
|
||||||
putStrLn "Yesod devel server. Press ENTER to quit"
|
putStrLn "Yesod devel server. Press ENTER to quit"
|
||||||
_ <- forkIO $ do
|
_ <- forkIO $ do
|
||||||
cabal <- D.findPackageDesc "."
|
|
||||||
gpd <- D.readPackageDescription D.normal cabal
|
|
||||||
|
|
||||||
ldar <- lookupLdAr
|
|
||||||
(hsSourceDirs, lib) <- checkCabalFile gpd
|
|
||||||
|
|
||||||
removeFileIfExists (bd </> "setup-config")
|
|
||||||
configure cabal gpd opts
|
|
||||||
removeFileIfExists "yesod-devel/ghcargs.txt" -- these files contain the wrong data after
|
|
||||||
removeFileIfExists "yesod-devel/arargs.txt" -- the configure step, remove them to force
|
|
||||||
removeFileIfExists "yesod-devel/ldargs.txt" -- a cabal build first
|
|
||||||
filesModified <- newEmptyMVar
|
filesModified <- newEmptyMVar
|
||||||
watchTree manager "." (const True) (\_ -> void (tryPutMVar filesModified ()))
|
watchTree manager "." (const True) (\_ -> void (tryPutMVar filesModified ()))
|
||||||
mainLoop hsSourceDirs filesModified cabal gpd lib ldar
|
mainOuterLoop filesModified
|
||||||
|
|
||||||
_ <- getLine
|
_ <- getLine
|
||||||
writeLock opts
|
writeLock opts
|
||||||
exitSuccess
|
exitSuccess
|
||||||
where
|
where
|
||||||
bd = getBuildDir opts
|
bd = getBuildDir opts
|
||||||
mainLoop :: [FilePath]
|
|
||||||
-> MVar ()
|
-- outer loop re-reads the cabal file
|
||||||
-> FilePath
|
mainOuterLoop filesModified = do
|
||||||
-> D.GenericPackageDescription
|
cabal <- D.findPackageDesc "."
|
||||||
-> D.Library
|
gpd <- D.readPackageDescription D.normal cabal
|
||||||
-> (FilePath, FilePath)
|
ldar <- lookupLdAr
|
||||||
-> IO ()
|
(hsSourceDirs, lib) <- checkCabalFile gpd
|
||||||
mainLoop hsSourceDirs filesModified cabal gpd lib ldar = do
|
removeFileIfExists (bd </> "setup-config")
|
||||||
ghcVer <- ghcVersion
|
configure cabal gpd opts
|
||||||
rebuild <- mkRebuild gpd ghcVer cabal opts ldar
|
removeFileIfExists "yesod-devel/ghcargs.txt" -- these files contain the wrong data after
|
||||||
forever $ do
|
removeFileIfExists "yesod-devel/arargs.txt" -- the configure step, remove them to force
|
||||||
|
removeFileIfExists "yesod-devel/ldargs.txt" -- a cabal build first
|
||||||
|
ghcVer <- ghcVersion
|
||||||
|
rebuild <- mkRebuild gpd ghcVer cabal opts ldar
|
||||||
|
mainInnerLoop hsSourceDirs filesModified cabal gpd lib ghcVer rebuild
|
||||||
|
|
||||||
|
-- inner loop rebuilds after files change
|
||||||
|
mainInnerLoop hsSourceDirs filesModified cabal gpd lib ghcVer rebuild = go
|
||||||
|
where
|
||||||
|
go = do
|
||||||
recompDeps hsSourceDirs
|
recompDeps hsSourceDirs
|
||||||
list <- getFileList hsSourceDirs [cabal]
|
list <- getFileList hsSourceDirs [cabal]
|
||||||
success <- rebuild
|
success <- rebuild
|
||||||
@ -169,6 +166,8 @@ devel opts passThroughArgs = withManager $ \manager -> do
|
|||||||
putStrLn $ "Exit code: " ++ show ec
|
putStrLn $ "Exit code: " ++ show ec
|
||||||
Ex.throwTo watchTid (userError "process finished")
|
Ex.throwTo watchTid (userError "process finished")
|
||||||
watchForChanges filesModified hsSourceDirs [cabal] list (eventTimeout opts)
|
watchForChanges filesModified hsSourceDirs [cabal] list (eventTimeout opts)
|
||||||
|
n <- cabal `isNewerThan` (bd </> "setup-config")
|
||||||
|
if n then mainOuterLoop filesModified else go
|
||||||
|
|
||||||
runBuildHook :: Maybe String -> IO ()
|
runBuildHook :: Maybe String -> IO ()
|
||||||
runBuildHook (Just s) = do
|
runBuildHook (Just s) = do
|
||||||
|
|||||||
@ -76,7 +76,6 @@ main = do
|
|||||||
, ("yesod.devel.ignore" , optCommand . develIgnore)
|
, ("yesod.devel.ignore" , optCommand . develIgnore)
|
||||||
, ("yesod.build.extracabalarg" , optCommand . buildExtraArgs)
|
, ("yesod.build.extracabalarg" , optCommand . buildExtraArgs)
|
||||||
] optParser'
|
] optParser'
|
||||||
print o
|
|
||||||
let cabal xs = rawSystem' (cabalCommand o) xs
|
let cabal xs = rawSystem' (cabalCommand o) xs
|
||||||
case o^.optCommand of
|
case o^.optCommand of
|
||||||
Init -> scaffold
|
Init -> scaffold
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user