#!/usr/bin/env runghc
import Distribution.Simple
import qualified Control.Exception as Ex
import System.Directory
import Control.Monad
import System.Info
import System.Exit
import List
b = "infinity"
main = defaultMainWithHooks $ defaultUserHooks {
postBuild = copyInfinity,
postClean = cleanInfinity
}
copyInfinity _ _ _ _ = do
copyFile ("dist/build/infinity/"++b) b
Ex.catch (createDirectory "Log" >> createDirectory "State")
(\_ -> return ())
return ()
cleanInfinity _ _ _ _ = do
Ex.catch (removeFile b)
(\_ -> return ())
clean "."
clean "Plugins"
return ()
where
clean s = do
c <- getDirectoryContents s
forM_ c $ \f -> do
if (".o" `isSuffixOf` f ||
".hi" `isSuffixOf` f ||
"#" `isSuffixOf` f ||
"~" `isSuffixOf` f)
then removeFile $ s++"/"++f
else return ()