Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecating --solver=modular CLI argument #9206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cabal-install/src/Distribution/Client/Dependency/Types.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE InstanceSigs #-}

module Distribution.Client.Dependency.Types
( PreSolver (..)
Expand All @@ -9,9 +10,8 @@ module Distribution.Client.Dependency.Types
import Distribution.Client.Compat.Prelude
import Prelude ()

import Text.PrettyPrint (text)

import qualified Distribution.Compat.CharParsing as P
import GHC.IO (unsafePerformIO)

-- | All the solvers that can be selected.
data PreSolver = AlwaysModular
Expand All @@ -27,14 +27,14 @@ instance Binary Solver
instance Structured PreSolver
instance Structured Solver

instance Pretty PreSolver where
pretty AlwaysModular = text "modular"

instance Parsec PreSolver where
parsec :: CabalParsing m => m PreSolver
parsec = do
name <- P.munch1 isAlpha
case map toLower name of
"modular" -> return AlwaysModular
"modular" -> return $ unsafePerformIO $ do
putStrLn "[WARNING] The `solver' config option is deprecated and will be removed in a future release."
return AlwaysModular
_ -> P.unexpected $ "PreSolver: " ++ name

-- | Global policy for all packages to say if we prefer package versions that
Expand Down
19 changes: 12 additions & 7 deletions cabal-install/src/Distribution/Client/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ import System.FilePath
( (</>)
)

import System.IO.Unsafe (unsafePerformIO)

globalCommand :: [Command action] -> CommandUI GlobalFlags
globalCommand commands =
CommandUI
Expand Down Expand Up @@ -934,7 +936,13 @@ configureExOptions _showOrParseArgs src =
)
(map prettyShow)
)
, optionSolver configSolver (\v flags -> flags{configSolver = v})
, optionSolver
configSolver
( \_ flags ->
unsafePerformIO $ do
putStrLn "[WARNING] The --solver flag is deprecated and will be removed in a future release."
return flags
)
, option
[]
["allow-older"]
Expand Down Expand Up @@ -2161,9 +2169,6 @@ defaultMaxBackjumps = 4000
defaultSolver :: PreSolver
defaultSolver = AlwaysModular

allSolvers :: String
allSolvers = intercalate ", " (map prettyShow ([minBound .. maxBound] :: [PreSolver]))

installCommand
:: CommandUI
( ConfigFlags
Expand Down Expand Up @@ -3424,16 +3429,16 @@ optionSolver get set =
option
[]
["solver"]
("Select dependency solver to use (default: " ++ prettyShow defaultSolver ++ "). Choices: " ++ allSolvers ++ ".")
("[DEPRECATED] Select dependency solver to use (default: modular). Choices: modular.")
get
set
( reqArg
"SOLVER"
( parsecToReadE
(const $ "solver must be one of: " ++ allSolvers)
(const $ "solver must be one of: modular")
(toFlag `fmap` parsec)
)
(flagToList . fmap prettyShow)
(flagToList . fmap (\_ -> "modular"))
)

optionSolverFlags
Expand Down
2 changes: 1 addition & 1 deletion doc/cabal-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ builds with ``cabal build`` are performed with the compiler

- Any flag accepted by ``cabal configure`` beyond
``./Setup configure``, namely ``--cabal-lib-version``,
``--constraint``, ``--preference`` and ``--solver.``
``--constraint`` and ``--preference``.

- Any flag accepted by ``cabal install`` beyond ``./Setup configure``.

Expand Down
4 changes: 4 additions & 0 deletions doc/cabal-project-description-file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,10 @@ Most users generally won't need these.

The command line variant of this field is ``--solver=modular``.

.. warning::

This CLI option has been deprecated and will be removed in a future release.

.. cfg-field:: max-backjumps: nat
--max-backjumps=N
:synopsis: Maximum number of solver backjumps.
Expand Down
Loading