mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-04 14:11:55 -07:00
Having an executable build script implies force = True' in
recompile'
This is slight change to the original implementation. This version forces a recompile if XMonad detects a custom build script. The previous version took into consideration the time stamps of the source files. For a custom build script, the source files may be located in another location, or there could be dependencies unknown to XMonad. Better to just always call the build script and let it work out if something needs to be built.
This commit is contained in:
@@ -48,11 +48,6 @@
|
|||||||
instead of `ghc`. It takes one argument, the name of the
|
instead of `ghc`. It takes one argument, the name of the
|
||||||
executable binary it must produce.
|
executable binary it must produce.
|
||||||
|
|
||||||
Note: the build script is called whenever `ghc` would have been
|
|
||||||
called. That means the `xmonad.hs` file (or any files in `lib`
|
|
||||||
need to have newer time stamps than the generated executable in
|
|
||||||
order for the build script to be called.
|
|
||||||
|
|
||||||
This fixes #8. (One of two possible custom build solutions. See
|
This fixes #8. (One of two possible custom build solutions. See
|
||||||
the next entry for another solution.)
|
the next entry for another solution.)
|
||||||
|
|
||||||
|
@@ -570,19 +570,16 @@ recompile force = io $ do
|
|||||||
src = cfgdir </> "xmonad.hs"
|
src = cfgdir </> "xmonad.hs"
|
||||||
lib = cfgdir </> "lib"
|
lib = cfgdir </> "lib"
|
||||||
buildscript = cfgdir </> "build"
|
buildscript = cfgdir </> "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
|
||||||
buildScriptT <- getModTime buildscript
|
|
||||||
let addBuildScriptT = if useBuildscript
|
useBuildscript <- do
|
||||||
then (buildScriptT :)
|
exists <- doesFileExist buildscript
|
||||||
else id
|
if exists then isExecutable buildscript else return False
|
||||||
if force || any (binT <) ( addBuildScriptT $ srcT : libTs)
|
|
||||||
|
if force || useBuildscript || any (binT <) (srcT : libTs)
|
||||||
then do
|
then do
|
||||||
-- temporarily disable SIGCHLD ignoring:
|
-- temporarily disable SIGCHLD ignoring:
|
||||||
uninstallSignalHandlers
|
uninstallSignalHandlers
|
||||||
@@ -610,6 +607,7 @@ recompile force = io $ do
|
|||||||
else return True
|
else return True
|
||||||
where getModTime f = E.catch (Just <$> getModificationTime f) (\(SomeException _) -> return Nothing)
|
where getModTime f = E.catch (Just <$> getModificationTime f) (\(SomeException _) -> return Nothing)
|
||||||
isSource = flip elem [".hs",".lhs",".hsc"] . takeExtension
|
isSource = flip elem [".hs",".lhs",".hsc"] . takeExtension
|
||||||
|
isExecutable f = E.catch (executable <$> getPermissions f) (\(SomeException _) -> return False)
|
||||||
allFiles t = do
|
allFiles t = do
|
||||||
let prep = map (t</>) . Prelude.filter (`notElem` [".",".."])
|
let prep = map (t</>) . Prelude.filter (`notElem` [".",".."])
|
||||||
cs <- prep <$> E.catch (getDirectoryContents t) (\(SomeException _) -> return [])
|
cs <- prep <$> E.catch (getDirectoryContents t) (\(SomeException _) -> return [])
|
||||||
|
Reference in New Issue
Block a user