on df5bf81 help sign in
Idris-dev/Setup.hs
97 lines 3.5 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 ((</>), splitDirectories)
11import qualified System.FilePath.Posix as Px
12import System.Process
14-- After Idris is built, we need to check and install the prelude and other libs
16make verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
18#ifdef mingw32_HOST_OS
19-- make on mingw32 exepects unix style separators
20(<//>) = (Px.</>)
21idrisCmd local = Px.joinPath $ splitDirectories $
22 ".." <//> buildDir local <//> "idris" <//> "idris"
23#else
24idrisCmd local = ".." </> buildDir local </> "idris" </> "idris"
25#endif
27cleanStdLib verbosity
28 = do make verbosity [ "-C", "lib", "clean", "IDRIS=idris" ]
29 make verbosity [ "-C", "effects", "clean", "IDRIS=idris" ]
31installStdLib pkg local verbosity copy
32 = do let dirs = L.absoluteInstallDirs pkg local copy
33 let idir = datadir dirs
34 let icmd = idrisCmd local
35 putStrLn $ "Installing libraries in " ++ idir
36 make verbosity
37 [ "-C", "lib", "install"
38 , "TARGET=" ++ idir
39 , "IDRIS=" ++ icmd
40 ]
41 make verbosity
42 [ "-C", "effects", "install"
43 , "TARGET=" ++ idir
44 , "IDRIS=" ++ icmd
45 ]
46 let idirRts = idir </> "rts"
47 putStrLn $ "Installing run time system in " ++ idirRts
48 make verbosity
49 [ "-C", "rts", "install"
50 , "TARGET=" ++ idirRts
51 , "IDRIS=" ++ icmd
52 ]
54-- This is a hack. I don't know how to tell cabal that a data file needs
55-- installing but shouldn't be in the distribution. And it won't make the
56-- distribution if it's not there, so instead I just delete
57-- the file after configure.
59removeLibIdris local verbosity
60 = do let icmd = idrisCmd local
61 make verbosity
62 [ "-C", "rts", "clean"
63 , "IDRIS=" ++ icmd
64 ]
66checkStdLib local verbosity
67 = do let icmd = idrisCmd local
68 putStrLn $ "Building libraries..."
69 make verbosity
70 [ "-C", "lib", "check"
71 , "IDRIS=" ++ icmd
72 ]
73 make verbosity
74 [ "-C", "effects", "check"
75 , "IDRIS=" ++ icmd
76 ]
77 make verbosity
78 [ "-C", "rts", "check"
79 , "IDRIS=" ++ icmd
80 ]
82-- Install libraries during both copy and install
83-- See http://hackage.haskell.org/trac/hackage/ticket/718
84main = defaultMainWithHooks $ simpleUserHooks
85 { postCopy = \ _ flags pkg lbi -> do
86 installStdLib pkg lbi (S.fromFlag $ S.copyVerbosity flags)
87 (S.fromFlag $ S.copyDest flags)
88 , postInst = \ _ flags pkg lbi -> do
89 installStdLib pkg lbi (S.fromFlag $ S.installVerbosity flags)
90 NoCopyDest
91 , postConf = \ _ flags _ lbi -> do
92 removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
93 , postClean = \ _ flags _ _ -> do
94 cleanStdLib (S.fromFlag $ S.cleanVerbosity flags)
95 , postBuild = \ _ flags _ lbi -> do
96 checkStdLib lbi (S.fromFlag $ S.buildVerbosity flags)
97 }