Skip to content
Permalink
Browse files
Merge pull request #53 from Philonous/rebuild_script
Add support for (re-) building using script
  • Loading branch information
pjones committed Dec 13, 2016
2 parents 5f5e737 + 0b1ccc7 commit e159ec36fe407d21c5c706dfba71f1438c0f9d1e
Showing 2 changed files with 31 additions and 4 deletions.
@@ -1,5 +1,9 @@
# Change Log / Release Notes

## 0.13

* Re-builds using script `<xmonaddir>/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
@@ -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 ()

0 comments on commit e159ec3

Please sign in to comment.