Commit 91398426 authored by ijones's avatar ijones
Browse files

added basic package description parsing (using read / show)

** HUnit and Cabal use the Setup.description file
** A works like it did before, but uses 'defaultMainNoRead'
parent d1286d6b
......@@ -74,7 +74,7 @@ data Extension =
OverlappingInstances
| TypeSynonymInstances
| TemplateHaskell
deriving Show
deriving (Show, Read)
type Opt = String
......
......@@ -47,6 +47,7 @@ module Distribution.Package (
showPackageId,
PackageDescription(..),
emptyPackageDescription,
parsePackageDesc,
#ifdef DEBUG
hunitTests
#endif
......@@ -56,6 +57,8 @@ import Distribution.Version(Version(..), showVersion)
import Distribution.Misc(License(..), Dependency, Extension)
import Distribution.Setup(CompilerFlavor)
import System.IO(openFile, IOMode(..), hGetContents)
#ifdef DEBUG
import HUnit (Test)
#endif
......@@ -97,7 +100,7 @@ data PackageDescription
includes :: [ FilePath ],
options :: [ (CompilerFlavor, [String]) ]
}
deriving (Show)
deriving (Show, Read)
emptyPackageDescription :: PackageDescription
emptyPackageDescription
......@@ -118,6 +121,12 @@ emptyPackageDescription
includes = [],
options = []
}
-- |Parse the given package file. FIX: don't use read / show.
parsePackageDesc :: FilePath -> IO PackageDescription
parsePackageDesc p
= openFile p ReadMode >>= hGetContents >>= return . read
-- ------------------------------------------------------------
-- * Testing
-- ------------------------------------------------------------
......
......@@ -47,7 +47,7 @@ module Distribution.Simple (
License(..), Version(..), VersionRange(..),
orLaterVersion, orEarlierVersion, betweenVersionsInclusive,
Extension(..), Dependency(..),
defaultMain,
defaultMain, defaultMainNoRead,
#ifdef DEBUG
simpleHunitTests
#endif
......@@ -82,6 +82,9 @@ import System.IO (hPutStr, stderr)
import HUnit (Test)
#endif
defaultPackageDesc :: FilePath
defaultPackageDesc = "Setup.description"
-- |Reads local build info, executes function
doBuildInstall :: (PackageDescription -> LocalBuildInfo -> IO ()) -- ^function to apply
-> PackageDescription
......@@ -90,8 +93,11 @@ doBuildInstall f pkgConf
= do lbi <- getPersistBuildConfig
f pkgConf lbi
defaultMain :: PackageDescription -> IO ()
defaultMain pkg_descr
defaultMain :: IO ()
defaultMain = parsePackageDesc defaultPackageDesc >>= defaultMainNoRead
defaultMainNoRead :: PackageDescription -> IO ()
defaultMainNoRead pkg_descr
= do args <- getArgs
let distPref = "dist"
let buildPref = pathJoin [distPref, "build"]
......
* misc
** make a library from the FileUtils, look at Python's os.path.
** add en.wikipedia.org/wiki/Cabal to web page
** clean up ~/.ghc-packages location...
** Possibly create a (native?) zib library?
** port code to windows
** ./Setup.lhs build for nhc
......
......@@ -55,14 +55,13 @@ moduleTest:
tests: moduleTest
cd test/A && make
check: tests main
check: tests
./moduleTest
# distribution...
pushall:
darcs push --all ijones@monk.syntaxpolice.org:/home/ijones/public_html/darcs_repos/library-infrastructure
darcs push --all ijones@cvs.haskell.org:/home/ijones/library-infrastructure
darcs push --all ijones@cvs.haskell.org:/home/darcs/cabal
dist: pushall
darcs dist
......
PackageDescription {package = PackageIdentifier {pkgName = "Cabal",
pkgVersion = Version {versionBranch = [0,1],
versionTags = []}},
license = AllRightsReserved,
copyright = "",
maintainer = "",
stability = "",
buildDepends = [Dependency "haskell-src" AnyVersion,
Dependency "HUnit-1.0" AnyVersion],
allModules = ["Distribution.Package","Distribution.Version",
"Distribution.Misc","Distribution.Setup",
"Distribution.InstalledPackageInfo",
"Distribution.Make","Distribution.Simple",
"Distribution.Simple.Build",
"Distribution.Simple.Install","Distribution.Simple.SrcDist",
"Distribution.Simple.Configure","Distribution.Simple.Utils",
"Distribution.Simple.Register",
"Distribution.Simple.GHCPackageConfig",
"Distribution.GetOpt"],
mainModules = [],
cSources = [],
hsSourceDir = ".",
exposedModules = [],
extensions = [],
extraLibs = [],
includeDirs = [],
includes = [],
options = []
}
......@@ -14,7 +14,7 @@
> "Distribution.Make",
>
> "Distribution.Simple",
> "Distribution/Simple.Build",
> "Distribution.Simple.Build",
> "Distribution.Simple.Install",
> "Distribution.Simple.SrcDist",
> "Distribution.Simple.Configure",
......@@ -29,4 +29,4 @@
> }
> main :: IO ()
> main = do defaultMain pkg_descr
> main = defaultMain
......@@ -8,4 +8,4 @@ pkg_descr = emptyPackageDescription {
exposedModules = ["A"]
}
main = defaultMain pkg_descr
main = defaultMainNoRead pkg_descr
PackageDescription {package = PackageIdentifier
{pkgName = "HUnit",
pkgVersion = Version {versionBranch = [1,0],
versionTags = []}},
license = AllRightsReserved,
copyright = "",
maintainer = "",
stability = "",
buildDepends = [Dependency "haskell-src" AnyVersion],
allModules = ["HUnitText","HUnit","HUnitLang","HUnitTestBase",
"Terminal","HUnitBase"],
mainModules = [],
cSources = [],
hsSourceDir = "src",
exposedModules = ["HUnit"],
extensions = [],
extraLibs = [],
includeDirs = [],
includes = [],
options = []
}
......@@ -4,14 +4,5 @@
> import Distribution.Simple
> pkg_descr = emptyPackageDescription {
> package = PackageIdentifier "HUnit" (Version [1,0] []),
> allModules = ["HUnitText", "HUnit", "HUnitLang",
> "HUnitTestBase", "Terminal", "HUnitBase"],
> exposedModules = ["HUnit"],
> buildDepends = [Dependency "haskell-src" AnyVersion],
> hsSourceDir = "src"
> }
> main :: IO ()
> main = do defaultMain pkg_descr
> main = defaultMain
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment