Skip to content

Commit

Permalink
cvs pull from ross
Browse files Browse the repository at this point in the history
  add flags arguments to post-hooks, and have defaultUserHooks use postConf
  instead of preConf.

  changes to package description fields, as discussed on the libraries list:
  
  * allow both License and License-File, which now correspond to different
    fields of Package Description.
  
  * add Synopsis.
  
  * rename Hidden-Modules as Other-Modules.
  • Loading branch information
SyntaxPolice committed Feb 11, 2005
1 parent 365705a commit 409b725
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 130 deletions.
3 changes: 2 additions & 1 deletion Cabal.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ License: BSD3
Author: Isaac Jones <ijones@syntaxpolice.org>
Maintainer: Isaac Jones <ijones@syntaxpolice.org>
Homepage: http://www.haskell.org/cabal/
Synopsis: A framework for packaging Haskell software
Description:
The Haskell Common Architecture for Building Applications and
Libraries: a framework defining a common interface for authors to more
Expand Down Expand Up @@ -37,7 +38,7 @@ Exposed-Modules:
Distribution.Simple.SrcDist,
Distribution.Simple.Utils,
Distribution.Version
Hidden-Modules:
Other-Modules:
Distribution.GetOpt,
Distribution.Compat.Directory,
Distribution.Compat.Exception,
Expand Down
9 changes: 4 additions & 5 deletions Distribution/InstalledPackageInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ module Distribution.InstalledPackageInfo (
) where

