diff --git a/Cabal/src/Distribution/Types/BuildType.hs b/Cabal/src/Distribution/Types/BuildType.hs index d7503701fa7..c9ace093640 100644 --- a/Cabal/src/Distribution/Types/BuildType.hs +++ b/Cabal/src/Distribution/Types/BuildType.hs @@ -25,7 +25,7 @@ data BuildType -- information used by later phases. | Make -- ^ calls @Distribution.Make.defaultMain@ | Custom -- ^ uses user-supplied @Setup.hs@ or @Setup.lhs@ (default) - deriving (Generic, Show, Read, Eq, Typeable, Data) + deriving (Generic, Show, Read, Eq, Ord, Typeable, Data) instance Binary BuildType instance Structured BuildType diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/Builder.hs b/cabal-install-solver/src/Distribution/Solver/Modular/Builder.hs index 5d196f4fd9f..6eec820d6cf 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/Builder.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/Builder.hs @@ -89,6 +89,7 @@ extendOpen qpn' gs s@(BS { rdeps = gs', open = o' }) = go gs' o' gs go g o ((Simple (LDep _dr (Ext _ext )) _) : ngs) = go g o ngs go g o ((Simple (LDep _dr (Lang _lang))_) : ngs) = go g o ngs go g o ((Simple (LDep _dr (Pkg _pn _vr))_) : ngs) = go g o ngs + go g o ((Simple (LDep _dr (BT _bt))_) : ngs) = go g o ngs addIfAbsent :: Eq a => a -> [a] -> [a] addIfAbsent x xs = if x `elem` xs then xs else x : xs diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/Dependency.hs b/cabal-install-solver/src/Distribution/Solver/Modular/Dependency.hs index 6b2fdba447b..3c890052135 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/Dependency.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/Dependency.hs @@ -58,6 +58,7 @@ import Distribution.Solver.Types.PackagePath import Distribution.Types.LibraryName import Distribution.Types.PkgconfigVersionRange import Distribution.Types.UnqualComponentName +import qualified Distribution.Types.BuildType as C {------------------------------------------------------------------------------- Constrained instances @@ -123,6 +124,7 @@ data Dep qpn = Dep (PkgComponent qpn) CI -- ^ dependency on a package component | Ext Extension -- ^ dependency on a language extension | Lang Language -- ^ dependency on a language version | Pkg PkgconfigName PkgconfigVersionRange -- ^ dependency on a pkg-config package + | BT C.BuildType -- ^ dependency on a build-type. deriving Functor -- | An exposed component within a package. This type is used to represent @@ -200,6 +202,7 @@ qualifyDeps QO{..} (Q pp@(PackagePath ns q) pn) = go goD (Ext ext) _ = Ext ext goD (Lang lang) _ = Lang lang goD (Pkg pkn vr) _ = Pkg pkn vr + goD (BT bt) _ = BT bt goD (Dep dep@(PkgComponent qpn (ExposedExe _)) ci) _ = Dep (Q (PackagePath ns (QualExe pn qpn)) <$> dep) ci goD (Dep dep@(PkgComponent qpn (ExposedLib _)) ci) comp diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs b/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs index 72d0b8193e3..bd10905e25c 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/IndexConversion.hs @@ -344,6 +344,7 @@ convCondTree flags dr pkg os arch cinfo pn fds comp getInfo solveExes@(SolveExec ++ L.map (\e -> D.Simple (LDep dr (Ext e)) comp) (allExtensions bi) -- unconditional extension dependencies ++ L.map (\l -> D.Simple (LDep dr (Lang l)) comp) (allLanguages bi) -- unconditional language dependencies ++ L.map (\(PkgconfigDependency pkn vr) -> D.Simple (LDep dr (Pkg pkn vr)) comp) (pkgconfigDepends bi) -- unconditional pkg-config dependencies + ++ [D.Simple (LDep dr (BT (buildType pkg))) comp] ++ concatMap (convBranch flags dr pkg os arch cinfo pn fds comp getInfo solveExes) branches -- build-tools dependencies -- NB: Only include these dependencies if SolveExecutables diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/Linking.hs b/cabal-install-solver/src/Distribution/Solver/Modular/Linking.hs index 1977685a7be..a87c4ae3d86 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/Linking.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/Linking.hs @@ -270,6 +270,7 @@ linkDeps target = \deps -> do (Simple (LDep _ (Ext _)) _, _) -> return () (Simple (LDep _ (Lang _)) _, _) -> return () (Simple (LDep _ (Pkg _ _)) _, _) -> return () + (Simple (LDep _ (BT _)) _, _) -> return () requalify :: FlaggedDeps QPN -> UpdateState (FlaggedDeps QPN) requalify deps = do diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/Message.hs b/cabal-install-solver/src/Distribution/Solver/Modular/Message.hs index eade1c3a1a0..36d3b3a86c7 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/Message.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/Message.hs @@ -219,6 +219,7 @@ showGR (DependencyGoal dr) = " (dependency of " ++ showDependencyReason dr ++ ") showFR :: ConflictSet -> FailReason -> String showFR _ (UnsupportedExtension ext) = " (conflict: requires " ++ showUnsupportedExtension ext ++ ")" showFR _ (UnsupportedLanguage lang) = " (conflict: requires " ++ showUnsupportedLanguage lang ++ ")" +showFR _ (UnsupportedBuildType bt) = " (conflict: disallowed build-type " ++ prettyShow bt ++ ")" showFR _ (MissingPkgconfigPackage pn vr) = " (conflict: pkg-config package " ++ prettyShow pn ++ prettyShow vr ++ ", not found in the pkg-config database)" showFR _ (NewPackageDoesNotMatchExistingConstraint d) = " (conflict: " ++ showConflictingDep d ++ ")" showFR _ (ConflictingConstraints d1 d2) = " (conflict: " ++ L.intercalate ", " (L.map showConflictingDep [d1, d2]) ++ ")" diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs b/cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs index da5fa569633..91f541e077e 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/Solver.hs @@ -44,6 +44,7 @@ import Distribution.Solver.Modular.Tree import qualified Distribution.Solver.Modular.PSQ as PSQ import Distribution.Simple.Setup (BooleanFlag(..)) +import qualified Distribution.Types.BuildType as C #ifdef DEBUG_TRACETREE import qualified Distribution.Solver.Modular.ConflictSet as CS @@ -68,6 +69,7 @@ data SolverConfig = SolverConfig { strongFlags :: StrongFlags, allowBootLibInstalls :: AllowBootLibInstalls, onlyConstrained :: OnlyConstrained, + buildTypes :: Maybe (S.Set C.BuildType), maxBackjumps :: Maybe Int, enableBackjumping :: EnableBackjumping, solveExecutables :: SolveExecutables, @@ -138,7 +140,7 @@ solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals = P.enforceManualFlags userConstraints validationCata = P.enforceSingleInstanceRestriction . validateLinking idx . - validateTree cinfo idx pkgConfigDB + validateTree cinfo idx pkgConfigDB (buildTypes sc) prunePhase = (if asBool (avoidReinstalls sc) then P.avoidReinstalls (const True) else id) . (if asBool (allowBootLibInstalls sc) then id diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/Tree.hs b/cabal-install-solver/src/Distribution/Solver/Modular/Tree.hs index 039da4b41b0..c8cd35349e7 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/Tree.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/Tree.hs @@ -36,6 +36,7 @@ import Distribution.Solver.Types.PackagePath import Distribution.Types.PkgconfigVersionRange import Distribution.Types.UnitId (UnitId) import Language.Haskell.Extension (Extension, Language) +import qualified Distribution.Types.BuildType as C type Weight = Double @@ -129,6 +130,7 @@ data FailReason = UnsupportedExtension Extension | DependenciesNotLinked String | CyclicDependencies | UnsupportedSpecVer Ver + | UnsupportedBuildType C.BuildType deriving (Eq, Show) -- | Information about a dependency involved in a conflict, for error messages. diff --git a/cabal-install-solver/src/Distribution/Solver/Modular/Validate.hs b/cabal-install-solver/src/Distribution/Solver/Modular/Validate.hs index db383c4ce22..45709be6f09 100644 --- a/cabal-install-solver/src/Distribution/Solver/Modular/Validate.hs +++ b/cabal-install-solver/src/Distribution/Solver/Modular/Validate.hs @@ -38,6 +38,7 @@ import Distribution.Solver.Types.PackagePath import Distribution.Solver.Types.PkgConfigDb (PkgConfigDb, pkgConfigPkgIsPresent) import Distribution.Types.LibraryName import Distribution.Types.PkgconfigVersionRange +import qualified Distribution.Types.BuildType as C #ifdef DEBUG_CONFLICT_SETS import GHC.Stack (CallStack) @@ -97,6 +98,7 @@ import GHC.Stack (CallStack) data ValidateState = VS { supportedExt :: Extension -> Bool, supportedLang :: Language -> Bool, + supportedBuildType :: C.BuildType -> Bool, presentPkgs :: PkgconfigName -> PkgconfigVersionRange -> Bool, index :: Index, @@ -202,6 +204,7 @@ validate = go PA ppa pfa psa <- asks pa -- obtain current preassignment extSupported <- asks supportedExt -- obtain the supported extensions langSupported <- asks supportedLang -- obtain the supported languages + btypeSupported <- asks supportedBuildType pkgPresent <- asks presentPkgs -- obtain the present pkg-config pkgs idx <- asks index -- obtain the index svd <- asks saved -- obtain saved dependencies @@ -216,7 +219,7 @@ validate = go -- plus the dependency information we have for that instance let newactives = extractAllDeps pfa psa qdeps -- We now try to extend the partial assignment with the new active constraints. - let mnppa = extend extSupported langSupported pkgPresent newactives + let mnppa = extend extSupported langSupported btypeSupported pkgPresent newactives =<< extendWithPackageChoice (PI qpn i) ppa -- In case we continue, we save the scoped dependencies let nsvd = M.insert qpn qdeps svd @@ -246,6 +249,7 @@ validate = go PA ppa pfa psa <- asks pa -- obtain current preassignment extSupported <- asks supportedExt -- obtain the supported extensions langSupported <- asks supportedLang -- obtain the supported languages + btypeSupported <- asks supportedBuildType pkgPresent <- asks presentPkgs -- obtain the present pkg-config pkgs svd <- asks saved -- obtain saved dependencies aComps <- asks availableComponents @@ -264,7 +268,7 @@ validate = go let newactives = extractNewDeps (F qfn) b npfa psa qdeps mNewRequiredComps = extendRequiredComponents qpn aComps rComps newactives -- As in the package case, we try to extend the partial assignment. - let mnppa = extend extSupported langSupported pkgPresent newactives ppa + let mnppa = extend extSupported langSupported btypeSupported pkgPresent newactives ppa case liftM2 (,) mnppa mNewRequiredComps of Left (c, fr) -> return (Fail c fr) -- inconsistency found Right (nppa, rComps') -> @@ -276,6 +280,7 @@ validate = go PA ppa pfa psa <- asks pa -- obtain current preassignment extSupported <- asks supportedExt -- obtain the supported extensions langSupported <- asks supportedLang -- obtain the supported languages + btypeSupported <- asks supportedBuildType pkgPresent <- asks presentPkgs -- obtain the present pkg-config pkgs svd <- asks saved -- obtain saved dependencies aComps <- asks availableComponents @@ -294,7 +299,7 @@ validate = go let newactives = extractNewDeps (S qsn) b pfa npsa qdeps mNewRequiredComps = extendRequiredComponents qpn aComps rComps newactives -- As in the package case, we try to extend the partial assignment. - let mnppa = extend extSupported langSupported pkgPresent newactives ppa + let mnppa = extend extSupported langSupported btypeSupported pkgPresent newactives ppa case liftM2 (,) mnppa mNewRequiredComps of Left (c, fr) -> return (Fail c fr) -- inconsistency found Right (nppa, rComps') -> @@ -390,11 +395,12 @@ extractNewDeps v b fa sa = go -- or the successfully extended assignment. extend :: (Extension -> Bool) -- ^ is a given extension supported -> (Language -> Bool) -- ^ is a given language supported + -> (C.BuildType -> Bool) -- ^ is a given build-type supported -> (PkgconfigName -> PkgconfigVersionRange -> Bool) -- ^ is a given pkg-config requirement satisfiable -> [LDep QPN] -> PPreAssignment -> Either Conflict PPreAssignment -extend extSupported langSupported pkgPresent newactives ppa = foldM extendSingle ppa newactives +extend extSupported langSupported btypeSupported pkgPresent newactives ppa = foldM extendSingle ppa newactives where extendSingle :: PPreAssignment -> LDep QPN -> Either Conflict PPreAssignment @@ -407,6 +413,9 @@ extend extSupported langSupported pkgPresent newactives ppa = foldM extendSingle extendSingle a (LDep dr (Pkg pn vr)) = if pkgPresent pn vr then Right a else Left (dependencyReasonToConflictSet dr, MissingPkgconfigPackage pn vr) + extendSingle a (LDep dr (BT bt)) = + if btypeSupported bt then Right a + else Left (dependencyReasonToConflictSet dr, UnsupportedBuildType bt) extendSingle a (LDep dr (Dep dep@(PkgComponent qpn _) ci)) = let mergedDep = M.findWithDefault (MergedDepConstrained []) qpn a in case (\ x -> M.insert qpn x a) <$> merge mergedDep (PkgDep dr dep ci) of @@ -572,14 +581,23 @@ extendRequiredComponents eqpn available = foldM extendSingle -- | Interface. -validateTree :: CompilerInfo -> Index -> PkgConfigDb -> Tree d c -> Tree d c -validateTree cinfo idx pkgConfigDb t = runValidate (validate t) VS { +validateTree + :: CompilerInfo + -> Index + -> PkgConfigDb + -> Maybe (S.Set C.BuildType) + -> Tree d c + -> Tree d c +validateTree cinfo idx pkgConfigDb bts t = runValidate (validate t) VS { supportedExt = maybe (const True) -- if compiler has no list of extensions, we assume everything is supported (\ es -> let s = S.fromList es in \ x -> S.member x s) (compilerInfoExtensions cinfo) , supportedLang = maybe (const True) (flip L.elem) -- use list lookup because language list is small and no Ord instance (compilerInfoLanguages cinfo) + , supportedBuildType = maybe (const True) + (flip S.member) + bts , presentPkgs = pkgConfigPkgIsPresent pkgConfigDb , index = idx , saved = M.empty diff --git a/cabal-install-solver/src/Distribution/Solver/Types/PackageConstraint.hs b/cabal-install-solver/src/Distribution/Solver/Types/PackageConstraint.hs index fbe56380e81..8decc49f4c9 100644 --- a/cabal-install-solver/src/Distribution/Solver/Types/PackageConstraint.hs +++ b/cabal-install-solver/src/Distribution/Solver/Types/PackageConstraint.hs @@ -141,8 +141,8 @@ showPackageConstraint pc@(PackageConstraint scope prop) = packageConstraintToDependency :: PackageConstraint -> Maybe PackageVersionConstraint packageConstraintToDependency (PackageConstraint scope prop) = toDep prop where - toDep (PackagePropertyVersion vr) = Just $ PackageVersionConstraint (scopeToPackageName scope) vr - toDep (PackagePropertyInstalled) = Nothing - toDep (PackagePropertySource) = Nothing - toDep (PackagePropertyFlags _) = Nothing - toDep (PackagePropertyStanzas _) = Nothing + toDep (PackagePropertyVersion vr) = Just $ PackageVersionConstraint (scopeToPackageName scope) vr + toDep (PackagePropertyInstalled) = Nothing + toDep (PackagePropertySource) = Nothing + toDep (PackagePropertyFlags _) = Nothing + toDep (PackagePropertyStanzas _) = Nothing diff --git a/cabal-install/src/Distribution/Client/Config.hs b/cabal-install/src/Distribution/Client/Config.hs index 17eb0c0550f..40c74857055 100644 --- a/cabal-install/src/Distribution/Client/Config.hs +++ b/cabal-install/src/Distribution/Client/Config.hs @@ -299,6 +299,7 @@ instance Semigroup SavedConfig where installMaxBackjumps = combine installMaxBackjumps, installReorderGoals = combine installReorderGoals, installCountConflicts = combine installCountConflicts, + installBuildTypeCustom = combine installBuildTypeCustom, installFineGrainedConflicts = combine installFineGrainedConflicts, installMinimizeConflictSet = combine installMinimizeConflictSet, installIndependentGoals = combine installIndependentGoals, diff --git a/cabal-install/src/Distribution/Client/Dependency.hs b/cabal-install/src/Distribution/Client/Dependency.hs index 06308e002f0..0ca4b53b251 100644 --- a/cabal-install/src/Distribution/Client/Dependency.hs +++ b/cabal-install/src/Distribution/Client/Dependency.hs @@ -45,6 +45,7 @@ module Distribution.Client.Dependency ( setPreferenceDefault, setReorderGoals, setCountConflicts, + setBuildTypeCustom, setFineGrainedConflicts, setMinimizeConflictSet, setIndependentGoals, @@ -156,6 +157,7 @@ data DepResolverParams = DepResolverParams { depResolverAvoidReinstalls :: AvoidReinstalls, depResolverShadowPkgs :: ShadowPkgs, depResolverStrongFlags :: StrongFlags, + depResolverBuildTypeCustom :: Bool, -- | Whether to allow base and its dependencies to be installed. depResolverAllowBootLibInstalls :: AllowBootLibInstalls, @@ -195,6 +197,7 @@ showDepResolverParams p = ++ "\navoid reinstalls: " ++ show (asBool (depResolverAvoidReinstalls p)) ++ "\nshadow packages: " ++ show (asBool (depResolverShadowPkgs p)) ++ "\nstrong flags: " ++ show (asBool (depResolverStrongFlags p)) + ++ "\nbuild type custom: " ++ show (depResolverBuildTypeCustom p) ++ "\nallow boot library installs: " ++ show (asBool (depResolverAllowBootLibInstalls p)) ++ "\nonly constrained packages: " ++ show (depResolverOnlyConstrained p) ++ "\nmax backjumps: " ++ maybe "infinite" show @@ -253,6 +256,7 @@ basicDepResolverParams installedPkgIndex sourcePkgIndex = depResolverAvoidReinstalls = AvoidReinstalls False, depResolverShadowPkgs = ShadowPkgs False, depResolverStrongFlags = StrongFlags False, + depResolverBuildTypeCustom = True, depResolverAllowBootLibInstalls = AllowBootLibInstalls False, depResolverOnlyConstrained = OnlyConstrainedNone, depResolverMaxBackjumps = Nothing, @@ -304,6 +308,9 @@ setCountConflicts count params = depResolverCountConflicts = count } +setBuildTypeCustom :: Bool -> DepResolverParams -> DepResolverParams +setBuildTypeCustom x params = params { depResolverBuildTypeCustom = x } + setFineGrainedConflicts :: FineGrainedConflicts -> DepResolverParams -> DepResolverParams setFineGrainedConflicts fineGrained params = params { @@ -705,14 +712,15 @@ resolveDependencies platform comp pkgConfigDB solver params = Step (showDepResolverParams finalparams) $ fmap (validateSolverResult platform comp indGoals) - $ runSolver solver (SolverConfig reordGoals cntConflicts fineGrained minimize - indGoals noReinstalls - shadowing strFlags allowBootLibs onlyConstrained_ maxBkjumps enableBj - solveExes order verbosity (PruneAfterFirstSuccess False)) + $ runSolver solver solverConfig platform comp installedPkgIndex sourcePkgIndex pkgConfigDB preferences constraints targets where - + solverConfig = SolverConfig reordGoals cntConflicts fineGrained minimize + indGoals noReinstalls + shadowing strFlags allowBootLibs onlyConstrained_ buildTypeCustom_ maxBkjumps enableBj + solveExes order verbosity (PruneAfterFirstSuccess False) + buildTypeCustom_ = if buildTypeCustom then Nothing else Just $ Set.fromList [PD.Simple, PD.Configure, PD.Make] finalparams@(DepResolverParams targets constraints prefs defpref @@ -726,6 +734,7 @@ resolveDependencies platform comp pkgConfigDB solver params = noReinstalls shadowing strFlags + buildTypeCustom allowBootLibs onlyConstrained_ maxBkjumps @@ -992,7 +1001,7 @@ resolveWithoutDependencies (DepResolverParams targets constraints prefs defpref installedPkgIndex sourcePkgIndex _reorderGoals _countConflicts _fineGrained _minimizeConflictSet _indGoals _avoidReinstalls - _shadowing _strFlags _maxBjumps _enableBj _solveExes + _shadowing _strFlags _buildTypeCustom _maxBjumps _enableBj _solveExes _allowBootLibInstalls _onlyConstrained _order _verbosity) = collectEithers $ map selectPackage (Set.toList targets) where diff --git a/cabal-install/src/Distribution/Client/ProjectConfig.hs b/cabal-install/src/Distribution/Client/ProjectConfig.hs index 766f35e50ae..2ef54be8ae4 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig.hs @@ -251,6 +251,7 @@ resolveSolverSettings ProjectConfig{ solverSettingAllowBootLibInstalls = fromFlag projectConfigAllowBootLibInstalls solverSettingOnlyConstrained = fromFlag projectConfigOnlyConstrained solverSettingIndexState = flagToMaybe projectConfigIndexState + solverSettingBuildTypeCustom = fromFlag projectConfigBuildTypeCustom solverSettingActiveRepos = flagToMaybe projectConfigActiveRepos solverSettingIndependentGoals = fromFlag projectConfigIndependentGoals --solverSettingShadowPkgs = fromFlag projectConfigShadowPkgs diff --git a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs b/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs index 410d9531cea..d17c6d69f6e 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs @@ -380,6 +380,7 @@ convertLegacyAllPackageFlags globalFlags configFlags configExFlags installFlags --installUpgradeDeps = projectConfigUpgradeDeps, installReorderGoals = projectConfigReorderGoals, installCountConflicts = projectConfigCountConflicts, + installBuildTypeCustom = projectConfigBuildTypeCustom, installFineGrainedConflicts = projectConfigFineGrainedConflicts, installMinimizeConflictSet = projectConfigMinimizeConflictSet, installPerComponent = projectConfigPerComponent, @@ -622,6 +623,7 @@ convertToLegacySharedConfig installUpgradeDeps = mempty, --projectConfigUpgradeDeps, installReorderGoals = projectConfigReorderGoals, installCountConflicts = projectConfigCountConflicts, + installBuildTypeCustom = projectConfigBuildTypeCustom, installFineGrainedConflicts = projectConfigFineGrainedConflicts, installMinimizeConflictSet = projectConfigMinimizeConflictSet, installIndependentGoals = projectConfigIndependentGoals, @@ -1025,7 +1027,7 @@ legacySharedConfigFieldDescrs constraintSrc = concat , "remote-build-reporting", "report-planning-failure" , "jobs", "keep-going", "offline", "per-component" -- solver flags: - , "max-backjumps", "reorder-goals", "count-conflicts" + , "max-backjumps", "reorder-goals", "count-conflicts", "build-type-custom" , "fine-grained-conflicts" , "minimize-conflict-set", "independent-goals" , "strong-flags" , "allow-boot-library-installs" , "reject-unconstrained-dependencies", "index-state" diff --git a/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs b/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs index 84996b2a0cf..aba2b21edeb 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs @@ -196,6 +196,7 @@ data ProjectConfigShared projectConfigMaxBackjumps :: Flag Int, projectConfigReorderGoals :: Flag ReorderGoals, projectConfigCountConflicts :: Flag CountConflicts, + projectConfigBuildTypeCustom :: Flag Bool, projectConfigFineGrainedConflicts :: Flag FineGrainedConflicts, projectConfigMinimizeConflictSet :: Flag MinimizeConflictSet, projectConfigStrongFlags :: Flag StrongFlags, @@ -409,6 +410,7 @@ data SolverSettings solverSettingAllowBootLibInstalls :: AllowBootLibInstalls, solverSettingOnlyConstrained :: OnlyConstrained, solverSettingIndexState :: Maybe TotalIndexState, + solverSettingBuildTypeCustom :: Bool, solverSettingActiveRepos :: Maybe ActiveRepos, solverSettingIndependentGoals :: IndependentGoals -- Things that only make sense for manual mode, not --local mode diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index 906f56d222b..843488d7671 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -1024,6 +1024,8 @@ planPackages verbosity comp platform solver SolverSettings{..} . setCountConflicts solverSettingCountConflicts + . setBuildTypeCustom solverSettingBuildTypeCustom + . setFineGrainedConflicts solverSettingFineGrainedConflicts . setMinimizeConflictSet solverSettingMinimizeConflictSet diff --git a/cabal-install/src/Distribution/Client/Setup.hs b/cabal-install/src/Distribution/Client/Setup.hs index 3cafcbed57b..858f3b15b87 100644 --- a/cabal-install/src/Distribution/Client/Setup.hs +++ b/cabal-install/src/Distribution/Client/Setup.hs @@ -930,6 +930,7 @@ data FetchFlags = FetchFlags { fetchSolver :: Flag PreSolver, fetchMaxBackjumps :: Flag Int, fetchReorderGoals :: Flag ReorderGoals, + fetchBuildTypeCustom :: Flag Bool, fetchCountConflicts :: Flag CountConflicts, fetchFineGrainedConflicts :: Flag FineGrainedConflicts, fetchMinimizeConflictSet :: Flag MinimizeConflictSet, @@ -950,6 +951,7 @@ defaultFetchFlags = FetchFlags { fetchDryRun = toFlag False, fetchSolver = Flag defaultSolver, fetchMaxBackjumps = Flag defaultMaxBackjumps, + fetchBuildTypeCustom = Flag True, fetchReorderGoals = Flag (ReorderGoals False), fetchCountConflicts = Flag (CountConflicts True), fetchFineGrainedConflicts = Flag (FineGrainedConflicts True), @@ -1015,6 +1017,7 @@ fetchCommand = CommandUI { fetchMaxBackjumps (\v flags -> flags { fetchMaxBackjumps = v }) fetchReorderGoals (\v flags -> flags { fetchReorderGoals = v }) fetchCountConflicts (\v flags -> flags { fetchCountConflicts = v }) + fetchBuildTypeCustom (\v flags -> flags { fetchBuildTypeCustom = v }) fetchFineGrainedConflicts (\v flags -> flags { fetchFineGrainedConflicts = v }) fetchMinimizeConflictSet (\v flags -> flags { fetchMinimizeConflictSet = v }) fetchIndependentGoals (\v flags -> flags { fetchIndependentGoals = v }) @@ -1037,6 +1040,7 @@ data FreezeFlags = FreezeFlags { freezeMaxBackjumps :: Flag Int, freezeReorderGoals :: Flag ReorderGoals, freezeCountConflicts :: Flag CountConflicts, + freezeBuildTypeCustom :: Flag Bool, freezeFineGrainedConflicts :: Flag FineGrainedConflicts, freezeMinimizeConflictSet :: Flag MinimizeConflictSet, freezeIndependentGoals :: Flag IndependentGoals, @@ -1056,6 +1060,7 @@ defaultFreezeFlags = FreezeFlags { freezeMaxBackjumps = Flag defaultMaxBackjumps, freezeReorderGoals = Flag (ReorderGoals False), freezeCountConflicts = Flag (CountConflicts True), + freezeBuildTypeCustom = Flag True, freezeFineGrainedConflicts = Flag (FineGrainedConflicts True), freezeMinimizeConflictSet = Flag (MinimizeConflictSet False), freezeIndependentGoals = Flag (IndependentGoals False), @@ -1110,6 +1115,7 @@ freezeCommand = CommandUI { freezeMaxBackjumps (\v flags -> flags { freezeMaxBackjumps = v }) freezeReorderGoals (\v flags -> flags { freezeReorderGoals = v }) freezeCountConflicts (\v flags -> flags { freezeCountConflicts = v }) + freezeBuildTypeCustom (\v flags -> flags { freezeBuildTypeCustom = v }) freezeFineGrainedConflicts (\v flags -> flags { freezeFineGrainedConflicts = v }) freezeMinimizeConflictSet (\v flags -> flags { freezeMinimizeConflictSet = v }) freezeIndependentGoals (\v flags -> flags { freezeIndependentGoals = v }) @@ -1544,6 +1550,7 @@ data InstallFlags = InstallFlags { installMaxBackjumps :: Flag Int, installReorderGoals :: Flag ReorderGoals, installCountConflicts :: Flag CountConflicts, + installBuildTypeCustom :: Flag Bool, installFineGrainedConflicts :: Flag FineGrainedConflicts, installMinimizeConflictSet :: Flag MinimizeConflictSet, installIndependentGoals :: Flag IndependentGoals, @@ -1586,6 +1593,7 @@ defaultInstallFlags = InstallFlags { installMaxBackjumps = Flag defaultMaxBackjumps, installReorderGoals = Flag (ReorderGoals False), installCountConflicts = Flag (CountConflicts True), + installBuildTypeCustom = Flag True, installFineGrainedConflicts = Flag (FineGrainedConflicts True), installMinimizeConflictSet = Flag (MinimizeConflictSet False), installIndependentGoals= Flag (IndependentGoals False), @@ -1811,6 +1819,7 @@ installOptions showOrParseArgs = installMaxBackjumps (\v flags -> flags { installMaxBackjumps = v }) installReorderGoals (\v flags -> flags { installReorderGoals = v }) installCountConflicts (\v flags -> flags { installCountConflicts = v }) + installBuildTypeCustom (\v flags -> flags { installBuildTypeCustom = v }) installFineGrainedConflicts (\v flags -> flags { installFineGrainedConflicts = v }) installMinimizeConflictSet (\v flags -> flags { installMinimizeConflictSet = v }) installIndependentGoals (\v flags -> flags { installIndependentGoals = v }) @@ -2387,6 +2396,7 @@ optionSolverFlags :: ShowOrParseArgs -> (flags -> Flag Int ) -> (Flag Int -> flags -> flags) -> (flags -> Flag ReorderGoals) -> (Flag ReorderGoals -> flags -> flags) -> (flags -> Flag CountConflicts) -> (Flag CountConflicts -> flags -> flags) + -> (flags -> Flag Bool) -> (Flag Bool -> flags -> flags) -> (flags -> Flag FineGrainedConflicts) -> (Flag FineGrainedConflicts -> flags -> flags) -> (flags -> Flag MinimizeConflictSet) -> (Flag MinimizeConflictSet -> flags -> flags) -> (flags -> Flag IndependentGoals) -> (Flag IndependentGoals -> flags -> flags) @@ -2395,7 +2405,7 @@ optionSolverFlags :: ShowOrParseArgs -> (flags -> Flag AllowBootLibInstalls) -> (Flag AllowBootLibInstalls -> flags -> flags) -> (flags -> Flag OnlyConstrained) -> (Flag OnlyConstrained -> flags -> flags) -> [OptionField flags] -optionSolverFlags showOrParseArgs getmbj setmbj getrg setrg getcc setcc +optionSolverFlags showOrParseArgs getmbj setmbj getrg setrg getcc setcc getbtcustom setbtcustom getfgc setfgc getmc setmc getig setig getsip setsip getstrfl setstrfl getib setib getoc setoc = [ option [] ["max-backjumps"] @@ -2408,6 +2418,11 @@ optionSolverFlags showOrParseArgs getmbj setmbj getrg setrg getcc setcc (fmap asBool . getrg) (setrg . fmap ReorderGoals) (yesNoOpt showOrParseArgs) + , option [] ["build-type-custom"] + "Allow build-type: Custom packages." + getbtcustom + setbtcustom + (yesNoOpt showOrParseArgs) , option [] ["count-conflicts"] "Try to speed up solving by preferring goals that are involved in a lot of conflicts (default)." (fmap asBool . getcc) diff --git a/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs b/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs index f020bd3abf1..d4ce706ffdd 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs @@ -477,6 +477,7 @@ instance Arbitrary ProjectConfigShared where projectConfigAllowBootLibInstalls <- arbitrary projectConfigOnlyConstrained <- arbitrary projectConfigPerComponent <- arbitrary + projectConfigBuildTypeCustom <- arbitrary projectConfigIndependentGoals <- arbitrary projectConfigProgPathExtra <- toNubList <$> listOf arbitraryShortToken return ProjectConfigShared {..} @@ -509,6 +510,7 @@ instance Arbitrary ProjectConfigShared where <*> shrinker projectConfigMaxBackjumps <*> shrinker projectConfigReorderGoals <*> shrinker projectConfigCountConflicts + <*> shrinker projectConfigBuildTypeCustom <*> shrinker projectConfigFineGrainedConflicts <*> shrinker projectConfigMinimizeConflictSet <*> shrinker projectConfigStrongFlags diff --git a/doc/cabal-project.rst b/doc/cabal-project.rst index 23083f9d0a9..ad7a98ec314 100644 --- a/doc/cabal-project.rst +++ b/doc/cabal-project.rst @@ -1622,6 +1622,16 @@ Most users generally won't need these. The command line variant of this field is ``--(no-)strong-flags``. +.. cfg-field:: build-type-custom: boolean + --build-type-custom + --no-build-type-custom: + :synopsis: Allow solver to select packages which use :pkg-field:`build-type` ``Custom`` + + :default: True + + Allow (or disallow) the dependency solver to select packages which + use :pkg-field:`build-type` ``Custom``. + .. cfg-field:: allow-boot-library-installs: boolean --allow-boot-library-installs --no-allow-boot-library-installs