summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-11-20 23:36:14 +0100
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-11-20 23:36:14 +0100
commit90abd90b12837cbecd334951a19817f5e3ea56d0 (patch)
tree8e14284ceb38b074f0d802d769ff3360924d231c
parent3f8427e54cb8180b998a9adb1b324556f45139e8 (diff)
downloadmetatile-90abd90b12837cbecd334951a19817f5e3ea56d0.tar
metatile-90abd90b12837cbecd334951a19817f5e3ea56d0.zip
Add recompilation forcing, clean up recompile's documentation
darcs-hash:20071120223614-a5988-6be0c47c1db902258f892e98a04a0de58767b44d
-rw-r--r--Main.hs2
-rw-r--r--XMonad/Core.hs22
2 files changed, 13 insertions, 11 deletions
diff --git a/Main.hs b/Main.hs
index ae31117..76df27d 100644
--- a/Main.hs
+++ b/Main.hs
@@ -43,7 +43,7 @@ main = do
--
buildLaunch :: IO ()
buildLaunch = do
- recompile
+ recompile False
dir <- fmap (++ "/.xmonad") getHomeDirectory
args <- getArgs
executeFile (dir ++ "/xmonad") False args Nothing
diff --git a/XMonad/Core.hs b/XMonad/Core.hs
index a606da2..819d484 100644
--- a/XMonad/Core.hs
+++ b/XMonad/Core.hs
@@ -313,25 +313,27 @@ restart mprog resume = do
catchIO (executeFile prog True args Nothing)
where showWs = show . mapLayout show
--- | Recompile ~\/xmonad\/xmonad.hs.
+-- | 'recompile force', recompile ~\/.xmonad\/xmonad.hs when any of the
+-- following apply:
+-- * force is True
+-- * the xmonad executable does not exist
+-- * the xmonad executable is older than xmonad.hs
--
--- The -i flag is used to restrict recompilation to the xmonad.hs file.
+-- The -i flag is used to restrict recompilation to the xmonad.hs file only.
--
--- The file is only recompiled if it is newer than its binary.
+-- Compilation errors (if any) are logged to ~\/.xmonad\/xmonad.errors. If
+-- GHC indicates failure with a non-zero exit code, an xmessage containing
+-- GHC's is spawned.
--
--- In the event of an error, signalled with GHC returning non-zero exit
--- status, any stderr produced by GHC, written to the file xmonad.errors,
--- will be displayed to the user with xmessage
---
-recompile :: MonadIO m => m ()
-recompile = liftIO $ do
+recompile :: MonadIO m => Bool -> m ()
+recompile force = liftIO $ do
dir <- (++ "/.xmonad") <$> getHomeDirectory
let bin = dir ++ "/" ++ "xmonad"
err = bin ++ ".errors"
src = bin ++ ".hs"
srcT <- getModTime src
binT <- getModTime bin
- when (srcT > binT) $ do
+ when (force || srcT > binT) $ do
status <- bracket (openFile err WriteMode) hClose $ \h -> do
waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-no-recomp", "-v0"] (Just dir)
Nothing Nothing Nothing (Just h)