@@ -1,42 +1,53 @@
1import Distribution.Simple
1import Distribution.Simple
2import Distribution.Simple.InstallDirs as I
2import Distribution.Simple.InstallDirs as I
3import Distribution.Simple.LocalBuildInfo as L
3import Distribution.Simple.LocalBuildInfo as L
4+import qualified Distribution.Simple.Setup as S
5+import qualified Distribution.Simple.Program as P
4import Distribution.PackageDescription
6import Distribution.PackageDescription
6import System.Exit
8import System.Exit
9+import System.FilePath ((</>))
7import System.Process
10import System.Process
9-- After Idris is built, we need to check and install the prelude and other libs
12-- After Idris is built, we need to check and install the prelude and other libs
11−system' cmd = do
14+make verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
12− exit <- system cmd
15+
13− case exit of
16+cleanStdLib verbosity
14− ExitSuccess -> return ()
15− ExitFailure _ -> exitWith exit
17−postCleanLib args flags desc _
18− = system' "make -C lib clean"
17+ = make verbosity [ "-C", "lib", "clean" ]
20−addPrefix pfx var c = "export " ++ var ++ "=" ++ show pfx ++ "/" ++ c ++ ":$" ++ var
22−postInstLib args flags desc local
23− = do let pkg = localPkgDescr local
24− let penv = packageTemplateEnv (package pkg)
25− let cenv = compilerTemplateEnv (compilerId (compiler local))
26− let dirs_pkg = substituteInstallDirTemplates penv (installDirTemplates local)
27− let dirs = substituteInstallDirTemplates cenv dirs_pkg
28− let bind = fromPathTemplate (bindir dirs)
29− let progPart t = L.substPathTemplate (packageId desc) local (t local)
30− let progpfx = progPart progPrefix
31− let progsfx = progPart progSuffix
32− let PackageName pkgname = (packageName desc)
33− let icmd = bind ++ "/" ++ progpfx ++ pkgname ++ progsfx
34− let idir = fromPathTemplate (datadir dirs) ++ "/" ++
35− fromPathTemplate (datasubdir dirs)
36− putStrLn $ "Installing libraries in " ++ idir
37− system' $ "make -C lib install TARGET=" ++ idir ++ " IDRIS=" ++ icmd
19+installStdLib 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
25+ [ "-C", "lib", "install"
30+checkStdLib local verbosity
31+ = do let icmd = ".." </> buildDir local </> "idris" </> "idris"
32+ putStrLn $ "Building libraries..."
34+ [ "-C", "lib", "check"
38+-- Install libraries during both copy and install
39+-- See http://hackage.haskell.org/trac/hackage/ticket/718
39−main = defaultMainWithHooks (simpleUserHooks { postInst = postInstLib,
40+main = defaultMainWithHooks $ simpleUserHooks
41+ { postCopy = \ _ flags pkg lbi -> do
42+ installStdLib pkg lbi (S.fromFlag $ S.copyVerbosity flags)
43+ (S.fromFlag $ S.copyDest flags)
44+ , postInst = \ _ flags pkg lbi -> do
45+ installStdLib pkg lbi (S.fromFlag $ S.installVerbosity flags)
40− postClean = postCleanLib })
47+ , postClean = \ _ flags _ _ -> do
48+ cleanStdLib (S.fromFlag $ S.cleanVerbosity flags)
49+ , postBuild = \ _ flags _ lbi -> do
50+ checkStdLib lbi (S.fromFlag $ S.buildVerbosity flags)