on ebacfee help sign in
Idris-dev/Setup.hs
87 lines 3.2 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 = make verbosity [ "-C", "lib", "clean" ]
30installStdLib pkg local verbosity copy
31 = do let dirs = L.absoluteInstallDirs pkg local copy
32 let idir = datadir dirs
33 let icmd = idrisCmd local
34 putStrLn $ "Installing libraries in " ++ idir
35 make verbosity
36 [ "-C", "lib", "install"
37 , "TARGET=" ++ idir
38 , "IDRIS=" ++ icmd
39 ]
40 let idirRts = idir </> "rts"
41 putStrLn $ "Installing run time system in " ++ idirRts
42 make verbosity
43 [ "-C", "rts", "install"
44 , "TARGET=" ++ idirRts
45 , "IDRIS=" ++ icmd
46 ]
48-- This is a hack. I don't know how to tell cabal that a data file needs
49-- installing but shouldn't be in the distribution. And it won't make the
50-- distribution if it's not there, so instead I just delete
51-- the file after configure.
53removeLibIdris local verbosity
54 = do let icmd = idrisCmd local
55 make verbosity
56 [ "-C", "rts", "clean"
57 , "IDRIS=" ++ icmd
58 ]
60checkStdLib local verbosity
61 = do let icmd = idrisCmd local
62 putStrLn $ "Building libraries..."
63 make verbosity
64 [ "-C", "lib", "check"
65 , "IDRIS=" ++ icmd
66 ]
67 make verbosity
68 [ "-C", "rts", "check"
69 , "IDRIS=" ++ icmd
70 ]
72-- Install libraries during both copy and install
73-- See http://hackage.haskell.org/trac/hackage/ticket/718
74main = defaultMainWithHooks $ simpleUserHooks
75 { postCopy = \ _ flags pkg lbi -> do
76 installStdLib pkg lbi (S.fromFlag $ S.copyVerbosity flags)
77 (S.fromFlag $ S.copyDest flags)
78 , postInst = \ _ flags pkg lbi -> do
79 installStdLib pkg lbi (S.fromFlag $ S.installVerbosity flags)
80 NoCopyDest
81 , postConf = \ _ flags _ lbi -> do
82 removeLibIdris lbi (S.fromFlag $ S.configVerbosity flags)
83 , postClean = \ _ flags _ _ -> do
84 cleanStdLib (S.fromFlag $ S.cleanVerbosity flags)
85 , postBuild = \ _ flags _ lbi -> do
86 checkStdLib lbi (S.fromFlag $ S.buildVerbosity flags)
87 }