mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-21 14:33:48 -07:00
Merge pull request #53 from Philonous/rebuild_script
Add support for (re-) building using script
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
# Change Log / Release Notes
|
# Change Log / Release Notes
|
||||||
|
|
||||||
|
## 0.13
|
||||||
|
|
||||||
|
* Re-builds using script `<xmonaddir>/build` if it exists and is executable
|
||||||
|
|
||||||
## 0.12 (December 14, 2015)
|
## 0.12 (December 14, 2015)
|
||||||
|
|
||||||
* Compiles with GHC 7.10.2, 7.8.4, and 7.6.3
|
* Compiles with GHC 7.10.2, 7.8.4, and 7.6.3
|
||||||
|
@@ -463,16 +463,27 @@ recompile force = io $ do
|
|||||||
err = base ++ ".errors"
|
err = base ++ ".errors"
|
||||||
src = base ++ ".hs"
|
src = base ++ ".hs"
|
||||||
lib = dir </> "lib"
|
lib = dir </> "lib"
|
||||||
|
buildscript = dir </> "build"
|
||||||
libTs <- mapM getModTime . Prelude.filter isSource =<< allFiles lib
|
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
|
srcT <- getModTime src
|
||||||
binT <- getModTime bin
|
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
|
then do
|
||||||
-- temporarily disable SIGCHLD ignoring:
|
-- temporarily disable SIGCHLD ignoring:
|
||||||
uninstallSignalHandlers
|
uninstallSignalHandlers
|
||||||
status <- bracket (openFile err WriteMode) hClose $ \h ->
|
status <- bracket (openFile err WriteMode) hClose $ \errHandle ->
|
||||||
waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-main-is", "main", "-v0", "-o",binn] (Just dir)
|
waitForProcess =<< if useBuildscript
|
||||||
Nothing Nothing Nothing (Just h)
|
then compileScript binn dir buildscript errHandle
|
||||||
|
else compileGHC binn dir errHandle
|
||||||
|
|
||||||
-- re-enable SIGCHLD:
|
-- re-enable SIGCHLD:
|
||||||
installSignalHandlers
|
installSignalHandlers
|
||||||
@@ -504,6 +515,18 @@ recompile force = io $ do
|
|||||||
'\8216' -> '`' -- ‘
|
'\8216' -> '`' -- ‘
|
||||||
'\8217' -> '`' -- ’
|
'\8217' -> '`' -- ’
|
||||||
_ -> c
|
_ -> 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.
|
-- | Conditionally run an action, using a @Maybe a@ to decide.
|
||||||
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
|
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()
|
||||||
|
Reference in New Issue
Block a user