diff options
author | Adam Vogt <vogt.adam@gmail.com> | 2009-03-22 00:29:07 +0100 |
---|---|---|
committer | Adam Vogt <vogt.adam@gmail.com> | 2009-03-22 00:29:07 +0100 |
commit | 23e4bc1ccd51373c43ea0a2a9643f01cebe0a395 (patch) | |
tree | 92c068528b2a95cc70d9e852f5e2efb44e5f5384 /XMonad | |
parent | 9ad0dcb6014ef075698a8306d86322732ced476a (diff) | |
download | metatile-23e4bc1ccd51373c43ea0a2a9643f01cebe0a395.tar metatile-23e4bc1ccd51373c43ea0a2a9643f01cebe0a395.zip |
Add lib to ghc searchpath with recompilation check
Ignore-this: 8827fb02fe1101d7b66f05d363bef038
darcs-hash:20090321232907-1499c-69dd8a1d22d2c8f28a6545ec20713d519dbc7ac4
Diffstat (limited to 'XMonad')
-rw-r--r-- | XMonad/Core.hs | 17 |
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 () |