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