Commit cc931709 authored by ijones's avatar ijones
Browse files

Added basic Setup.hs

Added basic Setup.hs functionality.  Caused a lot of imports, and
cleanup of some modules.  Derived show in various places.

Many dummy functions with "FIX".  Should implement some unit tests
next.
parent f9124285
......@@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Build where
import Distribution.Package(PackageConfig)
import Distribution.Misc(Compiler)
import Distribution.Misc(LocalBuildInfo)
build :: PackageConfig -> Compiler -> IO ()
build :: PackageConfig -> LocalBuildInfo -> IO ()
build _ _ = return ()
......@@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Install(install) where
import Distribution.Package(PackageConfig)
import Distribution.Misc(Compiler)
import Distribution.Misc(LocalBuildInfo)
install :: PackageConfig -> Compiler -> IO ()
install :: PackageConfig -> LocalBuildInfo -> IO ()
install _ _ = return ()
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Compiler
-- Module : Distribution.Misc
-- Copyright : Isaac Jones 2003-2004
--
-- Maintainer : Isaac Jones <ijones@syntaxpolice.org>
......@@ -41,7 +41,10 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Misc(Compiler, License, Dependency, Extension, Opt)
module Distribution.Misc(Compiler, License(..), Dependency,
Extension, Opt, LocalBuildInfo,
Action(..), CommandLineOpts,
writePersistBuildConfig, getPersistBuildConfig)
where
import Distribution.Version(VersionRange)
......@@ -51,11 +54,51 @@ import Distribution.Version(VersionRange)
-- ------------------------------------------------------------
data Flavor = GHC | NHC | Hugs | HBC | Helium | OtherCompiler String
deriving Show
data Compiler = Compiler {flavor :: Compiler,
data Compiler = Compiler {flavor :: Flavor,
path :: FilePath,
packagingTool :: FilePath}
deriving Show
emptyCompiler :: Compiler
emptyCompiler = Compiler (OtherCompiler "") "" ""
-- ------------------------------------------------------------
-- * Command-Line
-- ------------------------------------------------------------
type CommandLineOpts = (Action,
[String]) -- The un-parsed remainder
data Action = ConfigCmd LocalBuildInfo
| BuildCmd
| InstallCmd
| SDistCmd
| PackageInfoCmd
| UseInfoCmd
| TestCmd
-- | Register
-- | BDist
-- ------------------------------------------------------------
-- * build config
-- ------------------------------------------------------------
-- |Data cached after configuration step.
data LocalBuildInfo = LocalBuildInfo {prefix :: String,
compiler :: Compiler}
emptyLocalBuildInfo :: LocalBuildInfo
emptyLocalBuildInfo = LocalBuildInfo "" emptyCompiler
getPersistBuildConfig :: IO LocalBuildInfo
getPersistBuildConfig = return emptyLocalBuildInfo -- FIX
writePersistBuildConfig :: LocalBuildInfo -> IO ()
writePersistBuildConfig _ = return () --FIX
-- ------------------------------------------------------------
-- * Misc
......@@ -72,6 +115,6 @@ data Dependency = Dependency String VersionRange
-- |This represents non-standard compiler extensions which each
-- package might employ. Not yet implemented.
data Extension = Foo | Bar
data Extension = Foo | Bar deriving Show
type Opt = String
......@@ -60,6 +60,7 @@ data PackageDescription
copyright :: String,
maintainer :: String,
stability :: String}
deriving Show
data PackageConfig
= PackageConfig {packageDescription :: PackageDescription,
......@@ -72,3 +73,4 @@ data PackageConfig
includes :: [ FilePath ],
options :: [ (Compiler, [String]) ]
}
deriving Show
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Setup
-- Copyright : Isaac Jones 2003-2004
--
-- Maintainer : Isaac Jones <ijones@syntaxpolice.org>
-- Stability : alpha
-- Portability :
--
-- Explanation: <FIX>
-- WHERE DOES THIS MODULE FIT IN AT A HIGH-LEVEL <FIX>
{- Copyright (c) 2003-2004, Isaac Jones
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Isaac Jones nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Setup (parseArgs, defaultMain) where
-- Base
import System(getArgs)
-- Local
import Distribution.Build(build)
import Distribution.Install(install)
import Distribution.Misc(CommandLineOpts(..), Action(..),
LocalBuildInfo, getPersistBuildConfig)
import Distribution.Package(PackageConfig)
-- |Reads local build info, executes function
doBuildInstall :: (PackageConfig -> LocalBuildInfo -> IO ()) -- ^function to apply
-> PackageConfig
-> IO ()
doBuildInstall f pkgConf
= do lbi <- getPersistBuildConfig
f pkgConf lbi
-- |Parse the standard command-line arguments
parseArgs :: [String] -> CommandLineOpts
parseArgs _ = (BuildCmd, [])
defaultMain :: PackageConfig -> IO ()
defaultMain p
= do args <- getArgs
case parseArgs args of
(BuildCmd, _) -> doBuildInstall build p
(InstallCmd, _) -> doBuildInstall install p
(PackageInfoCmd, _) -> print p
return ()
\ No newline at end of file
......@@ -2,8 +2,9 @@
module Distribution.UseConfig where
import Distribution.Misc(License, Dependency, Opt)
import Distribution.Package(PackageIdentifier)
import Distribution.Misc(License(..), Dependency, Opt, LocalBuildInfo)
import Distribution.Package(PackageIdentifier(..), PackageConfig)
import Distribution.Version(Version(NoVersion))
data UseConfig
= UseConfig {
......@@ -13,14 +14,6 @@ data UseConfig
maintainer :: String,
stability :: String,
auto :: Bool,
-- provides :: [String],
{- A bit pi-in-the-sky; might indicate that this package provides
functionality that other packages also provide, such as a compiler
or GUI framework, and upon which other packages might depend. -}
-- isDefault :: Bool,
-- might indicate if this is the default compiler or GUI framework.
importDirs :: [FilePath],
sourceDirs :: [FilePath],
libraryDirs :: [FilePath],
......@@ -35,3 +28,11 @@ data UseConfig
frameworkDirs :: [FilePath],
extraFrameworks:: [String]}
deriving (Read, Show)
emptyUseConfig :: UseConfig
emptyUseConfig = UseConfig (PackageIdentifier "" NoVersion)
AllRightsReserved "" "" "" False [] [] [] [] [] []
[] [] [] [] [] [] []
getUseInfo :: LocalBuildInfo -> PackageConfig -> UseConfig
getUseInfo _ _ = emptyUseConfig -- FIX
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