From 75d297a6335207fa75a2b3e19f9ca856e6908aca Mon Sep 17 00:00:00 2001 From: Philipp Balzarek Date: Thu, 20 Oct 2016 14:37:22 +0200 Subject: [PATCH 1/3] Add support for rebuild script (#46) --- src/XMonad/Core.hs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/XMonad/Core.hs b/src/XMonad/Core.hs index 6b99afc..8920031 100644 --- a/src/XMonad/Core.hs +++ b/src/XMonad/Core.hs @@ -463,16 +463,29 @@ 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 do + permissions <- getPermissions buildscript + return $ executable permissions + 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 +517,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 [dir, 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 () From b0f9a3d0b9e68e5252de41cc23920f911f60b960 Mon Sep 17 00:00:00 2001 From: Philipp Balzarek Date: Thu, 20 Oct 2016 19:33:44 +0200 Subject: [PATCH 2/3] clean up build-script handling --- src/XMonad/Core.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/XMonad/Core.hs b/src/XMonad/Core.hs index 8920031..a6387fd 100644 --- a/src/XMonad/Core.hs +++ b/src/XMonad/Core.hs @@ -467,11 +467,9 @@ recompile force = io $ do libTs <- mapM getModTime . Prelude.filter isSource =<< allFiles lib useBuildscript <- do exists <- doesFileExist buildscript - if exists then do - permissions <- getPermissions buildscript - return $ executable permissions - else - return False + if exists + then executable <$> getPermissions buildscript + else return False srcT <- getModTime src binT <- getModTime bin buildScriptT <- getModTime buildscript @@ -528,7 +526,7 @@ recompile force = io $ do , "-o", binn ] (Just dir) Nothing Nothing Nothing (Just errHandle) compileScript binn dir script errHandle = - runProcess script [dir, binn] (Just dir) Nothing Nothing Nothing (Just 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 () From 0b1ccc75ef9006b9736c504e93eb0a542e40b07c Mon Sep 17 00:00:00 2001 From: Philipp Balzarek Date: Sat, 10 Dec 2016 11:21:06 +0100 Subject: [PATCH 3/3] update CHANGES.md --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) 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