public
Description: a haskell IRC bot
Homepage:
Clone URL: git://github.com/thoughtpolice/infinity.git
infinity / Setup.hs
100755 41 lines (34 sloc) 1.011 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env runghc
import Distribution.Simple
import System.Directory
import System.FilePath
import Control.Monad
import System.Info
import System.Exit
import List
 
inf = "infinity"
-- files to remove
bins = [inf] ++
       ["util" </> "unlambda"]
-- directories to clean
dirs = [ "."
       , "util" ] ++
       map ("src" </>) [ "Infinity"
                       , "Infinity" </> "Plugins"]
 
main = defaultMainWithHooks $ simpleUserHooks {
      postBuild = copyInfinity,
      postClean = cleanInfinity
}
 
copyInfinity _ _ _ _ = do
  copyFile (joinPath ["dist","build","infinity",inf]) inf
  ignore (createDirectory "Log" >> createDirectory "State")
 
cleanInfinity _ _ _ _ = do
  mapM_ (ignore . removeFile) bins
  mapM_ clean dirs
 where
   clean d = getDirectoryContents d >>= mapM_ (check d)
   check d f = when (any (`isSuffixOf` f) exts)
                (removeFile (d </> f))
   exts = ["~",".o",".hi",".o-boot",".hi-boot"]
 
 
-- convenience
ignore a = Prelude.catch a (\_ -> return ())