on master help sign in
Extend iPKG files to include metadata.

Taking cues from cabal, the iPKG format has been extended to include more package metadata information. The following fields have been added: + brief: Brief description of the package. + version: Version string to associate with the package. + readme: Location of the README file. + license: Description of the licensing information. + author: Author information. + maintainer: Maintainer information. + homepage: Website associated with the package. + sourcepage: Location of the DCVS where the source can be found. The documentation for packages was also updated.

commit61dfb94cebba05cfbd8a8a5814b660600a1642e2 authorJan de Muijnck-Hughes <jfdm@st-andrews.ac.uk> dateMon 6 Jun 2016, 14:13 (10 years ago) parentfc3e88c
4 files changed+158−13
CHANGELOG.md+17−1 docs/reference/packages.rst+29 src/Pkg/PParser.hs+102−12 test/pkg001/test-pkg.ipkg+10
CHANGELOG.md+17−1
@@ -80,9 +80,25 @@
8080* Added `Data.List.Views` with views on `List` and their covering functions.
8181* Added `Data.Nat.Views` with views on `Nat` and their covering functions.
8282* Added `Data.Primitives.Views` with views on various primitive types and their covering functions.
83−* Added `System.Concurrency.Sessions` for simple management of conversations
83+* Added `System.Concurrency.Sessions` for simple management of conversations
8484 between processes
8585
86+## iPKG Updates
87+
88+* Taking cues from cabal, the `iPKG` format has been extended to
89+ include more package metadata information. The following fields
90+ have been added:
91+
92+ + `brief`: Brief description of the package.
93+ + `version`: Version string to associate with the package.
94+ + `readme`: Location of the README file.
95+ + `license`: Description of the licensing information.
96+ + `author`: Author information.
97+ + `maintainer`: Maintainer information.
98+ + `homepage`: Website associated with the package.
99+ + `sourcepage`: Location of the DVCS where the source can be found.
100+
101+
86102## Miscellaneous updates
87103
88104* The Idris man page is now installed as part of the cabal/stack build process.
docs/reference/packages.rst+29
@@ -31,6 +31,35 @@ written as follows::
3131Other examples of package files can be found in the ``libs`` directory
3232of the main Idris repository, and in `third-party libraries <https://github.com/idris-lang/Idris-dev/wiki/Libraries>`_.
3333
34+Metadata
35+--------
36+
37+From Idris `v0.12` the `iPKG` format supports additional metadata
38+associated with the package.
39+The added fields are:
40+
41++ ``brief = "<text>"``, a string literal containing a brief description
42+ of the package.
43+
44++ ``version = <text>``, a version string to associate with the package.
45+
46++ ``readme = <file>``, location of the README file.
47+
48++ ``license = <text>``, a string description of the licensing
49+ information.
50+
51++ ``author = <text>``, the author information.
52+
53++ ``maintainer = <text>``, Maintainer information.
54+
55++ ``homepage = <url>``, the website associated with the package.
56+
57++ ``sourceloc = <url>``, the location of the DVCS where the source
58+ can be found.
59+
60++ ``bugtracker = <url>``, the location of the project's bug tracker.
61+
62+
3463Common Fields
3564-------------
3665
src/Pkg/PParser.hs+102−12
@@ -29,18 +29,33 @@ import Util.System
2929type PParser = StateT PkgDesc IdrisInnerParser
3030
3131data PkgDesc = PkgDesc {
32− pkgname :: String
33− , libdeps :: [String]
34− , objs :: [String]
35− , makefile :: Maybe String
36− , idris_opts :: [Opt]
37− , sourcedir :: String
38− , modules :: [Name]
39− , idris_main :: Name
40− , execout :: Maybe String
41− , idris_tests :: [Name]
32+ pkgname :: String -- ^ Name associated with a package.
33+ , pkgbrief :: Maybe String -- ^ Brief description of the package.
34+ , pkgversion :: Maybe String -- ^ Version string to associate with the package.
35+ , pkgreadme :: Maybe String -- ^ Location of the README file.
36+ , pkglicense :: Maybe String -- ^ Description of the licensing information.
37+ , pkgauthor :: Maybe String -- ^ Author information.
38+ , pkgmaintainer :: Maybe String -- ^ Maintainer information.
39+ , pkghomepage :: Maybe String -- ^ Website associated with the package.
40+ , pkgsourceloc :: Maybe String -- ^ Location of the source files.
41+ , pkgbugtracker :: Maybe String -- ^ Location of the project's bug tracker.
42+ , libdeps :: [String] -- ^ External dependencies.
43+ , objs :: [String] -- ^ Object files required by the package.
44+ , makefile :: Maybe String -- ^ Makefile used to build external code. Used as part of the FFI process.
45+ , idris_opts :: [Opt] -- ^ List of options to give the compiler.
46+ , sourcedir :: String -- ^ Source directory for Idris files.
47+ , modules :: [Name] -- ^ Modules provided by the package.
48+ , idris_main :: Name -- ^ If an executable in which module can the Main namespace and function be found.
49+ , execout :: Maybe String -- ^ What to call the executable.
50+ , idris_tests :: [Name] -- ^ Lists of tests to execute against the package.
4251 } deriving (Show)
4352
53+-- | Default settings for package descriptions.
54+defaultPkg :: PkgDesc
55+defaultPkg = PkgDesc "" Nothing Nothing Nothing Nothing
56+ Nothing Nothing Nothing Nothing
57+ Nothing [] [] Nothing [] "" [] (sUN "") Nothing []
58+
4459instance HasLastTokenSpan PParser where
4560 getLastTokenSpan = return Nothing
4661
@@ -51,8 +66,6 @@ instance TokenParsing PParser where
5166#endif
5267 someSpace = many (simpleWhiteSpace <|> singleLineComment <|> multiLineComment) *> pure ()
5368
54−defaultPkg :: PkgDesc
55−defaultPkg = PkgDesc "" [] [] Nothing [] "" [] (sUN "") Nothing []
5669
5770parseDesc :: FilePath -> IO PkgDesc
5871parseDesc fp = do
@@ -121,41 +134,118 @@ pClause = do reserved "executable"; lchar '=';
121134 exec <- filename
122135 st <- get
123136 put (st { execout = Just exec })
137+
124138 <|> do reserved "main"; lchar '=';
125139 main <- fst <$> iName []
126140 st <- get
127141 put (st { idris_main = main })
142+
128143 <|> do reserved "sourcedir"; lchar '=';
129144 src <- fst <$> identifier
130145 st <- get
131146 put (st { sourcedir = src })
147+
132148 <|> do reserved "opts"; lchar '=';
133149 opts <- stringLiteral
134150 st <- get
135151 let args = pureArgParser (words opts)
136152 put (st { idris_opts = args ++ idris_opts st })
153+
137154 <|> do reserved "pkgs"; lchar '=';
138155 ps <- sepBy1 (fst <$> identifier) (lchar ',')
139156 st <- get
140157 let pkgs = pureArgParser $ concatMap (\x -> ["-p", x]) ps
141158 put (st {idris_opts = pkgs ++ idris_opts st})
159+
142160 <|> do reserved "modules"; lchar '=';
143161 ms <- sepBy1 (fst <$> iName []) (lchar ',')
144162 st <- get
145163 put (st { modules = modules st ++ ms })
164+
146165 <|> do reserved "libs"; lchar '=';
147166 ls <- sepBy1 (fst <$> identifier) (lchar ',')
148167 st <- get
149168 put (st { libdeps = libdeps st ++ ls })
169+
150170 <|> do reserved "objs"; lchar '=';
151171 ls <- sepBy1 (fst <$> identifier) (lchar ',')
152172 st <- get
153173 put (st { objs = libdeps st ++ ls })
174+
154175 <|> do reserved "makefile"; lchar '=';
155176 mk <- fst <$> iName []
156177 st <- get
157178 put (st { makefile = Just (show mk) })
179+
158180 <|> do reserved "tests"; lchar '=';
159181 ts <- sepBy1 (fst <$> iName []) (lchar ',')
160182 st <- get
161183 put st { idris_tests = idris_tests st ++ ts }
184+
185+ <|> do reserved "version"
186+ lchar '='
187+ vStr <- many (satisfy (not . isEol))
188+ eol
189+ someSpace
190+ st <- get
191+ put st {pkgversion = Just vStr}
192+
193+ <|> do reserved "readme"
194+ lchar '='
195+ rme <- many (satisfy (not . isEol))
196+ eol
197+ someSpace
198+ st <- get
199+ put (st { pkgreadme = Just rme })
200+
201+ <|> do reserved "license"
202+ lchar '='
203+ lStr <- many (satisfy (not . isEol))
204+ eol
205+ st <- get
206+ put st {pkglicense = Just lStr}
207+
208+ <|> do reserved "homepage"
209+ lchar '='
210+ www <- many (satisfy (not . isEol))
211+ eol
212+ someSpace
213+ st <- get
214+ put st {pkghomepage = Just www}
215+
216+ <|> do reserved "sourceloc"
217+ lchar '='
218+ srcpage <- many (satisfy (not . isEol))
219+ eol
220+ someSpace
221+ st <- get
222+ put st {pkgsourceloc = Just srcpage}
223+
224+ <|> do reserved "bugtracker"
225+ lchar '='
226+ src <- many (satisfy (not . isEol))
227+ eol
228+ someSpace
229+ st <- get
230+ put st {pkgbugtracker = Just src}
231+
232+ <|> do reserved "brief"
233+ lchar '='
234+ brief <- stringLiteral
235+ st <- get
236+ someSpace
237+ put st {pkgbrief = Just brief}
238+
239+ <|> do reserved "author"; lchar '=';
240+ author <- many (satisfy (not . isEol))
241+ eol
242+ someSpace
243+ st <- get
244+ put st {pkgauthor = Just author}
245+
246+ <|> do reserved "maintainer"; lchar '=';
247+ maintainer <- many (satisfy (not . isEol))
248+ eol
249+ someSpace
250+ st <- get
251+ put st {pkgmaintainer = Just maintainer}
test/pkg001/test-pkg.ipkg+10
@@ -5,3 +5,13 @@ pkgs = effects
55opts = "--warnpartial --warnreach --nocolour --quiet --consolewidth 80"
66
77modules = Main
8+
9+author = Anne Author
10+maintainer = Anne Maintainer
11+license = BSD3 but see LICENSE for more information
12+brief = "This is a test package."
13+readme = README.md
14+version = 1234
15+homepage = http://www.idris-lang.org
16+sourceloc = http://ww.github.com/idris-lang/Idris-Dev
17+bugtracker = http://ww.github.com/idris-lang/Idris-Dev/issues