on master help sign in
Improvements to iPKG code.

This commit rehomes the code for package building and installation under the Idris namespace, allowing for projects that use the code to use a more meaningful import statement. This commit also factors out the ipkg data type from the parser.

commitcc1d6976d341cfa27c21d7dc85f124be15f60f81 authorJan de Muijnck-Hughes <jfdm@st-andrews.ac.uk> dateMon 1 Aug 2016, 14:40 (10 years ago) parent4a21c1d
5 files changed+60−37
idris.cabal+4−2 main/Main.hs+3−1 src/Pkg/Package.hs → src/Idris/Package.hs+7−3 src/Idris/Package/Common.hs+42 src/Pkg/PParser.hs → src/Idris/Package/Parser.hs+4−31
idris.cabal+4−2
@@ -1042,7 +1042,9 @@ Library
10421042 , IRTS.Simplified
10431043 , IRTS.System
10441044
1045− , Pkg.Package
1045+ , Idris.Package
1046+ , Idris.Package.Common
1047+
10461048 , Util.DynamicLinker
10471049 , Util.ScreenSize
10481050 , Util.System
@@ -1051,7 +1053,7 @@ Library
10511053 Util.Pretty
10521054 , Util.Net
10531055
1054− , Pkg.PParser
1056+ , Idris.Package.Parser
10551057
10561058 -- Auto Generated
10571059 , Paths_idris
main/Main.hs+3−1
@@ -10,11 +10,13 @@ import Idris.Imports
1010import Idris.Error
1111import Idris.CmdOptions
1212
13+import Idris.Package
14+
1315import IRTS.System ( getLibFlags, getIdrisLibDir, getIncFlags )
1416
1517import Util.System ( setupBundledCC )
1618
17−import Pkg.Package
19+
1820
1921-- Main program reads command line options, parses the main program, and gets
2022-- on with the REPL.
src/Pkg/Package.hs → src/Idris/Package.hsrenamed+7−3
@@ -1,12 +1,12 @@
11{-|
2−Module : Pkg.Package
2+Module : Idris.Package
33Description : Functionality for working with Idris packages.
44Copyright :
55License : BSD3
66Maintainer : The Idris Community.
77-}
88{-# LANGUAGE CPP #-}
9−module Pkg.Package where
9+module Idris.Package where
1010
1111import System.Process
1212import System.Directory
@@ -38,7 +38,8 @@ import Idris.Output
3838import Idris.Imports
3939import Idris.Error (ifail)
4040
41−import Pkg.PParser
41+import Idris.Package.Common
42+import Idris.Package.Parser
4243
4344import IRTS.System
4445
@@ -49,6 +50,9 @@ import IRTS.System
4950-- * invoke idris on each module, with idris_opts
5051-- * install everything into datadir/pname, if install flag is set
5152
53+getPkgDesc :: FilePath -> IO PkgDesc
54+getPkgDesc = parseDesc
55+
5256-- --------------------------------------------------------- [ Build Packages ]
5357
5458-- | Run the package through the idris compiler.
src/Idris/Package/Common.hsnew file+42
@@ -0,0 +1,42 @@
1+{-|
2+Module : Idris.Package.Common
3+Description : Data structures common to all `iPKG` file formats.
4+Copyright :
5+License : BSD3
6+Maintainer : The Idris Community.
7+-}
8+module Idris.Package.Common where
9+
10+import Idris.Core.TT
11+import Idris.REPL
12+import Idris.AbsSyntaxTree
13+
14+-- | Description of an Idris package.
15+data PkgDesc = PkgDesc {
16+ pkgname :: String -- ^ Name associated with a package.
17+ , pkgdeps :: [String] -- ^ List of packages this package depends on.
18+ , pkgbrief :: Maybe String -- ^ Brief description of the package.
19+ , pkgversion :: Maybe String -- ^ Version string to associate with the package.
20+ , pkgreadme :: Maybe String -- ^ Location of the README file.
21+ , pkglicense :: Maybe String -- ^ Description of the licensing information.
22+ , pkgauthor :: Maybe String -- ^ Author information.
23+ , pkgmaintainer :: Maybe String -- ^ Maintainer information.
24+ , pkghomepage :: Maybe String -- ^ Website associated with the package.
25+ , pkgsourceloc :: Maybe String -- ^ Location of the source files.
26+ , pkgbugtracker :: Maybe String -- ^ Location of the project's bug tracker.
27+ , libdeps :: [String] -- ^ External dependencies.
28+ , objs :: [String] -- ^ Object files required by the package.
29+ , makefile :: Maybe String -- ^ Makefile used to build external code. Used as part of the FFI process.
30+ , idris_opts :: [Opt] -- ^ List of options to give the compiler.
31+ , sourcedir :: String -- ^ Source directory for Idris files.
32+ , modules :: [Name] -- ^ Modules provided by the package.
33+ , idris_main :: Name -- ^ If an executable in which module can the Main namespace and function be found.
34+ , execout :: Maybe String -- ^ What to call the executable.
35+ , idris_tests :: [Name] -- ^ Lists of tests to execute against the package.
36+ } deriving (Show)
37+
38+-- | Default settings for package descriptions.
39+defaultPkg :: PkgDesc
40+defaultPkg = PkgDesc "" [] Nothing Nothing Nothing Nothing
41+ Nothing Nothing Nothing Nothing
42+ Nothing [] [] Nothing [] "" [] (sUN "") Nothing []
src/Pkg/PParser.hs → src/Idris/Package/Parser.hsrenamed+4−31
@@ -1,5 +1,5 @@
11{-|
2−Module : Pkg.PParser
2+Module : Idris.Package.Parser
33Description : `iPKG` file parser and package description information.
44Copyright :
55License : BSD3
@@ -9,7 +9,7 @@ Maintainer : The Idris Community.
99#if !(MIN_VERSION_base(4,8,0))
1010{-# LANGUAGE OverlappingInstances #-}
1111#endif
12−module Pkg.PParser where
12+module Idris.Package.Parser where
1313
1414import Text.Trifecta hiding (span, charLiteral, natural, symbol, char, string, whiteSpace)
1515import qualified Text.PrettyPrint.ANSI.Leijen as PP
@@ -19,6 +19,8 @@ import Idris.AbsSyntaxTree
1919import Idris.Parser.Helpers hiding (stringLiteral)
2020import Idris.CmdOptions
2121
22+import Idris.Package.Common
23+
2224import Control.Monad.State.Strict
2325import Control.Applicative
2426import System.FilePath (takeFileName, isValid)
@@ -29,35 +31,6 @@ import Util.System
2931
3032type PParser = StateT PkgDesc IdrisInnerParser
3133
32−data PkgDesc = PkgDesc {
33− pkgname :: String -- ^ Name associated with a package.
34− , pkgdeps :: [String] -- ^ List of packages this package depends on.
35− , pkgbrief :: Maybe String -- ^ Brief description of the package.
36− , pkgversion :: Maybe String -- ^ Version string to associate with the package.
37− , pkgreadme :: Maybe String -- ^ Location of the README file.
38− , pkglicense :: Maybe String -- ^ Description of the licensing information.
39− , pkgauthor :: Maybe String -- ^ Author information.
40− , pkgmaintainer :: Maybe String -- ^ Maintainer information.
41− , pkghomepage :: Maybe String -- ^ Website associated with the package.
42− , pkgsourceloc :: Maybe String -- ^ Location of the source files.
43− , pkgbugtracker :: Maybe String -- ^ Location of the project's bug tracker.
44− , libdeps :: [String] -- ^ External dependencies.
45− , objs :: [String] -- ^ Object files required by the package.
46− , makefile :: Maybe String -- ^ Makefile used to build external code. Used as part of the FFI process.
47− , idris_opts :: [Opt] -- ^ List of options to give the compiler.
48− , sourcedir :: String -- ^ Source directory for Idris files.
49− , modules :: [Name] -- ^ Modules provided by the package.
50− , idris_main :: Name -- ^ If an executable in which module can the Main namespace and function be found.
51− , execout :: Maybe String -- ^ What to call the executable.
52− , idris_tests :: [Name] -- ^ Lists of tests to execute against the package.
53− } deriving (Show)
54−
55−-- | Default settings for package descriptions.
56−defaultPkg :: PkgDesc
57−defaultPkg = PkgDesc "" [] Nothing Nothing Nothing Nothing
58− Nothing Nothing Nothing Nothing
59− Nothing [] [] Nothing [] "" [] (sUN "") Nothing []
60−
6134instance HasLastTokenSpan PParser where
6235 getLastTokenSpan = return Nothing
6336