on 09f2abd help sign in
Idris-dev/Setup.hs
42 lines 1.6 kB history raw
1import Distribution.Simple
2import Distribution.Simple.InstallDirs as I
3import Distribution.Simple.LocalBuildInfo as L
4import Distribution.PackageDescription
6import System.Exit
7import System.Process
9-- After Idris is built, we need to check and install the prelude and other libs
11system' cmd = do
12 exit <- system cmd
13 case exit of
14 ExitSuccess -> return ()
15 ExitFailure _ -> exitWith exit
17postCleanLib args flags desc _
18 = system' "make -C lib clean"
20addPrefix pfx var c = "export " ++ var ++ "=" ++ show pfx ++ "/" ++ c ++ ":$" ++ var
22postInstLib 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
39main = defaultMainWithHooks (simpleUserHooks { postInst = postInstLib,
40 postClean = postCleanLib })