on aa7262e help sign in
Idris-dev/Setup.hs
84 lines 3.0 kB history raw
1{-# LANGUAGE CPP #-}
2import Distribution.Simple
3import Distribution.Simple.InstallDirs as I
4import Distribution.Simple.LocalBuildInfo as L
5import qualified Distribution.Simple.Setup as S
6import qualified Distribution.Simple.Program as P
7import Distribution.PackageDescription
9import System.Exit
10import System.FilePath ((</>))
11import System.Process
13-- After Idris is built, we need to check and install the prelude and other libs
15make verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
17#ifdef mingw32_HOST_OS
18-- make on mingw32 exepects unix style separators
19idrisCmd local = "../dist/build/idris/idris"
20#else
21idrisCmd local = ".." </> buildDir local </> "idris" </> "idris"
22#endif
24cleanStdLib verbosity
25 = make verbosity [ "-C", "lib", "clean" ]
27installStdLib pkg local verbosity copy
28 = do let dirs = L.absoluteInstallDirs pkg local copy
29 let idir = datadir dirs
30 let icmd = idrisCmd local
31 putStrLn $ "Installing libraries in " ++ idir
32 make verbosity
33 [ "-C", "lib", "install"
34 , "TARGET=" ++ idir
35 , "IDRIS=" ++ icmd
36 ]
37 let idirRts = idir </> "rts"
38 putStrLn $ "Installing run time system in " ++ idirRts
39 make verbosity
40 [ "-C", "rts", "install"
41 , "TARGET=" ++ idirRts
42 , "IDRIS=" ++ icmd
43 ]
45-- This is a hack. I don't know how to tell cabal that a data file needs
46-- installing but shouldn't be in the distribution. And it won't make the
47-- distribution if it's not there, so instead I just delete
48-- the file after configure.
50removeLibIdris local verbosity
51 = do let icmd = idrisCmd local
52 make verbosity
53 [ "-C", "rts", "clean"
54 , "IDRIS=" ++ icmd
55 ]
57checkStdLib local verbosity
58 = do let icmd = idrisCmd local
59 putStrLn $ "Building libraries..."
60 make verbosity
61 [ "-C", "lib", "check"
62 , "IDRIS=" ++ icmd
63 ]
64 make verbosity
65 [ "-C", "rts", "check"
66 , "IDRIS=" ++ icmd
67 ]
69-- Install libraries during both copy and install
70-- See http://hackage.haskell.org/trac/hackage/ticket/718
71main = defaultMainWithHooks $ simpleUserHooks
72 { postCopy = \ _ flags pkg lbi -> do
73 installStdLib pkg lbi (S.fromFlag $ S.copyVerbosity flags)
74 (S.fromFlag $ S.copyDest flags)
75 , postInst = \ _ flags pkg lbi -> do
76 installStdLib pkg lbi (S.fromFlag $ S.installVerbosity flags)
77 NoCopyDest
78 , postConf = \ _ flags _ lbi -> do
79 removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
80 , postClean = \ _ flags _ _ -> do
81 cleanStdLib (S.fromFlag $ S.cleanVerbosity flags)
82 , postBuild = \ _ flags _ lbi -> do
83 checkStdLib lbi (S.fromFlag $ S.buildVerbosity flags)
84 }