import Distribution.ParseUtils (
StanzaField(..), singleStanza, ParseResult,
simpleField, listField, licenseField,
StanzaField(..), singleStanza, ParseResult(..),
simpleField, listField, parseLicenseQ,
parseFilePathQ, parseLibNameQ, parseModuleNameQ, parsePackageNameQ,
showFilePath, parseReadS, parseOptVersion, parseQuoted,
showFreeText)
Expand Down Expand Up @@ -188,9 +188,8 @@ basicStanzaFields =
, simpleField "version"
(text . showVersion) parseOptVersion
(pkgVersion . package) (\ver pkg -> pkg{package=(package pkg){pkgVersion=ver}})
, licenseField "license" False
license (\l pkg -> pkg{license=l})
, licenseField "license-file" True
, simpleField "license"
(text . show) parseLicenseQ
license (\l pkg -> pkg{license=l})
, simpleField "copyright"
showFreeText (munch (const True))
Expand Down
3 changes: 1 addition & 2 deletions Distribution/License.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,5 @@ data License = GPL -- ^GNU Public License. Source code must accompany alteratio
| BSD4 -- ^4-clause BSD license, older, with advertising clause.
| PublicDomain -- ^Holder makes no claim to ownership, least restrictive license.
| AllRightsReserved -- ^No rights are granted to others. Undistributable. Most restrictive.
| {- ... | -} OtherLicense FilePath
-- ^Use another license by listing the relative path to your license file.
| {- ... | -} OtherLicense -- ^Some other license.
deriving (Read, Show, Eq)
49 changes: 30 additions & 19 deletions Distribution/PackageDescription.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ data PackageDescription
-- the following are required by all packages:
package :: PackageIdentifier,
license :: License,
licenseFile :: FilePath,
copyright :: String,
maintainer :: String,
author :: String,
stability :: String,
testedWith :: [(CompilerFlavor,VersionRange)],
homepage :: String,
pkgUrl :: String,
synopsis :: String,
description :: String,
category :: String,
buildDepends :: [Dependency],
Expand All @@ -138,6 +140,7 @@ emptyPackageDescription :: PackageDescription
emptyPackageDescription
= PackageDescription {package = PackageIdentifier "" (Version [] []),
license = AllRightsReserved,
licenseFile = "",
copyright = "",
maintainer = "",
author = "",
Expand All @@ -146,6 +149,7 @@ emptyPackageDescription
buildDepends = [],
homepage = "",
pkgUrl = "",
synopsis = "",
description = "",
category = "",
library = Nothing,
Expand All @@ -156,12 +160,12 @@ emptyPackageDescription
libModules :: PackageDescription -> [String]
libModules PackageDescription{library=lib}
= (maybe [] exposedModules lib)
++ (maybe [] (hiddenModules . libBuildInfo) lib)
++ (maybe [] (otherModules . libBuildInfo) lib)

-- |Get all the module names from the exes in this package
exeModules :: PackageDescription -> [String]
exeModules PackageDescription{executables=execs}
= concatMap (hiddenModules . buildInfo) execs
= concatMap (otherModules . buildInfo) execs

-- |does this package have any libraries?
hasLibs :: PackageDescription -> Bool
Expand All @@ -175,7 +179,7 @@ data BuildInfo = BuildInfo {
frameworks :: [String],
cSources :: [FilePath],
hsSourceDir :: FilePath,
hiddenModules :: [String],
otherModules :: [String],
extensions :: [Extension],
extraLibs :: [String],
extraLibDirs :: [String],
Expand All @@ -193,7 +197,7 @@ emptyBuildInfo = BuildInfo {
frameworks = [],
cSources = [],
hsSourceDir = currentDir,
hiddenModules = [],
otherModules = [],
extensions = [],
extraLibs = [],
extraLibDirs = [],
Expand Down Expand Up @@ -271,7 +275,7 @@ unionBuildInfo b1 b2
frameworks = combine frameworks,
cSources = combine cSources,
hsSourceDir = override hsSourceDir "hs-source-dir",
hiddenModules = combine hiddenModules,
otherModules = combine otherModules,
extensions = combine extensions,
extraLibs = combine extraLibs,
extraLibDirs = combine extraLibDirs,
Expand Down Expand Up @@ -307,10 +311,12 @@ basicStanzaFields =
, simpleField "version"
(text . showVersion) parseVersion
(pkgVersion . package) (\ver pkg -> pkg{package=(package pkg){pkgVersion=ver}})
, licenseField "license" False
license (\l pkg -> pkg{license=l})
, licenseField "license-file" True
, simpleField "license"
(text . show) parseLicenseQ
license (\l pkg -> pkg{license=l})
, simpleField "license-file"
showFilePath parseFilePathQ
licenseFile (\l pkg -> pkg{licenseFile=l})
, simpleField "copyright"
showFreeText (munch (const True))
copyright (\val pkg -> pkg{copyright=val})
Expand All @@ -329,6 +335,9 @@ basicStanzaFields =
, simpleField "package-url"
showFreeText (munch (const True))
pkgUrl (\val pkg -> pkg{pkgUrl=val})
, simpleField "synopsis"
showFreeText (munch (const True))
synopsis (\val pkg -> pkg{synopsis=val})
, simpleField "description"
showFreeText (munch (const True))
description (\val pkg -> pkg{description=val})
Expand Down Expand Up @@ -394,9 +403,9 @@ binfoFields =
, simpleField "hs-source-dir"
showFilePath parseFilePathQ
hsSourceDir (\path binfo -> binfo{hsSourceDir=path})
, listField "hidden-modules"
, listField "other-modules"
text parseModuleNameQ
hiddenModules (\val binfo -> binfo{hiddenModules=val})
otherModules (\val binfo -> binfo{otherModules=val})
, optsField "options-ghc" GHC
options (\path binfo -> binfo{options=path})
, optsField "options-hugs" Hugs
Expand Down Expand Up @@ -555,7 +564,7 @@ sanityCheckPackage pkg_descr
(null (executables pkg_descr) && isNothing (library pkg_descr))
"No executables and no library found. Nothing to do."
noModules <- checkSanity (hasMods pkg_descr)
"No non-hidden modules in this package."
"No exposed modules or executables in this package."

return $ any (==True) [libSane, identSane, nothingToDo, noModules]

Expand Down Expand Up @@ -594,7 +603,8 @@ testPkgDesc = unlines [
"Author: Happy Haskell Hacker",
"Homepage: http://www.haskell.org/foo",
"Package-url: http://www.haskell.org/foo",
"Description: a nice package!",
"Synopsis: a nice package!",
"Description: a really nice package!",
"Category: tools",
"buildable: True",
"CC-OPTIONS: -g -o",
Expand All @@ -603,7 +613,7 @@ testPkgDesc = unlines [
"Tested-with: GHC",
"Stability: Free Text String",
"Build-Depends: haskell-src, HUnit>=1.0.0-rain",
"Hidden-Modules: Distribution.Package, Distribution.Version,",
"Other-Modules: Distribution.Package, Distribution.Version,",
" Distribution.Simple.GHCPackageConfig",
"C-Sources: not/even/rain.c, such/small/hands",
"HS-Source-Dir: src",
Expand All @@ -619,7 +629,7 @@ testPkgDesc = unlines [
"-- Next is an executable",
"Executable: somescript",
"Main-is: SomeFile.hs",
"Hidden-Modules: Foo1, Util, Main",
"Other-Modules: Foo1, Util, Main",
"HS-Source-Dir: scripts",
"Extensions: OverlappingInstances"
]
Expand All @@ -633,7 +643,8 @@ testPkgDescAnswer =
author = "Happy Haskell Hacker",
homepage = "http://www.haskell.org/foo",
pkgUrl = "http://www.haskell.org/foo",
description = "a nice package!",
synopsis = "a nice package!",
description = "a really nice package!",
category = "tools",
buildDepends = [Dependency "haskell-src" AnyVersion,
Dependency "HUnit"
Expand All @@ -652,9 +663,9 @@ testPkgDescAnswer =
frameworks = ["foo"],
cSources = ["not/even/rain.c", "such/small/hands"],
hsSourceDir = "src",
hiddenModules = ["Distribution.Package",
"Distribution.Version",
"Distribution.Simple.GHCPackageConfig"],
otherModules = ["Distribution.Package",
"Distribution.Version",
"Distribution.Simple.GHCPackageConfig"],
extensions = [OverlappingInstances, TypeSynonymInstances],
extraLibs = ["libfoo", "bar", "bang"],
extraLibDirs = ["/usr/local/libs"],
Expand All @@ -666,7 +677,7 @@ testPkgDescAnswer =
executables = [Executable "somescript"
"SomeFile.hs" (
emptyBuildInfo{
hiddenModules=["Foo1","Util","Main"],
otherModules=["Foo1","Util","Main"],
hsSourceDir = "scripts",
extensions = [OverlappingInstances]
})]
Expand Down
23 changes: 1 addition & 22 deletions Distribution/ParseUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module Distribution.ParseUtils (
parsePackageNameQ, parseVersionRangeQ,
parseTestedWithQ, parseLicenseQ, parseExtensionQ, parseCommaList,
showFilePath, showTestedWith, showDependency, showFreeText,
simpleField, listField, licenseField, optsField,
simpleField, listField, optsField,
parseReadS, parseQuoted,
) where

Expand Down Expand Up @@ -134,27 +134,6 @@ listField name showF readF get set = StanzaField name
xs <- runP lineNo name (parseCommaList readF) val
return (set xs st))

licenseField :: String -> Bool -> (b -> License) -> (License -> b -> b) -> StanzaField b
licenseField name flag get set = StanzaField name
(\st -> case get st of
OtherLicense path | flag -> text name <> colon <+> showFilePath path
| otherwise -> empty
license' | not flag -> text name <> colon <+> text (show license')
| otherwise -> empty)
(\st -> case get st of
OtherLicense path | flag -> showFilePath path
| otherwise -> empty
license' | not flag -> text (show license')
| otherwise -> empty)
(\lineNo val st ->
if flag
then do
path <- runP lineNo name parseFilePathQ val
return (set (OtherLicense path) st)
else do
x <- runP lineNo name parseLicenseQ val
return (set x st))

optsField :: String -> CompilerFlavor -> (b -> [(CompilerFlavor,[String])]) -> ([(CompilerFlavor,[String])] -> b -> b) -> StanzaField b
optsField name flavor get set = StanzaField name
(\st -> case lookup flavor (get st) of
Expand Down
4 changes: 2 additions & 2 deletions Distribution/PreProcess.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ preprocessSources pkg_descr lbi verbose handlers = do
sequence_ [preprocessModule ((hsSourceDir bi)
:(maybeToList (library pkg_descr >>= Just . hsSourceDir . libBuildInfo)))
modu verbose builtinSuffixes biHandlers |
modu <- hiddenModules bi] -- FIX: output errors?
modu <- otherModules bi] -- FIX: output errors?
where hc = compilerFlavor (compiler lbi)
builtinSuffixes
| hc == NHC = ["hs", "lhs", "gc"]
Expand Down Expand Up @@ -158,7 +158,7 @@ removePreprocessedPackage pkg_descr r suff
removePreprocessed (r `joinFileName` hsSourceDir bi) (libModules pkg_descr) suff)
foreachExe pkg_descr (\theExe -> do
let bi = buildInfo theExe
removePreprocessed (r `joinFileName` hsSourceDir bi) (hiddenModules bi) suff)
removePreprocessed (r `joinFileName` hsSourceDir bi) (otherModules bi) suff)

-- |Remove the preprocessed .hs files. (do we need to get some .lhs files too?)
removePreprocessed :: FilePath -- ^search Location
Expand Down
23 changes: 17 additions & 6 deletions Distribution/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}

