on master help sign in
Improvements to ipkg files for dependancies.

iPKG files have a new option `pkgs` which takes a comma-separated list of package names that the idris project depends on. This reduces bloat in the `opts` option with mutliple package declarations. So rather than have: ``` package foo opts = "-p lightyear -p containers -p tests -p pruviloj -p effects -p x --log 4" ``` we can now sayL ``` package foo opts = "--log 4" pkgs = lightyear, containers, tests, pruviloj, effects, x ```

commit0d78f192bd8326e2f3e61e8651bd1df116437aac authorJan de Muijnck-Hughes <jfdm@st-andrews.ac.uk> dateSat 26 Sep 2015, 13:39 (11 years ago) parent2f7d8c2
3 files changed+47−28
CHANGELOG+3 docs/reference/packages.rst+5−2 src/Pkg/PParser.hs+39−26
CHANGELOG+3
@@ -35,6 +35,9 @@ Tool updates
3535------------
3636* Records are now shown as records in :doc, rather than as the underlying
3737 datatype
38+* iPKG files have a new option `pkgs` which takes a comma-separated list
39+ of package names that the idris project depends on. This reduces bloat
40+ in the `opts` option with mutliple package declarations.
3841
3942Miscellaneous updates
4043---------------------
docs/reference/packages.rst+5−2
@@ -44,8 +44,11 @@ Other common fields which may be present in an ``ipkg`` file are:
4444+ ``main = <module>``, which takes the name of the main module, and
4545 must be present if the executable field is present.
4646
47−+ ``opts = "<idris options>"``, which allows options (such as other
48− packages) to be passed to Idris.
47++ ``opts = "<idris options>"``, which allows options to be passed to
48+ Idris.
49+
50++ ``pkgs = <pkg name> (',' <pkg name>)+``, a comma separated list of
51+ package names that the Idris package requires.
4952
5053Binding to C
5154------------
src/Pkg/PParser.hs+39−26
@@ -2,7 +2,13 @@
22#if !(MIN_VERSION_base(4,8,0))
33{-# LANGUAGE OverlappingInstances #-}
44#endif
5−
5+-- ------------------------------------------------------------- [ PParser.hs ]
6+-- Module : PParser.hs
7+-- Copyright : (c) The Idris Community.
8+-- License : see LICENSE
9+--
10+-- The parser for Idris ipkg files.
11+-- -------------------------------------------------------------------- [ EOH ]
612module Pkg.PParser where
713
814import Text.Trifecta hiding (span, charLiteral, natural, symbol, char, string, whiteSpace)
@@ -18,21 +24,20 @@ import Control.Applicative
1824
1925import Util.System
2026
21−
2227type PParser = StateT PkgDesc IdrisInnerParser
2328
24−data PkgDesc = PkgDesc { pkgname :: String,
25− libdeps :: [String],
26− objs :: [String],
27− makefile :: Maybe String,
28− idris_opts :: [Opt],
29− sourcedir :: String,
30− modules :: [Name],
31− idris_main :: Name,
32− execout :: Maybe String,
33− idris_tests :: [Name]
34− }
35− deriving Show
29+data PkgDesc = PkgDesc {
30+ pkgname :: String
31+ , libdeps :: [String]
32+ , objs :: [String]
33+ , makefile :: Maybe String
34+ , idris_opts :: [Opt]
35+ , sourcedir :: String
36+ , modules :: [Name]
37+ , idris_main :: Name
38+ , execout :: Maybe String
39+ , idris_tests :: [Name]
40+ } deriving (Show)
3641
3742instance HasLastTokenSpan PParser where
3843 getLastTokenSpan = return Nothing
@@ -44,23 +49,25 @@ instance TokenParsing PParser where
4449#endif
4550 someSpace = many (simpleWhiteSpace <|> singleLineComment <|> multiLineComment) *> pure ()
4651
47−
52+defaultPkg :: PkgDesc
4853defaultPkg = PkgDesc "" [] [] Nothing [] "" [] (sUN "") Nothing []
4954
5055parseDesc :: FilePath -> IO PkgDesc
51−parseDesc fp = do p <- readFile fp
52− case runparser pPkg defaultPkg fp p of
53− Failure err -> fail (show err)
54− Success x -> return x
56+parseDesc fp = do
57+ p <- readFile fp
58+ case runparser pPkg defaultPkg fp p of
59+ Failure err -> fail (show err)
60+ Success x -> return x
5561
5662pPkg :: PParser PkgDesc
57−pPkg = do reserved "package"; p <- fst <$> identifier
58− st <- get
59− put (st { pkgname = p })
60− some pClause
61− st <- get
62− eof
63− return st
63+pPkg = do
64+ reserved "package"; p <- fst <$> identifier
65+ st <- get
66+ put (st { pkgname = p })
67+ some pClause
68+ st <- get
69+ eof
70+ return st
6471
6572pClause :: PParser ()
6673pClause = do reserved "executable"; lchar '=';
@@ -80,6 +87,11 @@ pClause = do reserved "executable"; lchar '=';
8087 st <- get
8188 let args = pureArgParser (words opts)
8289 put (st { idris_opts = args })
90+ <|> do reserved "pkgs"; lchar '=';
91+ ps <- sepBy1 (fst <$> identifier) (lchar ',')
92+ st <- get
93+ let pkgs = pureArgParser $ map (\x -> unwords ["-p", x]) ps
94+ put (st {idris_opts = idris_opts st ++ pkgs})
8395 <|> do reserved "modules"; lchar '=';
8496 ms <- sepBy1 (fst <$> iName []) (lchar ',')
8597 st <- get
@@ -101,3 +113,4 @@ pClause = do reserved "executable"; lchar '=';
101113 st <- get
102114 put st { idris_tests = idris_tests st ++ ts }
103115
116+-- -------------------------------------------------------------------- [ EOF ]