Commit c35d8f5c authored by ijones's avatar ijones
Browse files

lots of cvs pulls from Ross, Malcolm, Simon, & Simon

  No reason we shouldn't have Ord on PackageIdentifiers

  Various changes committed in one bunch:
  
   - bindir/libdir/datadir/libexecdir support as discussed on
     librarie@haskell.org.  This should be considered fairly
     experimental.  Full documentation in the manual.
  
   - A module Paths_<pkgname> is autogenerated, you should be able
     to just import this.  (I haven't made this work with Hugs yet, though).
     I suspect I might need to make sure it's available to 'setup haddock'
     too.  Also, I haven't tested this on Windows yet (TODO).
  
   - All installation-paths-related functions are now provided by
     Distribution.Simple.LocalBuildInfo
  
   - some cleaning up of Distribution.Simple.Build as regards GHC support.
  
   - "setup copy" now takes a --destdir argument instead of --copy-prefix
     (the latter is still accepted for compatibility).
  
     Note for autoconf/make users: this means that your Makefile now
     needs to implement a "copy" target, see the manual for details.
  
   - New types: Distribution.Setup.CopyFlags (was previously just a
     pair), and CopyDest (was previously Maybe FilePath).
  
   - Hooks: the post hooks all take a PackageDescription argument now.
     There seemed no reason not to do this, and sometimes it's useful.


  Remove literal tabs in strings.  Not Haskell'98.

  harmonize running of ./confugure between defaultUserHooks and
  Distribution.Make:
  
  * pass through the same set of flags, plus unrecognized options
  
  * select the default compiler before processing options

  Fixes for Windows

  added a simple-minded data-files field.  Also added getDataFileName to
  Paths_<pkg> to save client code from worrying about path separators.
parent ff11d019
Name: Cabal
Version: 1.1.4
Copyright: 2003-2005, Isaac Jones
-- We want "base, unix" on Unix and just "base" on Windows, but can't
-- express that directly, so we fake it by depending on util.
Build-Depends: base, util
License: BSD3
License-File: LICENSE
......
......@@ -7,11 +7,10 @@
-- Stability : alpha
-- Portability : portable
--
-- Explanation: Information on how to USE an installed package,
-- consumed by HC-PKG (ghc-pkg, for instance). THIS MODULE IS NOT YET
-- USED. HC-PKG is not yet implemented, and ghc-pkg has its own file
-- format, so this module is very much subject to change once HC-PKG
-- is implemented.
-- This is the information about an /installed/ package that
-- is communicated to the @hc-pkg@ program in order to register
-- a package. @ghc-pkg@ now consumes this package format (as of verison
-- 6.4).
{- All rights reserved.
......
......@@ -68,39 +68,40 @@ Basic assumptions
Obviously we assume that there is a configure script, and that after the
ConfigCmd has been run, there is a Makefile.
ConfigCmd: We assume the configure script accepts a --with-hc flag
ConfigCmd: We assume the configure script accepts:
--with-hc
--with-hc-pkg
--prefix
--bindir
--libdir
--libexecdir
--datadir
BuildCmd: We assume the default Makefile target will build everything
InstallCmd: We assume there is an install target and a variable $(prefix)
that can be overridden
(./Setup --install-prefix=foo -> make prefix=foo install)
InstallCmd: We assume there is an install target
Note that we assume that this does *not* register the package!
CopyCmd: We assume there is a copy target, and a variable $(destdir)
The 'copy' target should probably just invoke make install recursively, eg.
copy :
$(MAKE) install prefix=$(destdir)/$(prefix) \
bindir=$(destdir)/$(bindir) \
...
The reason we can't invoke make install directly here is that we don't
know the value of $(prefix).
SDistCmd: We assume there is an dist target
RegisterCmd: We assume there is a register target and a variable $(user)
UnregisterCmd: We assume there is an unregister target
HaddockCmd: We assume there is a "docs" or "doc" target
ProgramaticaCmd: We assume there is a "programatica" target
-}
configureArgs :: ConfigFlags -> String
configureArgs flags
= unwords (hc_flag ++ hc_pkg_flag ++ prefix_flag)
where
hc_flag = case (configHcFlavor flags, configHcPath flags) of
(_, Just hc_path) -> ["--with-hc=" ++ hc_path]
(Just hc, Nothing) -> ["--with-hc=" ++ showHC hc]
(Nothing,Nothing) -> []
hc_pkg_flag = case configHcPkg flags of
Just hc_pkg_path -> ["--with-hc-pkg=" ++ hc_pkg_path]
Nothing -> []
prefix_flag = case configPrefix flags of
Just p -> ["--prefix=" ++ p]
Nothing -> []
showHC GHC = "ghc"
showHC NHC = "nhc98"
showHC Hugs = "hugs"
showHC c = "unknown compiler: " ++ (show c)
exec :: String -> IO ExitCode
exec cmd = (putStrLn $ "-=-= Cabal executing: " ++ cmd ++ "=-=-")
>> system cmd
......@@ -115,18 +116,22 @@ defaultMainNoRead pkg_descr
case action of
ConfigCmd flags -> do
(flags, _, args) <- parseConfigureArgs flags args []
no_extra_flags args
retVal <- exec $ "./configure " ++ configureArgs flags
retVal <- exec $ unwords $
"./configure" : configureArgs flags ++ args
if (retVal == ExitSuccess)
then putStrLn "Configure Succeeded."
else putStrLn "Configure failed."
exitWith retVal
CopyCmd mprefix -> do
((mprefix,_), _, args) <- parseCopyArgs (mprefix,0) args []
CopyCmd copydest0 -> do
((copydest,_), _, args) <- parseCopyArgs (copydest0,0) args []
no_extra_flags args
maybeExit $ system $ "make install" ++
maybe "" (" prefix="++) mprefix
let cmd = case copydest of
NoCopyDest -> "install"
CopyTo path -> "copy destdir=" ++ path
CopyPrefix path -> "install prefix=" ++ path
-- CopyPrefix is backwards compat, DEPRECATED
maybeExit $ system $ ("make " ++ cmd)
InstallCmd uInst -> do
((_,_), _, args) <- parseInstallArgs (uInst,0) args []
......
......@@ -54,7 +54,7 @@ data PackageIdentifier
pkgName :: String,
pkgVersion :: Version
}
deriving (Read, Show, Eq)
deriving (Read, Show, Eq, Ord)
showPackageId :: PackageIdentifier -> String
showPackageId (PackageIdentifier n (Version [] _)) = n -- if no version, don't show version.
......
......@@ -134,6 +134,7 @@ data PackageDescription
-- components
library :: Maybe Library,
executables :: [Executable],
dataFiles :: [FilePath],
extraSrcFiles :: [FilePath],
extraTmpFiles :: [FilePath]
}
......@@ -166,6 +167,7 @@ emptyPackageDescription
category = "",
library = Nothing,
executables = [],
dataFiles = [],
extraSrcFiles = [],
extraTmpFiles = []
}
......@@ -373,6 +375,8 @@ basicStanzaFields =
, listField "tested-with"
showTestedWith parseTestedWithQ
testedWith (\val pkg -> pkg{testedWith=val})
, listField "data-files" showFilePath parseFilePathQ
dataFiles (\val pkg -> pkg{dataFiles=val})
, listField "extra-source-files" showFilePath parseFilePathQ
extraSrcFiles (\val pkg -> pkg{extraSrcFiles=val})
, listField "extra-tmp-files" showFilePath parseFilePathQ
......
......@@ -42,8 +42,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Setup (--parseArgs,
module Distribution.Compiler,
Action(..), ConfigFlags(..),
CopyFlags, InstallFlags, RegisterFlags, SDistFlags,
Action(..),
ConfigFlags(..), emptyConfigFlags, configureArgs,
CopyFlags, CopyDest(..), InstallFlags, RegisterFlags, SDistFlags,
--optionHelpString,
#ifdef DEBUG
hunitTests,
......@@ -81,7 +82,7 @@ import System.Environment
data Action = ConfigCmd ConfigFlags -- config
| BuildCmd -- build
| CleanCmd -- clean
| CopyCmd (Maybe FilePath) -- copy
| CopyCmd CopyDest -- copy (--destdir flag)
| HaddockCmd -- haddock
| ProgramaticaCmd -- pfesetup
| InstallCmd Bool -- install (install-prefix) (--user flag)
......@@ -111,7 +112,21 @@ data ConfigFlags = ConfigFlags {
configGreencard:: Maybe FilePath, -- ^GreenCard path
configProfLib :: Bool, -- ^Enable profiling in the library
configProfExe :: Bool, -- ^Enable profiling in the executables.
configPrefix :: Maybe FilePath, -- ^installation prefix
configPrefix :: Maybe FilePath,
-- ^installation prefix
configBinDir :: Maybe FilePath,
-- ^installation dir for binaries,
configLibDir :: Maybe FilePath,
-- ^installation dir for object code libraries,
configLibSubDir :: Maybe FilePath,
-- ^subdirectory of libdir in which libs are installed
configLibExecDir :: Maybe FilePath,
-- ^installation dir for program executables,
configDataDir :: Maybe FilePath,
-- ^installation dir for read-only arch-independent data,
configDataSubDir :: Maybe FilePath,
-- ^subdirectory of datadir in which data files are installed
configVerbose :: Int, -- ^verbosity level
configUser :: Bool, -- ^--user flag?
configGHCiLib :: Bool -- ^Enable compiling library for GHCi
......@@ -119,7 +134,6 @@ data ConfigFlags = ConfigFlags {
emptyConfigFlags :: ConfigFlags
emptyConfigFlags = ConfigFlags {
configPrograms = defaultProgramConfiguration,
configHcFlavor = Nothing,
configHcPath = Nothing,
configHcPkg = Nothing,
......@@ -133,28 +147,70 @@ emptyConfigFlags = ConfigFlags {
configCpphs = Nothing,
configGreencard= Nothing,
configPrefix = Nothing,
configBinDir = Nothing,
configLibDir = Nothing,
configLibSubDir = Nothing,
configLibExecDir = Nothing,
configDataDir = Nothing,
configDataSubDir = Nothing,
configVerbose = 0,
configUser = False,
configGHCiLib = True
}
defaultCompilerFlavor :: Maybe CompilerFlavor
defaultCompilerFlavor =
#if defined(__GLASGOW_HASKELL__)
Just GHC
#elif defined(__NHC__)
Just NHC
#elif defined(__HUGS__)
Just Hugs
#else
Nothing
#endif
-- | Arguments to pass to a @configure@ script, e.g. generated by
-- @autoconf@.
configureArgs :: ConfigFlags -> [String]
configureArgs flags
= hc_flag ++
optFlag "with-hc-pkg" configHcPkg ++
optFlag "prefix" configPrefix ++
optFlag "bindir" configBinDir ++
optFlag "libdir" configLibDir ++
optFlag "libexecdir" configLibExecDir ++
optFlag "datadir" configDataDir
where
hc_flag = case (configHcFlavor flags, configHcPath flags) of
(_, Just hc_path) -> ["--with-hc=" ++ hc_path]
(Just hc, Nothing) -> ["--with-hc=" ++ showHC hc]
(Nothing,Nothing) -> []
optFlag name config_field = case config_field flags of
Just p -> ["--" ++ name ++ "=" ++ p]
Nothing -> []
showHC GHC = "ghc"
showHC NHC = "nhc98"
showHC Hugs = "hugs"
showHC c = "unknown compiler: " ++ (show c)
-- |Most of these flags are for Configure, but InstPrefix is for Copy.
data Flag a = GhcFlag | NhcFlag | HugsFlag
| WithCompiler FilePath | WithHcPkg FilePath | Prefix FilePath
| WithCompiler FilePath | WithHcPkg FilePath
| WithHappy FilePath | WithAlex FilePath
| WithHsc2hs FilePath | WithC2hs FilePath | WithCpphs FilePath
| WithGreencard FilePath
| WithProfLib | WithoutProfLib
| WithProfExe | WithoutProfExe
| WithGHCiLib | WithoutGHCiLib
| ProgramArgs String String -- program name, arguments
| WithProgram String FilePath -- program name, location
-- For install, register, and unregister:
| UserFlag | GlobalFlag
-- for register & unregister
| GenScriptFlag
-- For copy:
| InstPrefix FilePath
| DestDir FilePath
-- For sdist:
| Snapshot
-- For everyone:
......@@ -257,6 +313,8 @@ configureCmd = Cmd {
"give the path to the package tool",
Option "" ["prefix"] (reqDirArg Prefix)
"bake this prefix in preparation of installation",
Option "" ["with-haddock"] (reqPathArg WithHaddock)
"give the path to haddock",
Option "" ["with-happy"] (reqPathArg WithHappy)
"give the path to happy",
Option "" ["with-alex"] (reqPathArg WithAlex)
......@@ -341,6 +399,12 @@ parseConfigureArgs = parseArgs configureCmd updateCfg
updateCfg t WithGHCiLib = t { configGHCiLib = True }
updateCfg t WithoutGHCiLib = t { configGHCiLib = False }
updateCfg t (Prefix path) = t { configPrefix = Just path }
updateCfg t (BinDir path) = t { configBinDir = Just path }
updateCfg t (LibDir path) = t { configLibDir = Just path }
updateCfg t (LibSubDir path) = t { configLibSubDir= Just path }
updateCfg t (LibExecDir path) = t { configLibExecDir = Just path }
updateCfg t (DataDir path) = t { configDataDir = Just path }
updateCfg t (DataSubDir path) = t { configDataSubDir = Just path }
updateCfg t (Verbose n) = t { configVerbose = n }
updateCfg t UserFlag = t { configUser = True }
updateCfg t GlobalFlag = t { configUser = False }
......@@ -415,23 +479,32 @@ copyCmd :: Cmd a
copyCmd = Cmd {
cmdName = "copy",
cmdHelp = "Copy the files into the install locations.",
cmdDescription = "Does not call register, and allows a prefix at install time\nWithout the copy-prefix flag, configure determines location.\n",
cmdDescription = "Does not call register, and allows a prefix at install time\nWithout the --destdir flag, configure determines location.\n",
cmdOptions = [cmd_help, cmd_verbose,
Option "" ["destdir"] (reqDirArg DestDir)
"directory to copy files to, prepended to installation directories",
Option "" ["copy-prefix"] (reqDirArg InstPrefix)
"specify the directory in which to place installed files"
"[DEPRECATED, directory to copy files to instead of prefix]"
],
cmdAction = CopyCmd Nothing
cmdAction = CopyCmd NoCopyDest
}
-- | Flags to @copy@: (Copy Location, verbose)
type CopyFlags = (Maybe FilePath,Int)
-- | Flags to @copy@: (destdir, copy-prefix (backwards compat), verbose)
type CopyFlags = (CopyDest,Int)
data CopyDest
= NoCopyDest
| CopyTo FilePath
| CopyPrefix FilePath -- DEPRECATED
deriving (Eq, Show)
parseCopyArgs :: CopyFlags -> [String] -> [OptDescr a] ->
IO (CopyFlags, [a], [String])
parseCopyArgs = parseArgs copyCmd updateCfg
where updateCfg (mprefix,verbose) fl = case fl of
InstPrefix path -> (Just path, verbose)
Verbose n -> (mprefix, n)
where updateCfg (copydest,verbose) fl = case fl of
InstPrefix path -> (CopyPrefix path, verbose)
DestDir path -> (CopyTo path,verbose)
Verbose n -> (copydest,n)
_ -> error $ "Unexpected flag!"
-- | Flags to @install@: (user package, verbose)
......
......@@ -123,7 +123,7 @@ type Args = [String]
-- a command is run, and also to specify additional preprocessors.
data UserHooks = UserHooks
{
runTests :: Args -> Bool -> LocalBuildInfo -> IO ExitCode, -- ^Used for @.\/setup test@
runTests :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ExitCode, -- ^Used for @.\/setup test@
readDesc :: IO (Maybe PackageDescription), -- ^Read the description file
hookedPreProcessors :: [ PPSuffixHandler ],
-- ^Custom preprocessors in addition to and overriding 'knownSuffixHandlers'.
......@@ -133,7 +133,7 @@ data UserHooks = UserHooks
-- |Over-ride this hook to get different behavior during configure.
confHook :: PackageDescription -> ConfigFlags -> IO LocalBuildInfo,
-- |Hook to run after configure command
postConf :: Args -> ConfigFlags -> LocalBuildInfo -> IO ExitCode,
postConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ExitCode,
-- |Hook to run before build command. Second arg indicates verbosity level.
preBuild :: Args -> Int -> IO HookedBuildInfo,
......@@ -145,24 +145,24 @@ data UserHooks = UserHooks
-> [ PPSuffixHandler ]
-> IO (),
-- |Hook to run after build command. Second arg indicates verbosity level.
postBuild :: Args -> Int -> LocalBuildInfo -> IO ExitCode,
postBuild :: Args -> Int -> PackageDescription -> LocalBuildInfo -> IO ExitCode,
-- |Hook to run before clean command. Second arg indicates verbosity level.
preClean :: Args -> Int -> IO HookedBuildInfo,
-- |Over-ride this hook to get different behavior during clean.
cleanHook :: PackageDescription -> LocalBuildInfo -> Int -> [PPSuffixHandler] -> IO (),
-- |Hook to run after clean command. Second arg indicates verbosity level.
postClean :: Args -> Int -> LocalBuildInfo -> IO ExitCode,
postClean :: Args -> Int -> PackageDescription -> LocalBuildInfo -> IO ExitCode,
-- |Hook to run before copy command
preCopy :: Args -> CopyFlags -> IO HookedBuildInfo,
-- |Over-ride this hook to get different behavior during copy.
copyHook :: PackageDescription
-> LocalBuildInfo
-> (Maybe FilePath,Int) -- install-prefix, verbose
-> CopyFlags -- install-prefix, verbose
-> IO (),
-- |Hook to run after copy command
postCopy :: Args -> CopyFlags -> LocalBuildInfo -> IO ExitCode,
postCopy :: Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ExitCode,
-- |Hook to run before install command
preInst :: Args -> InstallFlags -> IO HookedBuildInfo,
......@@ -175,7 +175,7 @@ data UserHooks = UserHooks
-> IO (),
-- |Hook to run after install command. postInst should be run
-- on the target, not on the build machine.
postInst :: Args -> InstallFlags -> LocalBuildInfo -> IO ExitCode,
postInst :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ExitCode,
-- |Hook to run before sdist command. Second arg indicates verbosity level.
preSDist :: Args -> Int -> IO HookedBuildInfo,
......@@ -188,35 +188,35 @@ data UserHooks = UserHooks
-> PackageDescription
-> IO (),
-- |Hook to run after sdist command. Second arg indicates verbosity level.
postSDist :: Args -> Int -> LocalBuildInfo -> IO ExitCode,
postSDist :: Args -> Int -> PackageDescription -> LocalBuildInfo -> IO ExitCode,
-- |Hook to run before register command
preReg :: Args -> RegisterFlags -> IO HookedBuildInfo,
-- |Over-ride this hook to get different behavior during pfe.
regHook :: PackageDescription -> LocalBuildInfo -> RegisterFlags -> IO (),
-- |Hook to run after register command
postReg :: Args -> RegisterFlags -> LocalBuildInfo -> IO ExitCode,
postReg :: Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ExitCode,
-- |Hook to run before unregister command
preUnreg :: Args -> RegisterFlags -> IO HookedBuildInfo,
-- |Over-ride this hook to get different behavior during pfe.
unregHook :: PackageDescription -> LocalBuildInfo -> RegisterFlags -> IO (),
-- |Hook to run after unregister command
postUnreg :: Args -> RegisterFlags -> LocalBuildInfo -> IO ExitCode,
postUnreg :: Args -> RegisterFlags -> PackageDescription -> LocalBuildInfo -> IO ExitCode,
-- |Hook to run before haddock command. Second arg indicates verbosity level.
preHaddock :: Args -> Int -> IO HookedBuildInfo,
-- |Hook to run after haddock command. Second arg indicates verbosity level.
-- |Over-ride this hook to get different behavior during haddock.
haddockHook :: PackageDescription -> LocalBuildInfo -> Int -> [PPSuffixHandler] -> IO (),
postHaddock :: Args -> Int -> LocalBuildInfo -> IO ExitCode,
postHaddock :: Args -> Int -> PackageDescription -> LocalBuildInfo -> IO ExitCode,
-- |Hook to run before pfe command. Second arg indicates verbosity level.
prePFE :: Args -> Int -> IO HookedBuildInfo,
-- |Over-ride this hook to get different behavior during pfe.
pfeHook :: PackageDescription -> LocalBuildInfo -> Int -> [PPSuffixHandler] -> IO (),
-- |Hook to run after pfe command. Second arg indicates verbosity level.
postPFE :: Args -> Int -> LocalBuildInfo -> IO ExitCode
postPFE :: Args -> Int -> PackageDescription -> LocalBuildInfo -> IO ExitCode
}
......@@ -273,7 +273,7 @@ defaultMainWorker pkg_descr_in action args hooks
localbuildinfo <- c pkg_descr flags
writePersistBuildConfig (foldr id localbuildinfo optFns)
postHook postConf args flags localbuildinfo
postHook postConf args flags pkg_descr localbuildinfo
BuildCmd -> do
(flags, _, args) <- parseBuildArgs args []
......@@ -283,7 +283,7 @@ defaultMainWorker pkg_descr_in action args hooks
let bld = cmdHook buildHook
bld pkg_descr localbuildinfo flags pps
postHook postBuild args flags localbuildinfo
postHook postBuild args flags pkg_descr localbuildinfo
HaddockCmd -> do
(verbose, _, args) <- parseHaddockArgs args []
......@@ -293,7 +293,7 @@ defaultMainWorker pkg_descr_in action args hooks
let hdk = cmdHook haddockHook
hdk pkg_descr localbuildinfo verbose pps
postHook postHaddock args verbose localbuildinfo
postHook postHaddock args verbose pkg_descr localbuildinfo
ProgramaticaCmd -> do
(verbose, _, args) <- parseProgramaticaArgs args []
......@@ -303,7 +303,7 @@ defaultMainWorker pkg_descr_in action args hooks
let p = cmdHook pfeHook
p pkg_descr localbuildinfo verbose pps
postHook postPFE args verbose localbuildinfo
postHook postPFE args verbose pkg_descr localbuildinfo
CleanCmd -> do
(verbose,_, args) <- parseCleanArgs args []
......@@ -313,7 +313,7 @@ defaultMainWorker pkg_descr_in action args hooks
let c = cmdHook cleanHook
c pkg_descr localbuildinfo verbose pps
postHook postClean args verbose localbuildinfo
postHook postClean args verbose pkg_descr localbuildinfo
CopyCmd mprefix -> do
(flags, _, args) <- parseCopyArgs (mprefix,0) args []
......@@ -323,7 +323,7 @@ defaultMainWorker pkg_descr_in action args hooks
let c = maybe (copyHook defaultUserHooks) copyHook hooks
c pkg_descr localbuildinfo flags
postHook postCopy args flags localbuildinfo
postHook postCopy args flags pkg_descr localbuildinfo
InstallCmd uInst -> do
(flags@(uInst, verbose), _, args) <- parseInstallArgs (uInst,0) args []
......@@ -333,7 +333,7 @@ defaultMainWorker pkg_descr_in action args hooks
let inst = cmdHook instHook
inst pkg_descr localbuildinfo verbose uInst
postHook postInst args flags localbuildinfo
postHook postInst args flags pkg_descr localbuildinfo
SDistCmd -> do
let srcPref = distPref `joinFileName` "src"
......@@ -344,14 +344,14 @@ defaultMainWorker pkg_descr_in action args hooks
let sd = maybe (sDistHook defaultUserHooks) sDistHook hooks
sd srcPref distPref verbose snapshot pps pkg_descr
postHook postSDist args verbose localbuildinfo
postHook postSDist args verbose pkg_descr localbuildinfo
TestCmd -> do
(verbose,_, args) <- parseTestArgs args []
case hooks of
Nothing -> return ExitSuccess
Just h -> do localbuildinfo <- getPersistBuildConfig
out <- (runTests h) args False localbuildinfo
out <- (runTests h) args False pkg_descr_in localbuildinfo
when (isFailure out) (exitWith out)
return out
......@@ -363,7 +363,7 @@ defaultMainWorker pkg_descr_in action args hooks
let r = maybe (regHook defaultUserHooks) regHook hooks
r pkg_descr localbuildinfo flags
postHook postReg args flags localbuildinfo
postHook postReg args flags pkg_descr localbuildinfo
UnregisterCmd uInst genScript -> do
(flags,_, args) <- parseUnregisterArgs (uInst,genScript, 0) args []
......@@ -372,7 +372,7 @@ defaultMainWorker pkg_descr_in action args hooks
let ur = maybe (unregHook defaultUserHooks) unregHook hooks
ur pkg_descr localbuildinfo flags
postHook postUnreg args flags localbuildinfo
postHook postUnreg args flags pkg_descr localbuildinfo
HelpCmd -> return ExitSuccess -- this is handled elsewhere
where
......@@ -386,10 +386,10 @@ defaultMainWorker pkg_descr_in action args hooks
Just h -> do pbi <- f h a i
return (updatePackageDescription pbi pkg_descr_in)
cmdHook f = maybe (f defaultUserHooks) f hooks
postHook f args flags localbuildinfo
postHook f args flags pkg_descr localbuildinfo
= case hooks of
Nothing -> return ExitSuccess
Just h -> f h args flags localbuildinfo
Just h -> f h args flags pkg_descr localbuildinfo
isFailure :: ExitCode -> Bool
isFailure (ExitFailure _) = True
......@@ -567,7 +567,7 @@ emptyUserHooks
postHaddock = res
}
where rn _ _ = return emptyHookedBuildInfo
res _ _ _ = return ExitSuccess
res _ _ _ _ = return ExitSuccess
ru _ _ _ _ = return ()
-- |Basic default 'UserHooks':
......@@ -605,10 +605,10 @@ defaultUserHooks
unregHook = unregister,
preUnreg = readHook thd3
}
where defaultPostConf :: Args -> ConfigFlags -> LocalBuildInfo -> IO ExitCode
defaultPostConf args flags lbi
where defaultPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ExitCode
defaultPostConf args flags pkg_descr lbi
= do let verbose = configVerbose flags
args' = addOption "prefix" (configPrefix flags) args
args' = configureArgs flags ++ args
confExists <- doesFileExist "configure"
if confExists then
#if mingw32_HOST_OS || mingw32_TARGET_OS
......@@ -622,11 +622,6 @@ defaultUserHooks
no_extra_flags args
return ExitSuccess
addOption :: String -> Maybe String -> [String] -> [String]
addOption _flag Nothing opts = opts
addOption flag (Just value) opts =
("--" ++ flag ++ "=" ++ value) : opts
readHook :: (a -> Int) -> Args -> a -> IO HookedBuildInfo
readHook verbose a flags = do
no_extra_flags a
......@@ -640,7 +635,7 @@ defaultUserHooks
thd3 (_,_,z) = z
defaultInstallHook pkg_descr localbuildinfo verbose uInst = do
install pkg_descr localbuildinfo (Nothing, verbose)
install pkg_descr localbuildinfo (NoCopyDest, verbose)
when (hasLibs pkg_descr)
(register pkg_descr localbuildinfo (uInst, False, verbose))
......
......@@ -49,14 +49,17 @@ module Distribution.Simple.Build (
import Distribution.Compiler (Compiler(..), CompilerFlavor(..),
extensionsToGHCFlag, extensionsToNHCFlag)
import Distribution.PackageDescription (PackageDescription(..), BuildInfo(..),
setupMessage, withLib,
setupMessage, withLib, hasLibs,
Executable(..), withExe,
Library(..), libModules, hcOptions)
import Distribution.Package (PackageIdentifier(..), showPackageId)
import Distribution.Setup (CopyDest(..))
import Distribution.PreProcess (preprocessSources, PPSuffixHandler, ppCpp)
import Distribution.PreProcess.Unlit (unlit)
import Distribution.Version (Version(..))
import Distribution.Simple.Configure (LocalBuildInfo(..))
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..),
mkBinDir, mkLibDir, mkDataDir,
mkLibexecDir)
import Distribution.Simple.Install (hugsMainFilename)
import Distribution.Simple.Utils (rawSystemExit, die, rawSystemPathExit,
mkLibName, mkProfLibName, mkGHCiLibName, dotToSep,
......@@ -79,6 +82,7 @@ import System.Directory (removeFile)
import Distribution.Compat.Directory (copyFile,createDirectoryIfMissing)
import Distribution.Compat.FilePath (splitFilePath, joinFileName,
splitFileExt, joinFileExt, objExtension,
pathSeparator,
searchPathSeparator, joinPaths,
splitFileName, platformPath)
import qualified Distribution.Simple.GHCPackageConfig
......@@ -106,6 +110,11 @@ build pkg_descr lbi verbose suffixes = do
die ("Package " ++ name ++ " can't be built on this system.")
createDirectoryIfMissing True (buildDir lbi)