@@ -23,6 +23,7 @@ import Idris.Parser (loadModule)
23import Idris.Output (pshow)
23import Idris.Output (pshow)
24import Idris.AbsSyntax
24import Idris.AbsSyntax
25import Idris.IdrisDoc
25import Idris.IdrisDoc
26import Idris.Output
27import Idris.Output
28import IRTS.System
29import IRTS.System
@@ -36,21 +37,26 @@ import Pkg.PParser
36-- * invoke idris on each module, with idris_opts
37-- * invoke idris on each module, with idris_opts
37-- * install everything into datadir/pname, if install flag is set
38-- * install everything into datadir/pname, if install flag is set
40+-- | Get the index file name for a package name
41+pkgIndex :: String -> FilePath
42+pkgIndex s = "00" ++ s ++ "-idx.ibc"
39-- | Run the package through the idris compiler.
44-- | Run the package through the idris compiler.
40buildPkg :: Bool -> (Bool, FilePath) -> IO ()
45buildPkg :: Bool -> (Bool, FilePath) -> IO ()
41buildPkg warnonly (install, fp)
46buildPkg warnonly (install, fp)
42 = do pkgdesc <- parseDesc fp
47 = do pkgdesc <- parseDesc fp
48+ let idx = PkgIndex (pkgIndex (pkgname pkgdesc))
43 ok <- mapM (testLib warnonly (pkgname pkgdesc)) (libdeps pkgdesc)
49 ok <- mapM (testLib warnonly (pkgname pkgdesc)) (libdeps pkgdesc)
44 when (and ok) $
50 when (and ok) $
45 do dir <- getCurrentDirectory
51 do dir <- getCurrentDirectory
46 setCurrentDirectory $ dir </> sourcedir pkgdesc
52 setCurrentDirectory $ dir </> sourcedir pkgdesc
47 make (makefile pkgdesc)
53 make (makefile pkgdesc)
48 m_ist <- case (execout pkgdesc) of
54 m_ist <- case (execout pkgdesc) of
49− Nothing -> buildMods (NoREPL : Verbose : idris_opts pkgdesc)
55+ Nothing -> buildMods (idx : NoREPL : Verbose : idris_opts pkgdesc)
50 (modules pkgdesc)
56 (modules pkgdesc)
51 Just o -> do let exec = dir </> o
57 Just o -> do let exec = dir </> o
53− (NoREPL : Verbose : Output exec : idris_opts pkgdesc)
59+ (idx : NoREPL : Verbose : Output exec : idris_opts pkgdesc)
54 [idris_main pkgdesc]
60 [idris_main pkgdesc]
55 setCurrentDirectory dir
61 setCurrentDirectory dir
56 case m_ist of
62 case m_ist of
@@ -60,14 +66,7 @@ buildPkg warnonly (install, fp)
60 case errSpan ist of
66 case errSpan ist of
61 Just _ -> exitWith (ExitFailure 1)
67 Just _ -> exitWith (ExitFailure 1)
62 _ -> return ()
68 _ -> 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
69+ 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)
72-- | Type check packages only
71-- | Type check packages only
@@ -203,7 +202,8 @@ installPkg pkgdesc
203 = do dir <- getCurrentDirectory
202 = do dir <- getCurrentDirectory
204 setCurrentDirectory $ dir </> sourcedir pkgdesc
203 setCurrentDirectory $ dir </> sourcedir pkgdesc
205 case (execout pkgdesc) of
204 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)
207 Just o -> return () -- do nothing, keep executable locally, for noe
207 Just o -> return () -- do nothing, keep executable locally, for noe
208 mapM_ (installObj (pkgname pkgdesc)) (objs pkgdesc)
208 mapM_ (installObj (pkgname pkgdesc)) (objs pkgdesc)
@@ -213,7 +213,6 @@ installPkg pkgdesc
214buildMods :: [Opt] -> [Name] -> IO (Maybe IState)
214buildMods :: [Opt] -> [Name] -> IO (Maybe IState)
215buildMods opts ns = do let f = map (toPath . showCG) ns
215buildMods opts ns = do let f = map (toPath . showCG) ns
216−-- putStrLn $ "MODULE: " ++ show f
217 idris (map Filename f ++ opts)
216 idris (map Filename f ++ opts)
218 where toPath n = foldl1' (</>) $ splitOn "." n
217 where toPath n = foldl1' (</>) $ splitOn "." n
@@ -250,6 +249,14 @@ installIBC p m = do let f = toIBCFile m
250 where getDest (UN n) = ""
249 where getDest (UN n) = ""
251 getDest (NS n ns) = foldl1' (</>) (reverse (getDest n : map str ns))
250 getDest (NS n ns) = foldl1' (</>) (reverse (getDest n : map str ns))
252+installIdx :: String -> IO ()
253+installIdx p = do d <- getTargetDir
255+ let destdir = d </> p
256+ putStrLn $ "Installing " ++ f ++ " to " ++ destdir
257+ createDirectoryIfMissing True destdir
258+ copyFile f (destdir </> takeFileName f)
254installObj :: String -> String -> IO ()
261installObj :: String -> String -> IO ()
255installObj p o = do d <- getTargetDir
262installObj p o = do d <- getTargetDir