Commit 8814b950 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Change UserHooks.readDesc to use GenericPackageDescription

Also changes Simple.defaultMainNoRead to use GenericPackageDescription.
This is an API change that in principle could break Setup.hs scripts
but in practise there are no Setup.hs scripts that use either.
parent af1d3b1d
...@@ -148,7 +148,7 @@ defaultMainWithHooksArgs = defaultMainHelper ...@@ -148,7 +148,7 @@ defaultMainWithHooksArgs = defaultMainHelper
-- | Like 'defaultMain', but accepts the package description as input -- | Like 'defaultMain', but accepts the package description as input
-- rather than using IO to read it. -- rather than using IO to read it.
defaultMainNoRead :: PackageDescription -> IO () defaultMainNoRead :: GenericPackageDescription -> IO ()
defaultMainNoRead pkg_descr = defaultMainNoRead pkg_descr =
getArgs >>= getArgs >>=
defaultMainHelper simpleUserHooks { readDesc = return (Just pkg_descr) } defaultMainHelper simpleUserHooks { readDesc = return (Just pkg_descr) }
...@@ -212,7 +212,7 @@ configureAction hooks flags args = do ...@@ -212,7 +212,7 @@ configureAction hooks flags args = do
-- get_pkg_descr (configVerbosity flags') -- get_pkg_descr (configVerbosity flags')
--let pkg_descr = updatePackageDescription pbi pkg_descr0 --let pkg_descr = updatePackageDescription pbi pkg_descr0
let epkg_descr = (pkg_descr0, pbi) let epkg_descr = (Left pkg_descr0, pbi)
--(warns, ers) <- sanityCheckPackage pkg_descr --(warns, ers) <- sanityCheckPackage pkg_descr
--errorOut (configVerbosity flags') warns ers --errorOut (configVerbosity flags') warns ers
...@@ -227,17 +227,15 @@ configureAction hooks flags args = do ...@@ -227,17 +227,15 @@ configureAction hooks flags args = do
postConf hooks args flags pkg_descr localbuildinfo postConf hooks args flags pkg_descr localbuildinfo
where where
verbosity = fromFlag (configVerbosity flags) verbosity = fromFlag (configVerbosity flags)
confPkgDescr :: IO (Maybe FilePath, confPkgDescr :: IO (Maybe FilePath, GenericPackageDescription)
Either GenericPackageDescription
PackageDescription)
confPkgDescr = do confPkgDescr = do
mdescr <- readDesc hooks mdescr <- readDesc hooks
case mdescr of case mdescr of
Just descr -> return (Nothing, Right descr) Just descr -> return (Nothing, descr)
Nothing -> do Nothing -> do
pdfile <- defaultPackageDesc verbosity pdfile <- defaultPackageDesc verbosity
ppd <- readPackageDescription verbosity pdfile descr <- readPackageDescription verbosity pdfile
return (Just pdfile, Left ppd) return (Just pdfile, descr)
buildAction :: UserHooks -> BuildFlags -> Args -> IO () buildAction :: UserHooks -> BuildFlags -> Args -> IO ()
buildAction hooks flags args = do buildAction hooks flags args = do
......
...@@ -82,7 +82,7 @@ data UserHooks = UserHooks { ...@@ -82,7 +82,7 @@ data UserHooks = UserHooks {
-- | Used for @.\/setup test@ -- | Used for @.\/setup test@
runTests :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO (), runTests :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO (),
-- | Read the description file -- | Read the description file
readDesc :: IO (Maybe PackageDescription), readDesc :: IO (Maybe GenericPackageDescription),
-- | Custom preprocessors in addition to and overriding 'knownSuffixHandlers'. -- | Custom preprocessors in addition to and overriding 'knownSuffixHandlers'.
hookedPreProcessors :: [ PPSuffixHandler ], hookedPreProcessors :: [ PPSuffixHandler ],
-- | These programs are detected at configure time. Arguments for them are -- | These programs are detected at configure time. Arguments for them are
......
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