mirror of
https://github.com/xmonad/xmonad.git
synced 2025-05-19 08:30:21 -07:00
Do our own recompilation checking: only launch ghc if the xmonad.hs is newer than its .o file
This commit is contained in:
parent
4bb6371155
commit
45eea722be
2
Main.hs
2
Main.hs
@ -44,7 +44,7 @@ main = do
|
|||||||
buildLaunch :: IO ()
|
buildLaunch :: IO ()
|
||||||
buildLaunch = do
|
buildLaunch = do
|
||||||
recompile
|
recompile
|
||||||
dir <- fmap (++ "/.xmonad") getHomeDirectory
|
dir <- fmap (++ "/.xmonad") getHomeDirectory
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
executeFile (dir ++ "/xmonad") False args Nothing
|
executeFile (dir ++ "/xmonad") False args Nothing
|
||||||
return ()
|
return ()
|
||||||
|
@ -294,14 +294,22 @@ restart mprog resume = do
|
|||||||
|
|
||||||
-- | Recompile ~\/xmonad\/xmonad.hs.
|
-- | 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 :: IO ()
|
||||||
recompile = do
|
recompile = do
|
||||||
dir <- fmap (++ "/.xmonad") getHomeDirectory
|
dir <- liftM (++ "/.xmonad") getHomeDirectory
|
||||||
pid <- runProcess "ghc" ["--make", "xmonad.hs", "-i"] (Just dir)
|
let src = dir ++ "/" ++ "xmonad.hs"
|
||||||
Nothing Nothing Nothing Nothing
|
obj = dir ++ "/" ++ "xmonad.o"
|
||||||
waitForProcess pid
|
yes <- doesFileExist src
|
||||||
return ()
|
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
|
-- | Run a side effecting action with the current workspace. Like 'when' but
|
||||||
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
|
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user