From b9eb79068c8b6ad63d92e09a90b1b4e8e073ae3b Mon Sep 17 00:00:00 2001 From: Luite Stegeman Date: Sun, 4 Nov 2012 00:44:38 +0100 Subject: [PATCH] force reconfigure when cabal file changes --- yesod/Devel.hs | 47 +++++++++++++++++++++++------------------------ yesod/main.hs | 1 - 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/yesod/Devel.hs b/yesod/Devel.hs index 8f6f4ac7..9a3e872c 100644 --- a/yesod/Devel.hs +++ b/yesod/Devel.hs @@ -112,37 +112,34 @@ devel opts passThroughArgs = withManager $ \manager -> do putStrLn "Yesod devel server. Press ENTER to quit" _ <- 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 watchTree manager "." (const True) (\_ -> void (tryPutMVar filesModified ())) - mainLoop hsSourceDirs filesModified cabal gpd lib ldar - + mainOuterLoop filesModified _ <- getLine writeLock opts exitSuccess where bd = getBuildDir opts - mainLoop :: [FilePath] - -> MVar () - -> FilePath - -> D.GenericPackageDescription - -> D.Library - -> (FilePath, FilePath) - -> IO () - mainLoop hsSourceDirs filesModified cabal gpd lib ldar = do - ghcVer <- ghcVersion - rebuild <- mkRebuild gpd ghcVer cabal opts ldar - forever $ do + + -- outer loop re-reads the cabal file + mainOuterLoop filesModified = 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 + 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 list <- getFileList hsSourceDirs [cabal] success <- rebuild @@ -169,6 +166,8 @@ devel opts passThroughArgs = withManager $ \manager -> do putStrLn $ "Exit code: " ++ show ec Ex.throwTo watchTid (userError "process finished") 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 (Just s) = do diff --git a/yesod/main.hs b/yesod/main.hs index c41d1e87..2e116d69 100755 --- a/yesod/main.hs +++ b/yesod/main.hs @@ -76,7 +76,6 @@ main = do , ("yesod.devel.ignore" , optCommand . develIgnore) , ("yesod.build.extracabalarg" , optCommand . buildExtraArgs) ] optParser' - print o let cabal xs = rawSystem' (cabalCommand o) xs case o^.optCommand of Init -> scaffold