Commit edd436ab authored by ijones's avatar ijones
Browse files

cvs pull from ross

  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.
parent 661db811
......@@ -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
......@@ -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,
......
......@@ -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)
......@@ -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))
......
......@@ -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)
......@@ -111,6 +111,7 @@ data PackageDescription
-- the following are required by all packages:
package :: PackageIdentifier,
license :: License,
licenseFile :: FilePath,
copyright :: String,
maintainer :: String,
author :: String,
......@@ -118,6 +119,7 @@ data PackageDescription
testedWith :: [(CompilerFlavor,VersionRange)],
homepage :: String,
pkgUrl :: String,
synopsis :: String,
description :: String,
category :: String,
buildDepends :: [Dependency],
......@@ -138,6 +140,7 @@ emptyPackageDescription :: PackageDescription
emptyPackageDescription
= PackageDescription {package = PackageIdentifier "" (Version [] []),
license = AllRightsReserved,
licenseFile = "",
copyright = "",
maintainer = "",
author = "",
......@@ -146,6 +149,7 @@ emptyPackageDescription
buildDepends = [],
homepage = "",
pkgUrl = "",
synopsis = "",
description = "",
category = "",
library = Nothing,
......@@ -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
......@@ -175,7 +179,7 @@ data BuildInfo = BuildInfo {
frameworks :: [String],
cSources :: [FilePath],
hsSourceDir :: FilePath,
hiddenModules :: [String],
otherModules :: [String],
extensions :: [Extension],
extraLibs :: [String],
extraLibDirs :: [String],
......@@ -193,7 +197,7 @@ emptyBuildInfo = BuildInfo {
frameworks = [],
cSources = [],
hsSourceDir = currentDir,
hiddenModules = [],
otherModules = [],
extensions = [],
extraLibs = [],
extraLibDirs = [],
......@@ -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,
......@@ -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})
......@@ -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})
......@@ -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
......@@ -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]
......@@ -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",
......@@ -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",
......@@ -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"
]
......@@ -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"
......@@ -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"],
......@@ -666,7 +677,7 @@ testPkgDescAnswer =
executables = [Executable "somescript"
"SomeFile.hs" (
emptyBuildInfo{
hiddenModules=["Foo1","Util","Main"],
otherModules=["Foo1","Util","Main"],
hsSourceDir = "scripts",
extensions = [OverlappingInstances]
})]
......
......@@ -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
......@@ -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
......
......@@ -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"]
......@@ -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
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......
......@@ -111,38 +111,34 @@ type Args = [String]
-- a command is run, and also to specify additional preprocessors.
data UserHooks = UserHooks
{
runTests :: Args -> Bool -> IO ExitCode, -- ^Used for @.\/setup test@
runTests :: Args -> Bool -> LocalBuildInfo -> IO ExitCode, -- ^Used for @.\/setup test@
readDesc :: IO (Maybe PackageDescription), -- ^Read the description file
hookedPreProcessors :: [ PPSuffixHandler ],
-- ^Custom preprocessors in addition to 'knownSuffixHandlers'.
preConf :: Args -> ConfigFlags -> IO HookedBuildInfo,
postConf :: Args -> LocalBuildInfo -> IO ExitCode,
postConf :: Args -> ConfigFlags -> LocalBuildInfo -> IO ExitCode,
preBuild :: Args -> Int -> IO HookedBuildInfo,
postBuild :: Args -> LocalBuildInfo -> IO ExitCode,
postBuild :: Args -> Int -> LocalBuildInfo -> IO ExitCode,
preClean :: Args -> Int -> IO HookedBuildInfo,
postClean :: Args -> LocalBuildInfo -> IO ExitCode,
postClean :: Args -> Int -> LocalBuildInfo -> IO ExitCode,
preCopy :: Args
-> (Maybe FilePath,Int) -- Copy Location,verbose
-> IO HookedBuildInfo,
postCopy :: Args -> LocalBuildInfo -> IO ExitCode,
preCopy :: Args -> CopyFlags -> IO HookedBuildInfo,
postCopy :: Args -> CopyFlags -> LocalBuildInfo -> IO ExitCode,
preInst :: Args -> (Bool,Int) -> IO HookedBuildInfo,
postInst :: Args -> LocalBuildInfo -> IO ExitCode, -- ^guaranteed to be run on target
preInst :: Args -> InstallFlags -> IO HookedBuildInfo,
postInst :: Args -> InstallFlags -> LocalBuildInfo -> IO ExitCode, -- ^guaranteed to be run on target
preSDist :: Args -> Int -> IO HookedBuildInfo,
postSDist :: Args -> LocalBuildInfo -> IO ExitCode,
postSDist :: Args -> Int -> LocalBuildInfo -> IO ExitCode,
preReg :: Args
-> (Bool,Int) -- Install in the user's database?; verbose
-> IO HookedBuildInfo,
postReg :: Args -> LocalBuildInfo -> IO ExitCode,
preReg :: Args -> RegisterFlags -> IO HookedBuildInfo,
postReg :: Args -> RegisterFlags -> LocalBuildInfo -> IO ExitCode,
preUnreg :: Args -> Int -> IO HookedBuildInfo,
postUnreg :: Args -> LocalBuildInfo -> IO ExitCode
postUnreg :: Args -> Int -> LocalBuildInfo -> IO ExitCode
}
-- |A simple implementation of @main@ for a Cabal setup script.
......@@ -151,22 +147,21 @@ data UserHooks = UserHooks
defaultMain :: IO ()
defaultMain = do args <- getArgs
(action, args) <- parseGlobalArgs args
pkg_descr <- defaultPackageDesc >>= readPackageDescription
pkg_descr_file <- defaultPackageDesc
pkg_descr <- readPackageDescription pkg_descr_file
defaultMainWorker pkg_descr action args Nothing
return ()
-- | A customizable version of 'defaultMain'.
defaultMainWithHooks :: UserHooks
-> IO ()
defaultMainWithHooks :: UserHooks -> IO ()
defaultMainWithHooks hooks
= do args <- getArgs
(action, args) <- parseGlobalArgs args
maybeDesc <- readDesc hooks
case maybeDesc of
Just pkg_descr -> defaultMainWorker pkg_descr action args (Just hooks) >> return ()
Nothing -> do pkg_descr <- defaultPackageDesc >>= readPackageDescription
defaultMainWorker pkg_descr action args (Just hooks)
return ()
pkg_descr <- maybe (defaultPackageDesc >>= readPackageDescription)
return maybeDesc
defaultMainWorker pkg_descr action args (Just hooks)
return ()
-- |Like 'defaultMain', but accepts the package description as input
-- rather than using IO to read it.
......@@ -192,24 +187,24 @@ defaultMainWorker pkg_descr_in action args hooks
(flags, optFns, args) <-
parseConfigureArgs flags args [buildDirOpt]
pkg_descr <- hookOrInArgs preConf args flags
let buildInfos =
map libBuildInfo (maybeToList (library pkg_descr)) ++
map buildInfo (executables pkg_descr)
when (not (any buildable buildInfos)) $ do
let name = showPackageId (package pkg_descr)
die ("Package " ++ name ++ " can't be built on this system.")
sanityCheckPackage pkg_descr
localbuildinfo <- configure pkg_descr flags
writePersistBuildConfig (foldr id localbuildinfo optFns)
sanityCheckPackage pkg_descr
postHook postConf args localbuildinfo
postHook postConf args flags localbuildinfo
BuildCmd -> do
(flags, _, args) <- parseBuildArgs args []
pkg_descr <- hookOrInArgs preBuild args flags
let buildInfos =
map libBuildInfo (maybeToList (library pkg_descr)) ++
map buildInfo (executables pkg_descr)
when (not (any buildable buildInfos)) $ do
let name = showPackageId (package pkg_descr)
die ("Package " ++ name ++ " can't be built on this system.")
localbuildinfo <- getPersistBuildConfig
build pkg_descr localbuildinfo flags pps
writeInstalledConfig pkg_descr localbuildinfo
postHook postBuild args localbuildinfo
postHook postBuild args flags localbuildinfo
HaddockCmd -> do
(verbose, _, args) <- parseHaddockArgs args []
pkg_descr <- hookOrInArgs preBuild args verbose
......@@ -254,7 +249,7 @@ defaultMainWorker pkg_descr_in action args hooks
when (isNothing mPfe) (error "pfe command not found")
putStrLn $ "using : " ++ fromJust mPfe
let bi = libBuildInfo lib
let mods = exposedModules lib ++ hiddenModules (libBuildInfo lib)
let mods = exposedModules lib ++ otherModules (libBuildInfo lib)
preprocessSources pkg_descr lbi verbose pps
inFiles <- sequence [moduleToFilePath [hsSourceDir bi] m ["hs", "lhs"]
| m <- mods] >>= return . concat
......@@ -282,14 +277,14 @@ defaultMainWorker pkg_descr_in action args hooks
try $ removeFile installedPkgConfigFile
try $ removeFile localBuildInfoFile
removePreprocessedPackage pkg_descr currentDir (ppSuffixes pps)
postHook postClean args localbuildinfo
postHook postClean args verbose localbuildinfo
CopyCmd mprefix -> do
(flags, _, args) <- parseCopyArgs (mprefix,0) args []
pkg_descr <- hookOrInArgs preCopy args flags
localbuildinfo <- getPersistBuildConfig
install pkg_descr localbuildinfo flags
postHook postCopy args localbuildinfo
postHook postCopy args flags localbuildinfo
InstallCmd uInst -> do
(flags@(uInst, verbose), _, args) <- parseInstallArgs (uInst,0) args []
......@@ -301,7 +296,7 @@ defaultMainWorker pkg_descr_in action args hooks
install pkg_descr localbuildinfo (Nothing, verbose)
when (hasLibs pkg_descr)
(register pkg_descr localbuildinfo flags)
postHook postInst args localbuildinfo
postHook postInst args flags localbuildinfo
SDistCmd -> do
let distPref = "dist"
......@@ -310,21 +305,21 @@ defaultMainWorker pkg_descr_in action args hooks
pkg_descr <- hookOrInArgs preSDist args verbose
localbuildinfo <- getPersistBuildConfig
sdist srcPref distPref verbose pps pkg_descr
postHook postSDist args localbuildinfo
postHook postSDist args verbose localbuildinfo
RegisterCmd uInst -> do
(flags, _, args) <- parseRegisterArgs (uInst,0) args []
pkg_descr <- hookOrInArgs preReg args flags
localbuildinfo <- getPersistBuildConfig
when (hasLibs pkg_descr) (register pkg_descr localbuildinfo flags)
postHook postReg args localbuildinfo
postHook postReg args flags localbuildinfo
UnregisterCmd -> do
(flags,_, args) <- parseUnregisterArgs args []
pkg_descr <- hookOrInArgs preUnreg args flags
localbuildinfo <- getPersistBuildConfig
unregister pkg_descr localbuildinfo flags
postHook postUnreg args localbuildinfo
postHook postUnreg args flags localbuildinfo
HelpCmd -> return ExitSuccess -- this is handled elsewhere
where
......@@ -337,10 +332,10 @@ defaultMainWorker pkg_descr_in action args hooks
Nothing -> no_extra_flags a >> return pkg_descr_in
Just h -> do pbi <- f h a i
return (updatePackageDescription pbi pkg_descr_in)
postHook f a localbuildinfo
postHook f args flags localbuildinfo
= case hooks of
Nothing -> return ExitSuccess
Just h -> f h a localbuildinfo
Just h -> f h args flags localbuildinfo
mockPP inputArgs pkg_descr bi lbi pref verbose file
= do let (filePref, fileName) = splitFileName file
let targetDir = joinPaths pref filePref
......@@ -391,26 +386,26 @@ emptyUserHooks
preUnreg = rn,
postUnreg = res
}
where rn _ _ = return emptyHookedBuildInfo
res _ _ = return ExitSuccess
where rn _ _ = return emptyHookedBuildInfo
res _ _ _ = return ExitSuccess
-- |Basic default 'UserHooks':
--
-- * on non-Windows systems, 'preConf' runs @.\/configure@, if present.
-- * on non-Windows systems, 'postConf' runs @.\/configure@, if present.
--
-- * all pre-hooks read additional build information from
-- * all pre-hooks except 'preConf' read additional build information from
-- /package/@.buildinfo@, if present.
--
-- Thus @configure@ can use local system information to generate
-- /package/@.buildinfo@ and possibly other files.
-- FIXME: do something sensible for windows, or do nothing in preConf.
-- FIXME: do something sensible for windows, or do nothing in postConf.
defaultUserHooks :: UserHooks
defaultUserHooks
= emptyUserHooks
{
preConf = defaultPreConf,
postConf = defaultPostConf,
preBuild = readHook,
preClean = readHook,
preCopy = readHook,
......@@ -419,9 +414,8 @@ defaultUserHooks
preReg = readHook,
preUnreg = readHook
}
where readHook a _ = no_extra_flags a >> readExistingHookedBuildInfo
defaultPreConf :: [String] -> ConfigFlags -> IO HookedBuildInfo
defaultPreConf args flags
where defaultPostConf :: Args -> ConfigFlags -> LocalBuildInfo -> IO ExitCode
defaultPostConf args flags lbi
= do let prefix_opt pref opts =
("--prefix=" ++ pref) : opts
confExists <- doesFileExist "configure"
......@@ -431,12 +425,15 @@ defaultUserHooks
return ()
else
no_extra_flags args
readExistingHookedBuildInfo
readExistingHookedBuildInfo
= do maybe_infoFile <- defaultHookedPackageDesc
case maybe_infoFile of
Nothing -> return emptyHookedBuildInfo
Just infoFile -> readHookedBuildInfo infoFile
return ExitSuccess
readHook :: Args -> a -> IO HookedBuildInfo
readHook a _ = do
no_extra_flags a
maybe_infoFile <- defaultHookedPackageDesc
case maybe_infoFile of
Nothing -> return emptyHookedBuildInfo
Just infoFile -> readHookedBuildInfo infoFile
-- ------------------------------------------------------------
-- * Testing
......
......@@ -207,7 +207,7 @@ buildHugs pkg_descr lbi verbose = do
where
compileExecutable :: FilePath -> Executable -> IO ()
compileExecutable destDir (exe@Executable {modulePath=mainPath, buildInfo=bi}) = do
let exeMods = hiddenModules bi
let exeMods = otherModules bi
let srcMainFile = hsSourceDir bi `joinFileName` mainPath
let destMainFile = destDir `joinFileName` hugsMainFilename exe
copyModule (CPP `elem` extensions bi) bi srcMainFile destMainFile
......
......@@ -180,7 +180,7 @@ mkInstalledPackageInfo pkg_descr lbi
IPI.category = category pkg_descr,
IPI.exposed = True,
IPI.exposedModules = exposedModules lib,
IPI.hiddenModules = hiddenModules bi,
IPI.hiddenModules = otherModules bi,
IPI.importDirs = [mkLibDir pkg_descr lbi Nothing],
IPI.libraryDirs = [mkLibDir pkg_descr lbi Nothing],
IPI.hsLibraries = ["HS" ++ showPackageId (package pkg_descr)],
......
......@@ -98,11 +98,11 @@ prepareDir :: Int -- ^verbose
-> [String] -- ^Exposed modules
-> BuildInfo
-> IO ()
prepareDir verbose inPref pps mods BuildInfo{hsSourceDir=srcDir, hiddenModules=mods'}
prepareDir verbose inPref pps mods BuildInfo{hsSourceDir=