Commit 13364cab authored by Mikhail Glushenkov's avatar Mikhail Glushenkov

Refactoring.

parent e7e53d95
......@@ -12,6 +12,7 @@
-----------------------------------------------------------------------------
module Distribution.Client.Configure (
configure,
chooseCabalVersion,
) where
import Distribution.Client.Dependency
......@@ -53,10 +54,23 @@ import Distribution.System
import Distribution.Verbosity as Verbosity
( Verbosity )
import Distribution.Version
( Version(..), orLaterVersion )
( Version(..), VersionRange, orLaterVersion )
import Data.Monoid (Monoid(..))
-- | Choose the Cabal version such that the setup scripts compiled against this
-- version will support the given command-line flags.
chooseCabalVersion :: ConfigExFlags -> Maybe Version -> VersionRange
chooseCabalVersion configExFlags maybeVersion =
maybe defaultVersionRange thisVersion maybeVersion
where
allowNewer = fromFlagOrDefault False $
fmap isAllowNewer (configAllowNewer configExFlags)
defaultVersionRange = if allowNewer
then orLaterVersion (Version [1,19,2] [])
else anyVersion
-- | Configure the package found in the local directory
configure :: Verbosity
-> PackageDBStack
......@@ -95,13 +109,8 @@ configure verbosity packageDBs repos comp platform conf
++ "one local ready package."
where
allowNewer = fromFlagOrDefault False $
fmap isAllowNewer (configAllowNewer configExFlags)
setupScriptOptions index = SetupScriptOptions {
useCabalVersion = maybe (if allowNewer
then orLaterVersion (Version [1,19,2] [])
else anyVersion)
thisVersion
useCabalVersion = chooseCabalVersion configExFlags
(flagToMaybe (configCabalVersion configExFlags)),
useCompiler = Just comp,
usePlatform = Just platform,
......
......@@ -57,9 +57,11 @@ import System.IO.Error
( isDoesNotExistError, ioeGetFileName )
import Distribution.Client.Targets
import Distribution.Client.Configure
( chooseCabalVersion )
import Distribution.Client.Dependency
import Distribution.Client.Dependency.Types
( AllowNewer, Solver(..), isAllowNewer )
( Solver(..) )
import Distribution.Client.FetchUtils
import qualified Distribution.Client.Haddock as Haddock (regenerateHaddockIndex)
import Distribution.Client.IndexUtils as IndexUtils
......@@ -131,7 +133,7 @@ import Distribution.PackageDescription.Configuration
import Distribution.ParseUtils
( showPWarning )
import Distribution.Version
( Version(..), anyVersion, orLaterVersion, thisVersion )
( Version )
import Distribution.Simple.Utils as Utils
( notice, info, warn, debug, debugNoWrap, die
, intercalate, withTempDirectory )
......@@ -916,14 +918,10 @@ performInstallations verbosity
parallelInstall = numJobs >= 2
distPref = fromFlagOrDefault (useDistPref defaultSetupScriptOptions)
(configDistPref configFlags)
allowNewer = fromFlagOrDefault False $
fmap isAllowNewer (configAllowNewer configExFlags)
setupScriptOptions index lock = SetupScriptOptions {
useCabalVersion = maybe (if allowNewer
then orLaterVersion (Version [1,19,2] [])
else anyVersion)
thisVersion (libVersion miscOptions),
useCabalVersion = chooseCabalVersion configExFlags
(libVersion miscOptions),
useCompiler = Just comp,
usePlatform = Just platform,
-- Hack: we typically want to allow the UserPackageDB for finding the
......
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