mirror of
https://github.com/xmonad/xmonad.git
synced 2025-05-19 00:20:22 -07:00
The recompile function now returns a boolean status instead of ().
This commit is contained in:
parent
5e61b137fb
commit
9ff105340e
4
Main.hs
4
Main.hs
@ -31,8 +31,8 @@ main = do
|
|||||||
case args of
|
case args of
|
||||||
[] -> launch
|
[] -> launch
|
||||||
["--resume", _] -> launch
|
["--resume", _] -> launch
|
||||||
["--recompile"] -> recompile False
|
["--recompile"] -> recompile False >> return ()
|
||||||
["--recompile-force"] -> recompile True
|
["--recompile-force"] -> recompile True >> return ()
|
||||||
["--version"] -> putStrLn "xmonad 0.5"
|
["--version"] -> putStrLn "xmonad 0.5"
|
||||||
_ -> fail "unrecognized flags"
|
_ -> fail "unrecognized flags"
|
||||||
|
|
||||||
|
@ -348,7 +348,9 @@ getXMonadDir = io $ getAppUserDataDirectory "xmonad"
|
|||||||
-- GHC indicates failure with a non-zero exit code, an xmessage containing
|
-- GHC indicates failure with a non-zero exit code, an xmessage containing
|
||||||
-- GHC's is spawned.
|
-- GHC's is spawned.
|
||||||
--
|
--
|
||||||
recompile :: MonadIO m => Bool -> m ()
|
-- False is returned if there is compilation errors.
|
||||||
|
--
|
||||||
|
recompile :: MonadIO m => Bool -> m Bool
|
||||||
recompile force = io $ do
|
recompile force = io $ do
|
||||||
dir <- getXMonadDir
|
dir <- getXMonadDir
|
||||||
let binn = "xmonad-"++arch++"-"++os
|
let binn = "xmonad-"++arch++"-"++os
|
||||||
@ -358,7 +360,8 @@ recompile force = io $ do
|
|||||||
src = base ++ ".hs"
|
src = base ++ ".hs"
|
||||||
srcT <- getModTime src
|
srcT <- getModTime src
|
||||||
binT <- getModTime bin
|
binT <- getModTime bin
|
||||||
when (force || srcT > binT) $ do
|
if (force || srcT > binT)
|
||||||
|
then do
|
||||||
status <- bracket (openFile err WriteMode) hClose $ \h -> do
|
status <- bracket (openFile err WriteMode) hClose $ \h -> do
|
||||||
waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-no-recomp", "-v0", "-o",binn] (Just dir)
|
waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-no-recomp", "-v0", "-o",binn] (Just dir)
|
||||||
Nothing Nothing Nothing (Just h)
|
Nothing Nothing Nothing (Just h)
|
||||||
@ -370,6 +373,8 @@ recompile force = io $ do
|
|||||||
["Error detected while loading xmonad configuration file: " ++ src]
|
["Error detected while loading xmonad configuration file: " ++ src]
|
||||||
++ lines ghcErr ++ ["","Please check the file for errors."]
|
++ lines ghcErr ++ ["","Please check the file for errors."]
|
||||||
doubleFork $ executeFile "xmessage" True [msg] Nothing
|
doubleFork $ executeFile "xmessage" True [msg] Nothing
|
||||||
|
return (status == ExitSuccess)
|
||||||
|
else return True
|
||||||
where getModTime f = catch (Just <$> getModificationTime f) (const $ return Nothing)
|
where getModTime f = catch (Just <$> getModificationTime f) (const $ return Nothing)
|
||||||
|
|
||||||
-- | Run a side effecting action with the current workspace. Like 'when' but
|
-- | Run a side effecting action with the current workspace. Like 'when' but
|
||||||
|
Loading…
x
Reference in New Issue
Block a user