on master help sign in
Merge pull request #3305 from jfdm/pkg-namespace
588e347Jan de Muijnck-Hughes
idris.cabal+4−2
@@ -1042,7 +1042,9 @@ Library
1042 , IRTS.Simplified
1042 , IRTS.Simplified
1043 , IRTS.System
1043 , IRTS.System
1044
1044
1045+ , Idris.Package
1045− , Pkg.Package
1046+ , Idris.Package.Common
1047+
1046 , Util.DynamicLinker
1048 , Util.DynamicLinker
1047 , Util.ScreenSize
1049 , Util.ScreenSize
1048 , Util.System
1050 , Util.System
@@ -1051,7 +1053,7 @@ Library
1051 Util.Pretty
1053 Util.Pretty
1052 , Util.Net
1054 , Util.Net
1053
1055
1054− , Pkg.PParser
1056+ , Idris.Package.Parser
1055
1057
1056 -- Auto Generated
1058 -- Auto Generated
1057 , Paths_idris
1059 , Paths_idris
main/Main.hs+3−1
@@ -10,11 +10,13 @@ import Idris.Imports
10import Idris.Error
10import Idris.Error
11import Idris.CmdOptions
11import Idris.CmdOptions
12
12
13+import Idris.Package
14+
13import IRTS.System ( getLibFlags, getIdrisLibDir, getIncFlags )
15import IRTS.System ( getLibFlags, getIdrisLibDir, getIncFlags )
14
16
15import Util.System ( setupBundledCC )
17import Util.System ( setupBundledCC )
16
18
17−import Pkg.Package
19+
18
20
19-- Main program reads command line options, parses the main program, and gets
21-- Main program reads command line options, parses the main program, and gets
20-- on with the REPL.
22-- on with the REPL.
src/Pkg/Package.hs → src/Idris/Package.hsrenamed+7−3
@@ -1,12 +1,12 @@
1{-|
1{-|
2−Module : Pkg.Package
2+Module : Idris.Package
3Description : Functionality for working with Idris packages.
3Description : Functionality for working with Idris packages.
4Copyright :
4Copyright :
5License : BSD3
5License : BSD3
6Maintainer : The Idris Community.
6Maintainer : The Idris Community.
7-}
7-}
8{-# LANGUAGE CPP #-}
8{-# LANGUAGE CPP #-}
9−module Pkg.Package where
9+module Idris.Package where
10
10
11import System.Process
11import System.Process
12import System.Directory
12import System.Directory
@@ -38,7 +38,8 @@ import Idris.Output
38import Idris.Imports
38import Idris.Imports
39import Idris.Error (ifail)
39import Idris.Error (ifail)
40
40
41−import Pkg.PParser
41+import Idris.Package.Common
42+import Idris.Package.Parser
42
43
43import IRTS.System
44import IRTS.System
44
45
@@ -49,6 +50,9 @@ import IRTS.System
49-- * invoke idris on each module, with idris_opts
50-- * invoke idris on each module, with idris_opts
50-- * install everything into datadir/pname, if install flag is set
51-- * install everything into datadir/pname, if install flag is set
51
52
53+getPkgDesc :: FilePath -> IO PkgDesc
54+getPkgDesc = parseDesc
55+
52-- --------------------------------------------------------- [ Build Packages ]
56-- --------------------------------------------------------- [ Build Packages ]
53
57
54-- | Run the package through the idris compiler.
58-- | 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 @@
1{-|
1{-|
2−Module : Pkg.PParser
2+Module : Idris.Package.Parser
3Description : `iPKG` file parser and package description information.
3Description : `iPKG` file parser and package description information.
4Copyright :
4Copyright :
5License : BSD3
5License : BSD3
@@ -9,7 +9,7 @@ Maintainer : The Idris Community.
9#if !(MIN_VERSION_base(4,8,0))
9#if !(MIN_VERSION_base(4,8,0))
10{-# LANGUAGE OverlappingInstances #-}
10{-# LANGUAGE OverlappingInstances #-}
11#endif
11#endif
12−module Pkg.PParser where
12+module Idris.Package.Parser where
13
13
14import Text.Trifecta hiding (span, charLiteral, natural, symbol, char, string, whiteSpace)
14import Text.Trifecta hiding (span, charLiteral, natural, symbol, char, string, whiteSpace)
15import qualified Text.PrettyPrint.ANSI.Leijen as PP
15import qualified Text.PrettyPrint.ANSI.Leijen as PP
@@ -19,6 +19,8 @@ import Idris.AbsSyntaxTree
19import Idris.Parser.Helpers hiding (stringLiteral)
19import Idris.Parser.Helpers hiding (stringLiteral)
20import Idris.CmdOptions
20import Idris.CmdOptions
21
21
22+import Idris.Package.Common
23+
22import Control.Monad.State.Strict
24import Control.Monad.State.Strict
23import Control.Applicative
25import Control.Applicative
24import System.FilePath (takeFileName, isValid)
26import System.FilePath (takeFileName, isValid)
@@ -29,35 +31,6 @@ import Util.System
29
31
30type PParser = StateT PkgDesc IdrisInnerParser
32type PParser = StateT PkgDesc IdrisInnerParser
31
33
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−
61instance HasLastTokenSpan PParser where
34instance HasLastTokenSpan PParser where
62 getLastTokenSpan = return Nothing
35 getLastTokenSpan = return Nothing
63
36