Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
54b6fb35
Commit
54b6fb35
authored
May 21, 2004
by
simonmar
Browse files
Add stubs for all commands, various other updates
parent
84f2cd75
Changes
10
Hide whitespace changes
Inline
Side-by-side
Distribution/InstalledPackageInfo.hs
View file @
54b6fb35
-----------------------------------------------------------------------------
-- |
-- 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...
module
Distribution.InstalledPackageInfo
where
module
Distribution.InstalledPackageInfo
(
InstalledPackageInfo
(
..
),
emptyInstalledPackageInfo
)
where
import
Distribution.Misc
(
License
(
..
),
Dependency
,
Opt
)
import
Distribution.Package
(
PackageIdentifier
(
..
)
,
PackageConfig
)
import
Distribution.Package
(
PackageIdentifier
(
..
))
data
InstalledPackageInfo
=
InstalledPackageInfo
{
...
...
Distribution/Package.hs
View file @
54b6fb35
...
...
@@ -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
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module
Distribution.Package
(
PackageIdentifier
(
..
),
PackageConfig
(
..
))
where
module
Distribution.Package
(
PackageIdentifier
(
..
),
PackageDescription
(
..
),
emptyPackageDescription
)
where
import
Distribution.Version
(
Version
)
import
Distribution.Misc
(
License
,
Dependency
,
Extension
)
import
Distribution.Misc
(
License
(
..
)
,
Dependency
,
Extension
)
import
Distribution.Setup
(
CompilerFlavor
)
data
PackageIdentifier
=
PackageIdentifier
{
pkgName
::
String
,
pkgVersion
::
Version
}
deriving
(
Read
,
Show
,
Eq
)
data
PackageConfig
=
PackageConfig
{
package
::
PackageIdentifier
,
licenese
::
License
,
copyright
::
String
,
maintainer
::
String
,
stability
::
String
,
buildDepends
::
[
Dependency
],
sources
::
[
FilePath
],
extensions
::
[
Extension
],
library
::
String
,
-- library name
extraLibs
::
[
String
],
includeDirs
::
[
FilePath
],
includes
::
[
FilePath
],
options
::
[
(
CompilerFlavor
,
[
String
])
]
-- | This data type is the internal representation of the file @pkg.descr@.
-- It contains two kinds of information about the package: information
-- which is needed for all packages, such as the package name and version, and
-- information which is needed for the simple build system only, such as
-- the compiler options and library name.
--
data
PackageDescription
=
PackageDescription
{
-- the following are required by all packages:
package
::
PackageIdentifier
,
licenese
::
License
,
copyright
::
String
,
maintainer
::
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
Distribution/Simple.hs
View file @
54b6fb35
...
...
@@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module
Distribution.Simple
(
module
Distribution
.
Package
,
License
(
..
),
Version
(
..
),
defaultMain
,
emptyPackageConfig
,
defaultMain
,
)
where
-- Base
...
...
@@ -53,7 +53,10 @@ import System(getArgs)
import
Distribution.Package
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
,
configure
,
writePersistBuildConfig
)
import
Distribution.Simple.Install
(
install
)
...
...
@@ -66,52 +69,57 @@ import Control.Monad ( when )
import
Data.List
(
intersperse
)
-- |Reads local build info, executes function
doBuildInstall
::
(
Package
Config
->
LocalBuildInfo
->
IO
()
)
-- ^function to apply
->
Package
Config
doBuildInstall
::
(
Package
Description
->
LocalBuildInfo
->
IO
()
)
-- ^function to apply
->
Package
Description
->
IO
()
doBuildInstall
f
pkgConf
=
do
lbi
<-
getPersistBuildConfig
f
pkgConf
lbi
defaultMain
::
Package
Config
->
IO
()
defaultMain
pkg
config
defaultMain
::
Package
Description
->
IO
()
defaultMain
pkg
_descr
=
do
args
<-
getArgs
case
parseArgs
args
of
Right
(
HelpCmd
,
_
)
->
hPutStr
stderr
(
optionHelpString
helpprefix
)
Right
(
ConfigCmd
flags
,
extra_flags
)
->
do
when
(
not
(
null
extra_flags
))
$
do
die
(
"Unrecognised flags: "
++
concat
(
intersperse
","
(
extra_flags
)))
localbuildinfo
<-
configure
pkgconfig
flags
no_extra_flags
extra_flags
localbuildinfo
<-
configure
pkg_descr
flags
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
hPutStr
stderr
(
unlines
err
)
hPutStr
stderr
(
optionHelpString
helpprefix
)
-- (BuildCmd, _) -> doBuildInstall build p
-- (InstallCmd _, _) -> doBuildInstall install p
_other
->
die
"unimplemented command
\n
"
return
()
emptyPackageConfig
::
PackageConfig
emptyPackageConfig
=
PackageConfig
{
package
=
undefined
,
licenese
=
AllRightsReserved
,
copyright
=
""
,
maintainer
=
""
,
stability
=
""
,
buildDepends
=
[]
,
sources
=
[]
,
extensions
=
[]
,
library
=
""
,
extraLibs
=
[]
,
includeDirs
=
[]
,
includes
=
[]
,
options
=
[]
}
no_extra_flags
[]
=
return
()
no_extra_flags
extra_flags
=
die
(
"Unrecognised flags: "
++
concat
(
intersperse
","
(
extra_flags
)))
helpprefix
::
String
helpprefix
=
"Syntax: ./Setup.hs command [flags]
\n
"
Distribution/Simple/Build.hs
View file @
54b6fb35
...
...
@@ -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
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
(
Package
Config
)
import
Distribution.Package
(
Package
Description
)
import
Distribution.Simple.Configure
(
LocalBuildInfo
)
build
::
PackageConfig
->
LocalBuildInfo
->
IO
()
build
_
_
=
return
()
import
System.IO
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
Distribution/Simple/Configure.hs
View file @
54b6fb35
...
...
@@ -49,14 +49,16 @@ module Distribution.Simple.Configure (writePersistBuildConfig,
where
import
Distribution.Setup
(
ConfigFlags
,
CompilerFlavor
(
..
),
Compiler
(
..
))
import
Distribution.Package
(
Package
Config
(
..
))
import
Distribution.Package
(
Package
Description
(
..
))
import
Distribution.Simple.Utils
(
splitFilenameDir
,
die
,
split
)
import
System.IO
import
System.IO
hiding
(
catch
)
import
System.Exit
import
System.Directory
import
System.Environment
(
getEnv
)
import
Control.Monad
(
when
)
import
Control.Exception
(
catch
,
evaluate
)
import
Prelude
hiding
(
catch
)
#
ifdef
DEBUG
import
HUnit
...
...
@@ -73,7 +75,10 @@ emptyLocalBuildInfo = undefined
getPersistBuildConfig
::
IO
LocalBuildInfo
getPersistBuildConfig
=
do
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
lbi
=
do
...
...
@@ -85,7 +90,7 @@ localBuildInfoFile = "./.setup-config"
-- -----------------------------------------------------------------------------
-- Configuration
configure
::
Package
Config
->
ConfigFlags
->
IO
LocalBuildInfo
configure
::
Package
Description
->
ConfigFlags
->
IO
LocalBuildInfo
configure
pkgconfig
(
maybe_hc_flavor
,
maybe_hc_path
,
maybe_prefix
)
=
do
-- prefix
...
...
@@ -101,7 +106,7 @@ configure pkgconfig (maybe_hc_flavor, maybe_hc_path, maybe_prefix)
message
$
"Using package tool: "
++
pkg
return
LocalBuildInfo
{
prefix
=
prefix
,
compiler
=
compiler
}
system_default_prefix
Package
Config
{
package
=
package
}
=
system_default_prefix
Package
Description
{
package
=
package
}
=
#
ifdef
mingw32_TARGET_OS
"C:
\
P
r
ogram Files
\"
++ pkgName package
#else
...
...
@@ -111,7 +116,7 @@ system_default_prefix PackageConfig{package=package} =
-- -----------------------------------------------------------------------------
-- Determining the compiler details
configCompiler :: Maybe CompilerFlavor -> Maybe FilePath -> Package
Config
configCompiler :: Maybe CompilerFlavor -> Maybe FilePath -> Package
Description
-> IO Compiler
configCompiler (Just flavor) (Just path) pkgconfig
...
...
@@ -195,7 +200,7 @@ message s = putStrLn $ "configure: " ++ s
hunitTests :: IO [Test]
hunitTests = do
let simonMarGHCLoc = "
/
home
/
simonmar
/
fp
/
bin
/
i386
-
unknown
-
linux
/
ghc
"
simonMarGHC <- configure Package
Config
{} (Just GHC,
simonMarGHC <- configure Package
Description
{} (Just GHC,
Just simonMarGHCLoc,
Nothing)
return $ [TestLabel "
Configure
Testing
" $ TestList [
...
...
Distribution/Simple/Install.hs
View file @
54b6fb35
...
...
@@ -43,8 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module
Distribution.Simple.Install
(
install
)
where
import
Distribution.Package
(
Package
Config
)
import
Distribution.Package
(
Package
Description
)
import
Distribution.Simple.Configure
(
LocalBuildInfo
)
install
::
Package
Config
->
LocalBuildInfo
->
IO
()
install
::
Package
Description
->
LocalBuildInfo
->
IO
()
install
_
_
=
return
()
Distribution/Simple/Register.hs
View file @
54b6fb35
...
...
@@ -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
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.Package
(
Package
Config
)
import
Distribution.Package
(
Package
Description
)
import
Distribution.InstalledPackageInfo
(
InstalledPackageInfo
)
getUseInfo
::
LocalBuildInfo
->
PackageConfig
->
InstalledPackageInfo
getUseInfo
_
_
=
undefined
import
System.IO
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
)
Distribution/Simple/SrcDist.hs
0 → 100644
View file @
54b6fb35
-----------------------------------------------------------------------------
-- |
-- 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
)
Distribution/TODO
View file @
54b6fb35
* Documentation
** Integrate SimonPJ's document into the "proposal" (simonpj)
** x-pkg command-line interface
* Code
** parse pkg.desc
** build
** install
** register
** generate InstalledPackageInfo
** read & write config-droppings
** configure: check for presence of build dependencies
* later todo
** writePersistBuildConfig robustify + diagnostics
** command-line parsing errors
** elaborate command-line help text
* Testing
...
...
test/Setup.hs
View file @
54b6fb35
...
...
@@ -2,8 +2,10 @@ module Main where
import
Distribution.Simple
pkgconfig
=
emptyPackageConfig
{
package
=
PackageIdentifier
"test"
(
Version
[
1
,
0
]
[]
)
pkg_descr
=
emptyPackageDescription
{
package
=
PackageIdentifier
"test"
(
Version
[
1
,
0
]
[]
),
allModules
=
[
"A"
],
exposedModules
=
[
"A"
]
}
main
=
defaultMain
pkg
config
main
=
defaultMain
pkg
_descr
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment