Commit 54b6fb35 authored by simonmar's avatar simonmar
Browse files

Add stubs for all commands, various other updates

parent 84f2cd75
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.InstalledPackageInfo
-- Copyright : (c) The University of Glasgow 2004
--
-- Maintainer : libraries@haskell.org
-- Stability : alpha
-- Portability : portable
--
-- Explanation: <FIX>
-- WHERE DOES THIS MODULE FIT IN AT A HIGH-LEVEL <FIX>
{- Copyright (c) 2004, The University of Glasgow
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 the University 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. -}
-- This module is meant to be local-only to Distribution... -- This module is meant to be local-only to Distribution...
module Distribution.InstalledPackageInfo where module Distribution.InstalledPackageInfo (
InstalledPackageInfo(..),
emptyInstalledPackageInfo
) where
import Distribution.Misc(License(..), Dependency, Opt) import Distribution.Misc(License(..), Dependency, Opt)
import Distribution.Package(PackageIdentifier(..), PackageConfig) import Distribution.Package(PackageIdentifier(..))
data InstalledPackageInfo data InstalledPackageInfo
= InstalledPackageInfo { = InstalledPackageInfo {
......
...@@ -41,32 +41,62 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ...@@ -41,32 +41,62 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -} OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Package(PackageIdentifier(..), module Distribution.Package (
PackageConfig(..)) PackageIdentifier(..),
PackageDescription(..),
where emptyPackageDescription
) where
import Distribution.Version(Version) import Distribution.Version(Version)
import Distribution.Misc(License, Dependency, Extension) import Distribution.Misc(License(..), Dependency, Extension)
import Distribution.Setup(CompilerFlavor) import Distribution.Setup(CompilerFlavor)
data PackageIdentifier data PackageIdentifier
= PackageIdentifier {pkgName::String, pkgVersion::Version} = PackageIdentifier {pkgName::String, pkgVersion::Version}
deriving (Read, Show, Eq) deriving (Read, Show, Eq)
data PackageConfig -- | This data type is the internal representation of the file @pkg.descr@.
= PackageConfig {package :: PackageIdentifier, -- It contains two kinds of information about the package: information
licenese :: License, -- which is needed for all packages, such as the package name and version, and
copyright :: String, -- information which is needed for the simple build system only, such as
maintainer :: String, -- the compiler options and library name.
stability :: String, --
buildDepends :: [ Dependency ], data PackageDescription
sources :: [ FilePath ], = PackageDescription {
extensions :: [ Extension ], -- the following are required by all packages:
library :: String, -- library name package :: PackageIdentifier,
extraLibs :: [ String ], licenese :: License,
includeDirs :: [ FilePath ], copyright :: String,
includes :: [ FilePath ], maintainer :: String,
options :: [ (CompilerFlavor, [String]) ] stability :: String,
-- the following are required by the simple build infrastructure only:
buildDepends :: [ Dependency ],
allModules :: [ String ],
exposedModules :: [ String ],
extensions :: [ Extension ],
library :: String, -- library name
extraLibs :: [ String ],
includeDirs :: [ FilePath ],
includes :: [ FilePath ],
options :: [ (CompilerFlavor, [String]) ]
}
deriving (Show)
emptyPackageDescription :: PackageDescription
emptyPackageDescription
= PackageDescription {package = undefined,
licenese = AllRightsReserved,
copyright = "",
maintainer = "",
stability = "",
buildDepends = [],
allModules = [],
exposedModules = [],
extensions = [],
library = "",
extraLibs = [],
includeDirs = [],
includes = [],
options = []
} }
deriving Show
...@@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -} ...@@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Simple ( module Distribution.Simple (
module Distribution.Package, module Distribution.Package,
License(..), Version(..), License(..), Version(..),
defaultMain, emptyPackageConfig, defaultMain,
) where ) where
-- Base -- Base
...@@ -53,7 +53,10 @@ import System(getArgs) ...@@ -53,7 +53,10 @@ import System(getArgs)
import Distribution.Package import Distribution.Package
import Distribution.Setup(parseArgs, Action(..), optionHelpString) import Distribution.Setup(parseArgs, Action(..), optionHelpString)
import Distribution.Simple.Build(build) import Distribution.Simple.Build ( build )
import Distribution.Simple.SrcDist ( sdist )
import Distribution.Simple.Register ( register, unregister )
import Distribution.Simple.Configure(LocalBuildInfo(..), getPersistBuildConfig, import Distribution.Simple.Configure(LocalBuildInfo(..), getPersistBuildConfig,
configure, writePersistBuildConfig) configure, writePersistBuildConfig)
import Distribution.Simple.Install(install) import Distribution.Simple.Install(install)
...@@ -66,52 +69,57 @@ import Control.Monad ( when ) ...@@ -66,52 +69,57 @@ import Control.Monad ( when )
import Data.List ( intersperse ) import Data.List ( intersperse )
-- |Reads local build info, executes function -- |Reads local build info, executes function
doBuildInstall :: (PackageConfig -> LocalBuildInfo -> IO ()) -- ^function to apply doBuildInstall :: (PackageDescription -> LocalBuildInfo -> IO ()) -- ^function to apply
-> PackageConfig -> PackageDescription
-> IO () -> IO ()
doBuildInstall f pkgConf doBuildInstall f pkgConf
= do lbi <- getPersistBuildConfig = do lbi <- getPersistBuildConfig
f pkgConf lbi f pkgConf lbi
defaultMain :: PackageConfig -> IO () defaultMain :: PackageDescription -> IO ()
defaultMain pkgconfig defaultMain pkg_descr
= do args <- getArgs = do args <- getArgs
case parseArgs args of case parseArgs args of
Right (HelpCmd, _) -> hPutStr stderr (optionHelpString helpprefix) Right (HelpCmd, _) -> hPutStr stderr (optionHelpString helpprefix)
Right (ConfigCmd flags, extra_flags) -> do Right (ConfigCmd flags, extra_flags) -> do
when (not (null extra_flags)) $ do no_extra_flags extra_flags
die ("Unrecognised flags: " ++ localbuildinfo <- configure pkg_descr flags
concat (intersperse "," (extra_flags)))
localbuildinfo <- configure pkgconfig flags
writePersistBuildConfig localbuildinfo writePersistBuildConfig localbuildinfo
Right (BuildCmd, extra_flags) -> do
no_extra_flags extra_flags
localbuildinfo <- getPersistBuildConfig
build pkg_descr localbuildinfo
Right (InstallCmd maybe_install_prefix, extra_flags) -> do
no_extra_flags extra_flags
localbuildinfo <- getPersistBuildConfig
install pkg_descr localbuildinfo
Right (SDistCmd, extra_flags) -> do
no_extra_flags extra_flags
localbuildinfo <- getPersistBuildConfig
sdist pkg_descr localbuildinfo
Right (RegisterCmd, extra_flags) -> do
no_extra_flags extra_flags
localbuildinfo <- getPersistBuildConfig
register pkg_descr localbuildinfo
Right (UnregisterCmd, extra_flags) -> do
no_extra_flags extra_flags
localbuildinfo <- getPersistBuildConfig
unregister pkg_descr localbuildinfo
Left err -> do Left err -> do
hPutStr stderr (unlines err) hPutStr stderr (unlines err)
hPutStr stderr (optionHelpString helpprefix) hPutStr stderr (optionHelpString helpprefix)
-- (BuildCmd, _) -> doBuildInstall build p
-- (InstallCmd _, _) -> doBuildInstall install p
_other -> die "unimplemented command\n"
return () return ()
emptyPackageConfig :: PackageConfig no_extra_flags [] = return ()
emptyPackageConfig no_extra_flags extra_flags =
= PackageConfig {package = undefined, die ("Unrecognised flags: " ++ concat (intersperse "," (extra_flags)))
licenese = AllRightsReserved,
copyright = "",
maintainer = "",
stability = "",
buildDepends = [],
sources = [],
extensions = [],
library = "",
extraLibs = [],
includeDirs = [],
includes = [],
options = []
}
helpprefix :: String helpprefix :: String
helpprefix = "Syntax: ./Setup.hs command [flags]\n" helpprefix = "Syntax: ./Setup.hs command [flags]\n"
...@@ -39,10 +39,22 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ...@@ -39,10 +39,22 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -} OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Simple.Build where module Distribution.Simple.Build (
build
) where
import Distribution.Package(PackageConfig) import Distribution.Package(PackageDescription)
import Distribution.Simple.Configure(LocalBuildInfo) import Distribution.Simple.Configure(LocalBuildInfo)
build :: PackageConfig -> LocalBuildInfo -> IO () import System.IO
build _ _ = return () import System.Exit
build :: PackageDescription -> LocalBuildInfo -> IO ()
build pkg_descr lbi = do
hPutStrLn stderr "ToDo: building..."
exitWith (ExitFailure 1)
-- construct ghc --make command line
-- run it
-- build a library
...@@ -49,14 +49,16 @@ module Distribution.Simple.Configure (writePersistBuildConfig, ...@@ -49,14 +49,16 @@ module Distribution.Simple.Configure (writePersistBuildConfig,
where where
import Distribution.Setup(ConfigFlags,CompilerFlavor(..), Compiler(..)) import Distribution.Setup(ConfigFlags,CompilerFlavor(..), Compiler(..))
import Distribution.Package(PackageConfig(..)) import Distribution.Package(PackageDescription(..))
import Distribution.Simple.Utils (splitFilenameDir, die, split) import Distribution.Simple.Utils (splitFilenameDir, die, split)
import System.IO import System.IO hiding (catch)
import System.Exit import System.Exit
import System.Directory import System.Directory
import System.Environment ( getEnv ) import System.Environment ( getEnv )
import Control.Monad ( when ) import Control.Monad ( when )
import Control.Exception ( catch, evaluate )
import Prelude hiding (catch)
#ifdef DEBUG #ifdef DEBUG
import HUnit import HUnit
...@@ -73,7 +75,10 @@ emptyLocalBuildInfo = undefined ...@@ -73,7 +75,10 @@ emptyLocalBuildInfo = undefined
getPersistBuildConfig :: IO LocalBuildInfo getPersistBuildConfig :: IO LocalBuildInfo
getPersistBuildConfig = do getPersistBuildConfig = do
str <- readFile localBuildInfoFile str <- readFile localBuildInfoFile
return (read str) let bi = read str
evaluate bi `catch` \e ->
die "error reading .setup-config; perhaps run ./Setup.lhs configure?"
return bi
writePersistBuildConfig :: LocalBuildInfo -> IO () writePersistBuildConfig :: LocalBuildInfo -> IO ()
writePersistBuildConfig lbi = do writePersistBuildConfig lbi = do
...@@ -85,7 +90,7 @@ localBuildInfoFile = "./.setup-config" ...@@ -85,7 +90,7 @@ localBuildInfoFile = "./.setup-config"
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- Configuration -- Configuration
configure :: PackageConfig -> ConfigFlags -> IO LocalBuildInfo configure :: PackageDescription -> ConfigFlags -> IO LocalBuildInfo
configure pkgconfig (maybe_hc_flavor, maybe_hc_path, maybe_prefix) configure pkgconfig (maybe_hc_flavor, maybe_hc_path, maybe_prefix)
= do = do
-- prefix -- prefix
...@@ -101,7 +106,7 @@ configure pkgconfig (maybe_hc_flavor, maybe_hc_path, maybe_prefix) ...@@ -101,7 +106,7 @@ configure pkgconfig (maybe_hc_flavor, maybe_hc_path, maybe_prefix)
message $ "Using package tool: " ++ pkg message $ "Using package tool: " ++ pkg
return LocalBuildInfo{prefix=prefix, compiler=compiler} return LocalBuildInfo{prefix=prefix, compiler=compiler}
system_default_prefix PackageConfig{package=package} = system_default_prefix PackageDescription{package=package} =
#ifdef mingw32_TARGET_OS #ifdef mingw32_TARGET_OS
"C:\Program Files\" ++ pkgName package "C:\Program Files\" ++ pkgName package
#else #else
...@@ -111,7 +116,7 @@ system_default_prefix PackageConfig{package=package} = ...@@ -111,7 +116,7 @@ system_default_prefix PackageConfig{package=package} =
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- Determining the compiler details -- Determining the compiler details
configCompiler :: Maybe CompilerFlavor -> Maybe FilePath -> PackageConfig configCompiler :: Maybe CompilerFlavor -> Maybe FilePath -> PackageDescription
-> IO Compiler -> IO Compiler
configCompiler (Just flavor) (Just path) pkgconfig configCompiler (Just flavor) (Just path) pkgconfig
...@@ -195,7 +200,7 @@ message s = putStrLn $ "configure: " ++ s ...@@ -195,7 +200,7 @@ message s = putStrLn $ "configure: " ++ s
hunitTests :: IO [Test] hunitTests :: IO [Test]
hunitTests = do hunitTests = do
let simonMarGHCLoc = "/home/simonmar/fp/bin/i386-unknown-linux/ghc" let simonMarGHCLoc = "/home/simonmar/fp/bin/i386-unknown-linux/ghc"
simonMarGHC <- configure PackageConfig{} (Just GHC, simonMarGHC <- configure PackageDescription{} (Just GHC,
Just simonMarGHCLoc, Just simonMarGHCLoc,
Nothing) Nothing)
return $ [TestLabel "Configure Testing" $ TestList [ return $ [TestLabel "Configure Testing" $ TestList [
......
...@@ -43,8 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -} ...@@ -43,8 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Simple.Install(install) where module Distribution.Simple.Install(install) where
import Distribution.Package(PackageConfig) import Distribution.Package(PackageDescription)
import Distribution.Simple.Configure(LocalBuildInfo) import Distribution.Simple.Configure(LocalBuildInfo)
install :: PackageConfig -> LocalBuildInfo -> IO () install :: PackageDescription -> LocalBuildInfo -> IO ()
install _ _ = return () install _ _ = return ()
...@@ -41,11 +41,24 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ...@@ -41,11 +41,24 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -} OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Simple.Register where module Distribution.Simple.Register (
register,
unregister,
) where
import Distribution.Simple.Configure(LocalBuildInfo) import Distribution.Simple.Configure(LocalBuildInfo)
import Distribution.Package(PackageConfig) import Distribution.Package(PackageDescription)
import Distribution.InstalledPackageInfo(InstalledPackageInfo) import Distribution.InstalledPackageInfo(InstalledPackageInfo)
getUseInfo :: LocalBuildInfo -> PackageConfig -> InstalledPackageInfo import System.IO
getUseInfo _ _ = undefined import System.Exit
register :: PackageDescription -> LocalBuildInfo -> IO ()
register pkg_descr lbi = do
hPutStrLn stderr "ToDo: registering..."
exitWith (ExitFailure 1)
unregister :: PackageDescription -> LocalBuildInfo -> IO ()
unregister pkg_descr lbi = do
hPutStrLn stderr "ToDo: unregistering..."
exitWith (ExitFailure 1)
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Simple.SrcDist
-- Copyright : Simon Marlow 2004
--
-- Maintainer : Isaac Jones <ijones@syntaxpolice.org>
-- Stability : alpha
-- Portability :
--
{- Copyright (c) 2003-2004, Simon Marlow
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.Simple.SrcDist (
sdist
) where
import Distribution.Package(PackageDescription)
import Distribution.Simple.Configure(LocalBuildInfo)
import System.IO
import System.Exit
sdist :: PackageDescription -> LocalBuildInfo -> IO ()
sdist pkg_descr lbi = do
hPutStrLn stderr "ToDo: sdisting..."
exitWith (ExitFailure 1)
* Documentation
** Integrate SimonPJ's document into the "proposal" (simonpj)
** x-pkg command-line interface
* Code * Code
** parse pkg.desc
** build ** build
** install ** install
** register ** register
** generate InstalledPackageInfo ** generate InstalledPackageInfo
** read & write config-droppings ** read & write config-droppings
** configure: check for presence of build dependencies
* later todo * later todo
** writePersistBuildConfig robustify + diagnostics ** writePersistBuildConfig robustify + diagnostics
** command-line parsing errors
** elaborate command-line help text ** elaborate command-line help text
* Testing * Testing
......
...@@ -2,8 +2,10 @@ module Main where ...@@ -2,8 +2,10 @@ module Main where
import Distribution.Simple import Distribution.Simple
pkgconfig = emptyPackageConfig { pkg_descr = emptyPackageDescription {
package = PackageIdentifier "test" (Version [1,0] []) package = PackageIdentifier "test" (Version [1,0] []),
allModules = ["A"],
exposedModules = ["A"]
} }
main = defaultMain pkgconfig main = defaultMain pkg_descr
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