module Distribution.Setup (--parseArgs,
Action(..), ConfigFlags(..),
CopyFlags, InstallFlags, RegisterFlags,
CompilerFlavor(..), Compiler(..),
--optionHelpString,
#ifdef DEBUG
Expand Down Expand Up @@ -100,6 +101,7 @@ data Action = ConfigCmd ConfigFlags -- config
-- | NoCmd -- error case?
deriving (Show, Eq)

-- | Flags to @configure@ command
data ConfigFlags = ConfigFlags {
configHcFlavor :: Maybe CompilerFlavor,
configHcPath :: Maybe FilePath, -- ^given compiler location
Expand Down Expand Up @@ -359,8 +361,11 @@ copyCmd = Cmd {
cmdAction = CopyCmd Nothing
}

parseCopyArgs :: (Maybe FilePath,Int) -> [String] -> [OptDescr a] ->
IO ((Maybe FilePath,Int), [a], [String])
-- | Flags to @copy@: (Copy Location, verbose)
type CopyFlags = (Maybe FilePath,Int)

parseCopyArgs :: CopyFlags -> [String] -> [OptDescr a] ->
IO (CopyFlags, [a], [String])
parseCopyArgs cfg args customOpts =
case getCmdOpt copyCmd customOpts args of
(flags, _, []) | hasHelpFlag flags -> do
Expand All @@ -379,8 +384,11 @@ parseCopyArgs cfg args customOpts =
_ -> error $ "Unexpected flag!"
updateCfg [] t = t

parseInstallArgs :: (Bool,Int) -> [String] -> [OptDescr a] ->
IO ((Bool,Int), [a], [String])
-- | Flags to @install@: (user package, verbose)
type InstallFlags = (Bool,Int)

parseInstallArgs :: InstallFlags -> [String] -> [OptDescr a] ->
IO (InstallFlags, [a], [String])
parseInstallArgs cfg args customOpts =
case getCmdOpt installCmd customOpts args of
(flags, _, []) | hasHelpFlag flags -> do
Expand Down Expand Up @@ -431,8 +439,11 @@ registerCmd = Cmd {
cmdAction = RegisterCmd False
}

parseRegisterArgs :: (Bool,Int) -> [String] -> [OptDescr a] ->
IO ((Bool,Int), [a], [String])
-- | Flags to @register@: (user package, verbose)
type RegisterFlags = (Bool,Int)

parseRegisterArgs :: RegisterFlags -> [String] -> [OptDescr a] ->
IO (RegisterFlags, [a], [String])
parseRegisterArgs cfg args customOpts =
case getCmdOpt registerCmd customOpts args of
(flags, _, []) | hasHelpFlag flags -> do
Expand Down
Loading

0 comments on commit 409b725

Please sign in to comment.