diff --git a/CHANGES.md b/CHANGES.md index 0bfa2d5..e3c9cf3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Change Log / Release Notes +## 0.13 + + * Re-builds using script `/build` if it exists and is executable + ## 0.12 (December 14, 2015) * Compiles with GHC 7.10.2, 7.8.4, and 7.6.3 diff --git a/src/XMonad/Core.hs b/src/XMonad/Core.hs index 6b99afc..a6387fd 100644 --- a/src/XMonad/Core.hs +++ b/src/XMonad/Core.hs @@ -463,16 +463,27 @@ recompile force = io $ do err = base ++ ".errors" src = base ++ ".hs" lib = dir "lib" + buildscript = dir "build" libTs <- mapM getModTime . Prelude.filter isSource =<< allFiles lib + useBuildscript <- do + exists <- doesFileExist buildscript + if exists + then executable <$> getPermissions buildscript + else return False srcT <- getModTime src binT <- getModTime bin - if force || any (binT <) (srcT : libTs) + buildScriptT <- getModTime buildscript + let addBuildScriptT = if useBuildscript + then (buildScriptT :) + else id + if force || any (binT <) ( addBuildScriptT $ srcT : libTs) then do -- temporarily disable SIGCHLD ignoring: uninstallSignalHandlers - status <- bracket (openFile err WriteMode) hClose $ \h -> - waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-main-is", "main", "-v0", "-o",binn] (Just dir) - Nothing Nothing Nothing (Just h) + status <- bracket (openFile err WriteMode) hClose $ \errHandle -> + waitForProcess =<< if useBuildscript + then compileScript binn dir buildscript errHandle + else compileGHC binn dir errHandle -- re-enable SIGCHLD: installSignalHandlers @@ -504,6 +515,18 @@ recompile force = io $ do '\8216' -> '`' -- ‘ '\8217' -> '`' -- ’ _ -> c + compileGHC binn dir errHandle = + runProcess "ghc" ["--make" + , "xmonad.hs" + , "-i" + , "-ilib" + , "-fforce-recomp" + , "-main-is", "main" + , "-v0" + , "-o", binn + ] (Just dir) Nothing Nothing Nothing (Just errHandle) + compileScript binn dir script errHandle = + runProcess script [binn] (Just dir) Nothing Nothing Nothing (Just errHandle) -- | Conditionally run an action, using a @Maybe a@ to decide. whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()