aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorAdam Vogt <vogt.adam@gmail.com>2009-03-22 00:29:07 +0100
committerAdam Vogt <vogt.adam@gmail.com>2009-03-22 00:29:07 +0100
commit9b9f065f0a38b1fbe2467b669a79fe4c274d9a30 (patch)
tree92c068528b2a95cc70d9e852f5e2efb44e5f5384 /XMonad
parent806dec564e2b55b91df1c963e56ad3937b5b87f8 (diff)
downloadxmonad-9b9f065f0a38b1fbe2467b669a79fe4c274d9a30.tar.gz
xmonad-9b9f065f0a38b1fbe2467b669a79fe4c274d9a30.tar.xz
xmonad-9b9f065f0a38b1fbe2467b669a79fe4c274d9a30.zip
Add lib to ghc searchpath with recompilation check
Ignore-this: 8827fb02fe1101d7b66f05d363bef038 darcs-hash:20090321232907-1499c-69dd8a1d22d2c8f28a6545ec20713d519dbc7ac4.gz
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Core.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/XMonad/Core.hs b/XMonad/Core.hs
index 7e17550..c5aeef8 100644
--- a/XMonad/Core.hs
+++ b/XMonad/Core.hs
@@ -37,6 +37,7 @@ import Control.Exception (catch, try, bracket, throw, finally, Exception(ExitExc
import Control.Applicative
import Control.Monad.State
import Control.Monad.Reader
+import System.FilePath
import System.IO
import System.Info
import System.Posix.Process (executeFile, forkProcess, getAnyProcessStatus, createSession)
@@ -49,6 +50,7 @@ import System.Exit
import Graphics.X11.Xlib
import Graphics.X11.Xlib.Extras (Event)
import Data.Typeable
+import Data.List ((\\))
import Data.Maybe (isJust)
import Data.Monoid
import Data.Maybe (fromMaybe)
@@ -405,18 +407,20 @@ recompile :: MonadIO m => Bool -> m Bool
recompile force = io $ do
dir <- getXMonadDir
let binn = "xmonad-"++arch++"-"++os
- bin = dir ++ "/" ++ binn
- base = dir ++ "/" ++ "xmonad"
+ bin = dir </> binn
+ base = dir </> "xmonad"
err = base ++ ".errors"
src = base ++ ".hs"
+ lib = dir </> "lib"
+ libTs <- mapM getModTime =<< allFiles lib
srcT <- getModTime src
binT <- getModTime bin
- if (force || srcT > binT)
+ if (force || srcT > binT || any (binT<) libTs)
then do
-- temporarily disable SIGCHLD ignoring:
uninstallSignalHandlers
status <- bracket (openFile err WriteMode) hClose $ \h -> do
- waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-fforce-recomp", "-v0", "-o",binn] (Just dir)
+ waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-v0", "-o",binn] (Just dir)
Nothing Nothing Nothing (Just h)
-- re-enable SIGCHLD:
@@ -436,6 +440,11 @@ recompile force = io $ do
return (status == ExitSuccess)
else return True
where getModTime f = catch (Just <$> getModificationTime f) (const $ return Nothing)
+ allFiles t = do
+ let prep = map (t</>) . Prelude.filter (`notElem` [".",".."])
+ cs <- prep <$> catch (getDirectoryContents t) (\_ -> return [])
+ ds <- filterM doesDirectoryExist cs
+ concat . ((cs \\ ds):) <$> mapM allFiles ds
-- | Conditionally run an action, using a @Maybe a@ to decide.
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()