Skip to content

Commit e159ec3

Browse files
authored
Merge pull request #53 from Philonous/rebuild_script
Add support for (re-) building using script
2 parents 5f5e737 + 0b1ccc7 commit e159ec3

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log / Release Notes
22

3+
## 0.13
4+
5+
* Re-builds using script `<xmonaddir>/build` if it exists and is executable
6+
37
## 0.12 (December 14, 2015)
48

59
* Compiles with GHC 7.10.2, 7.8.4, and 7.6.3

src/XMonad/Core.hs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,16 +463,27 @@ recompile force = io $ do
463463
err = base ++ ".errors"
464464
src = base ++ ".hs"
465465
lib = dir </> "lib"
466+
buildscript = dir </> "build"
466467
libTs <- mapM getModTime . Prelude.filter isSource =<< allFiles lib
468+
useBuildscript <- do
469+
exists <- doesFileExist buildscript
470+
if exists
471+
then executable <$> getPermissions buildscript
472+
else return False
467473
srcT <- getModTime src
468474
binT <- getModTime bin
469-
if force || any (binT <) (srcT : libTs)
475+
buildScriptT <- getModTime buildscript
476+
let addBuildScriptT = if useBuildscript
477+
then (buildScriptT :)
478+
else id
479+
if force || any (binT <) ( addBuildScriptT $ srcT : libTs)
470480
then do
471481
-- temporarily disable SIGCHLD ignoring:
472482
uninstallSignalHandlers
473-
status <- bracket (openFile err WriteMode) hClose $ \h ->
474-
waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-main-is", "main", "-v0", "-o",binn] (Just dir)
475-
Nothing Nothing Nothing (Just h)
483+
status <- bracket (openFile err WriteMode) hClose $ \errHandle ->
484+
waitForProcess =<< if useBuildscript
485+
then compileScript binn dir buildscript errHandle
486+
else compileGHC binn dir errHandle
476487

477488
-- re-enable SIGCHLD:
478489
installSignalHandlers
@@ -504,6 +515,18 @@ recompile force = io $ do
504515
'\8216' -> '`' --
505516
'\8217' -> '`' --
506517
_ -> c
518+
compileGHC binn dir errHandle =
519+
runProcess "ghc" ["--make"
520+
, "xmonad.hs"
521+
, "-i"
522+
, "-ilib"
523+
, "-fforce-recomp"
524+
, "-main-is", "main"
525+
, "-v0"
526+
, "-o", binn
527+
] (Just dir) Nothing Nothing Nothing (Just errHandle)
528+
compileScript binn dir script errHandle =
529+
runProcess script [binn] (Just dir) Nothing Nothing Nothing (Just errHandle)
507530

508531
-- | Conditionally run an action, using a @Maybe a@ to decide.
509532
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()

0 commit comments

Comments
 (0)