aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorDon Stewart <dons@galois.com>2007-11-19 02:07:59 +0100
committerDon Stewart <dons@galois.com>2007-11-19 02:07:59 +0100
commit9b54117ae59c5502b271b4fbdaf84549b64c0076 (patch)
tree180c380fbaad54670f57ea063e3a76bbbaec9816 /XMonad
parent63e38814727224c263b416ccb6230955eb51ef49 (diff)
downloadxmonad-9b54117ae59c5502b271b4fbdaf84549b64c0076.tar.gz
xmonad-9b54117ae59c5502b271b4fbdaf84549b64c0076.tar.xz
xmonad-9b54117ae59c5502b271b4fbdaf84549b64c0076.zip
Do our own recompilation checking: only launch ghc if the xmonad.hs is newer than its .o file
darcs-hash:20071119010759-cba2c-e9b94827122cb337ddcf93c3aefb62775011707a.gz
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Core.hs20
1 files changed, 14 insertions, 6 deletions
diff --git a/XMonad/Core.hs b/XMonad/Core.hs
index ee5320c..90bfd9a 100644
--- a/XMonad/Core.hs
+++ b/XMonad/Core.hs
@@ -294,14 +294,22 @@ restart mprog resume = do
-- | Recompile ~\/xmonad\/xmonad.hs.
--
--- Raises an exception if ghc can't be found.
+-- The -i flag is used to restrict recompilation to the xmonad.hs file.
+-- Raises an exception if GHC can't be found, or if anything else goes wrong.
+--
recompile :: IO ()
recompile = do
- dir <- fmap (++ "/.xmonad") getHomeDirectory
- pid <- runProcess "ghc" ["--make", "xmonad.hs", "-i"] (Just dir)
- Nothing Nothing Nothing Nothing
- waitForProcess pid
- return ()
+ dir <- liftM (++ "/.xmonad") getHomeDirectory
+ let src = dir ++ "/" ++ "xmonad.hs"
+ obj = dir ++ "/" ++ "xmonad.o"
+ yes <- doesFileExist src
+ when yes $ do
+ srcT <- getModificationTime src
+ objT <- getModificationTime obj
+ when (srcT > objT) $ do
+ waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i"] (Just dir)
+ Nothing Nothing Nothing Nothing
+ return ()
-- | Run a side effecting action with the current workspace. Like 'when' but
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()