@@ -23,6 +23,7 @@ import Idris.Parser (loadModule)
2323import Idris.Output (pshow)
2424import Idris.AbsSyntax
2525import Idris.IdrisDoc
26+import Idris.IBC
2627import Idris.Output
2728
2829import IRTS.System
@@ -36,21 +37,26 @@ import Pkg.PParser
3637-- * invoke idris on each module, with idris_opts
3738-- * install everything into datadir/pname, if install flag is set
3839
40+-- | Get the index file name for a package name
41+pkgIndex :: String -> FilePath
42+pkgIndex s = "00" ++ s ++ "-idx.ibc"
43+
3944-- | Run the package through the idris compiler.
4045buildPkg :: Bool -> (Bool, FilePath) -> IO ()
4146buildPkg warnonly (install, fp)
4247 = do pkgdesc <- parseDesc fp
48+ let idx = PkgIndex (pkgIndex (pkgname pkgdesc))
4349 ok <- mapM (testLib warnonly (pkgname pkgdesc)) (libdeps pkgdesc)
4450 when (and ok) $
4551 do dir <- getCurrentDirectory
4652 setCurrentDirectory $ dir </> sourcedir pkgdesc
4753 make (makefile pkgdesc)
4854 m_ist <- case (execout pkgdesc) of
49− Nothing -> buildMods (NoREPL : Verbose : idris_opts pkgdesc)
55+ Nothing -> buildMods (idx : NoREPL : Verbose : idris_opts pkgdesc)
5056 (modules pkgdesc)
5157 Just o -> do let exec = dir </> o
5258 buildMods
53− (NoREPL : Verbose : Output exec : idris_opts pkgdesc)
59+ (idx : NoREPL : Verbose : Output exec : idris_opts pkgdesc)
5460 [idris_main pkgdesc]
5561 setCurrentDirectory dir
5662 case m_ist of
@@ -60,14 +66,7 @@ buildPkg warnonly (install, fp)
6066 case errSpan ist of
6167 Just _ -> exitWith (ExitFailure 1)
6268 _ -> return ()
63− -- Also give up if there are metavariables to solve
64− case (map fst (idris_metavars ist) \\ primDefs) of
65− _ -> when install $ installPkg pkgdesc
66−-- ms -> do if install
67−-- then putStrLn "Can't install: there are undefined metavariables:"
68−-- else putStrLn "There are undefined metavariables:"
69−-- putStrLn $ "\t" ++ show ms
70−-- exitWith (ExitFailure 1)
69+ when install $ installPkg pkgdesc
7170
7271-- | Type check packages only
7372--
@@ -203,7 +202,8 @@ installPkg pkgdesc
203202 = do dir <- getCurrentDirectory
204203 setCurrentDirectory $ dir </> sourcedir pkgdesc
205204 case (execout pkgdesc) of
206− Nothing -> mapM_ (installIBC (pkgname pkgdesc)) (modules pkgdesc)
205+ Nothing -> do mapM_ (installIBC (pkgname pkgdesc)) (modules pkgdesc)
206+ installIdx (pkgname pkgdesc)
207207 Just o -> return () -- do nothing, keep executable locally, for noe
208208 mapM_ (installObj (pkgname pkgdesc)) (objs pkgdesc)
209209
@@ -213,7 +213,6 @@ installPkg pkgdesc
213213
214214buildMods :: [Opt] -> [Name] -> IO (Maybe IState)
215215buildMods opts ns = do let f = map (toPath . showCG) ns
216−-- putStrLn $ "MODULE: " ++ show f
217216 idris (map Filename f ++ opts)
218217 where toPath n = foldl1' (</>) $ splitOn "." n
219218
@@ -250,6 +249,14 @@ installIBC p m = do let f = toIBCFile m
250249 where getDest (UN n) = ""
251250 getDest (NS n ns) = foldl1' (</>) (reverse (getDest n : map str ns))
252251
252+installIdx :: String -> IO ()
253+installIdx p = do d <- getTargetDir
254+ let f = pkgIndex p
255+ let destdir = d </> p
256+ putStrLn $ "Installing " ++ f ++ " to " ++ destdir
257+ createDirectoryIfMissing True destdir
258+ copyFile f (destdir </> takeFileName f)
259+ return ()
253260
254261installObj :: String -> String -> IO ()
255262installObj p o = do d <- getTargetDir