From 4e06f1a8d0b444a1ee896b5ed28be7cb6409eae4 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 10 Jul 2016 14:40:02 -0400 Subject: [PATCH 1/5] cabal-install uses internal libraries. There are lots of benefits: * We only build solver code once, instead of repeatedly rebuilding it for each test suite. * Duplication in the cabal-install file is greatly reduced. There is one downside, which is that we don't rebuild cabal-install with asserts turned on. I think we should look into making this a runtime toggleable chunk of code. Signed-off-by: Edward Z. Yang --- cabal-install/cabal-install.cabal | 158 +++++++----------------------- cabal-install/{ => main}/Main.hs | 0 2 files changed, 36 insertions(+), 122 deletions(-) rename cabal-install/{ => main}/Main.hs (100%) diff --git a/cabal-install/cabal-install.cabal b/cabal-install/cabal-install.cabal index 310ccf292e8..538d515e9bc 100644 --- a/cabal-install/cabal-install.cabal +++ b/cabal-install/cabal-install.cabal @@ -14,7 +14,7 @@ Maintainer: Cabal Development Team Copyright: 2003-2016, Cabal Development Team Category: Distribution Build-type: Custom -Cabal-Version: >= 1.10 +Cabal-Version: >= 1.23 Extra-Source-Files: README.md bash-completion/cabal bootstrap.sh changelog tests/README.md @@ -176,15 +176,14 @@ Flag debug-tracetree description: Compile in support for tracetree (used to debug the solver) default: False -executable cabal - main-is: Main.hs +library cabal-install-internal ghc-options: -Wall -fwarn-tabs if impl(ghc >= 8.0) ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances - other-modules: + exposed-modules: Distribution.Client.BuildTarget Distribution.Client.BuildReports.Anonymous Distribution.Client.BuildReports.Storage @@ -361,9 +360,6 @@ executable cabal else build-depends: unix >= 2.5 && < 2.8 - if !(arch(arm) && impl(ghc < 7.6)) - ghc-options: -threaded - if flag(debug-conflict-sets) cpp-options: -DDEBUG_CONFLICT_SETS build-depends: base >= 4.8 @@ -374,11 +370,33 @@ executable cabal default-language: Haskell2010 +executable cabal + main-is: Main.hs + hs-source-dirs: main + + ghc-options: -Wall -fwarn-tabs + if impl(ghc >= 8.0) + ghc-options: -Wcompat + -Wnoncanonical-monad-instances + -Wnoncanonical-monadfail-instances + + build-depends: + cabal-install-internal, + Cabal >= 1.25 && < 1.26, + base, + directory, + filepath + + if !(arch(arm) && impl(ghc < 7.6)) + ghc-options: -threaded + + default-language: Haskell2010 + -- Small, fast running tests. Test-Suite unit-tests type: exitcode-stdio-1.0 main-is: UnitTests.hs - hs-source-dirs: tests, . + hs-source-dirs: tests ghc-options: -Wall -fwarn-tabs other-modules: UnitTests.Distribution.Client.ArbitraryInstances @@ -398,120 +416,50 @@ Test-Suite unit-tests UnitTests.Options build-depends: base, - array, bytestring, + cabal-install-internal, Cabal, containers, mtl, - pretty, - process, directory, filepath, - hashable, - stm, tar, - time, - HTTP, zlib, - binary, - random, - hackage-security, + network-uri, + network, tasty, tasty-hunit, tasty-quickcheck, tagged, QuickCheck >= 2.8.2 - if flag(old-directory) - build-depends: old-time - - if flag(network-uri) - build-depends: network-uri >= 2.6, network >= 2.6 - else - build-depends: network-uri < 2.6, network < 2.6 - - if impl(ghc < 7.6) - build-depends: ghc-prim >= 0.2 && < 0.3 - - if os(windows) - build-depends: Win32 - else - build-depends: unix - if !(arch(arm) && impl(ghc < 7.6)) ghc-options: -threaded - if flag(debug-conflict-sets) - cpp-options: -DDEBUG_CONFLICT_SETS - build-depends: base >= 4.8 - - if flag(debug-tracetree) - cpp-options: -DDEBUG_TRACETREE - build-depends: tracetree >= 0.1 && < 0.2 - default-language: Haskell2010 -- Slow solver tests Test-Suite solver-quickcheck type: exitcode-stdio-1.0 main-is: SolverQuickCheck.hs - hs-source-dirs: tests, . + hs-source-dirs: tests ghc-options: -Wall -fwarn-tabs other-modules: UnitTests.Distribution.Solver.Modular.DSL UnitTests.Distribution.Solver.Modular.QuickCheck build-depends: base, - array, - bytestring, + cabal-install-internal, Cabal, containers, - mtl, - pretty, - process, - directory, - filepath, - hashable, - stm, - tar, - time, - HTTP, - zlib, - binary, - random, - hackage-security, tasty, tasty-quickcheck, QuickCheck >= 2.8.2, pretty-show - if flag(old-directory) - build-depends: old-time - - if flag(network-uri) - build-depends: network-uri >= 2.6, network >= 2.6 - else - build-depends: network-uri < 2.6, network < 2.6 - - if impl(ghc < 7.6) - build-depends: ghc-prim >= 0.2 && < 0.3 - - if os(windows) - build-depends: Win32 - else - build-depends: unix - if !(arch(arm) && impl(ghc < 7.6)) ghc-options: -threaded - if flag(debug-conflict-sets) - cpp-options: -DDEBUG_CONFLICT_SETS - build-depends: base >= 4.8 - - if flag(debug-tracetree) - cpp-options: -DDEBUG_TRACETREE - build-depends: tracetree >= 0.1 && < 0.2 - default-language: Haskell2010 -- Integration tests that call the cabal executable externally @@ -547,56 +495,22 @@ test-suite integration-tests test-suite integration-tests2 type: exitcode-stdio-1.0 main-is: IntegrationTests2.hs - hs-source-dirs: tests, . - ghc-options: -Wall -fwarn-tabs -fno-ignore-asserts - other-modules: + hs-source-dirs: tests + ghc-options: -Wall -fwarn-tabs build-depends: - async, - array, base, - base16-bytestring, - binary, - bytestring, + cabal-install-internal, Cabal, containers, - cryptohash-sha256, directory, filepath, - hackage-security, - hashable, - HTTP, - mtl, - network, - network-uri, - pretty, - process, - random, - stm, - tar, - time, - zlib, tasty, tasty-hunit, tagged - if flag(old-bytestring) - build-depends: bytestring-builder - - if flag(old-directory) - build-depends: old-time - - if impl(ghc < 7.6) - build-depends: ghc-prim >= 0.2 && < 0.3 - - if os(windows) - build-depends: Win32 - else - build-depends: unix - - if arch(arm) - cc-options: -DCABAL_NO_THREADED - else + if !(arch(arm) && impl(ghc < 7.6)) ghc-options: -threaded + default-language: Haskell2010 custom-setup diff --git a/cabal-install/Main.hs b/cabal-install/main/Main.hs similarity index 100% rename from cabal-install/Main.hs rename to cabal-install/main/Main.hs From 02f32afaee99f703b6078339d863f46d5350ced4 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 11 Jul 2016 01:06:57 -0400 Subject: [PATCH 2/5] Fix Haddock syntax in cabal-install. A side effect of making cabal-install an internal library is that Haddock now generates documentation for it. Make sure that all of our comments are valid! Signed-off-by: Edward Z. Yang --- .../Client/Dependency/TopDown/Constraints.hs | 24 +++++++++++-------- .../Distribution/Client/Init/Heuristics.hs | 13 +++++----- .../Distribution/Client/ProjectPlanning.hs | 8 +++---- cabal-install/Distribution/Client/Sandbox.hs | 2 +- cabal-install/Distribution/Client/Setup.hs | 4 ++-- .../Distribution/Solver/Modular/Solver.hs | 16 ++++++------- 6 files changed, 36 insertions(+), 31 deletions(-) diff --git a/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs b/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs index d13566416b5..d23098a8d77 100644 --- a/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs +++ b/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs @@ -76,27 +76,29 @@ import Control.Exception -- constraints. -- data Constraints installed source reason - = Constraints + = Constraints { -- | Targets that we know we need. This is the set for which we -- guarantee the constraints are satisfiable. - !(Set PackageName) + constraintsTargets :: !(Set PackageName), -- | The available/remaining set. These are packages that have available -- choices remaining. This is guaranteed to cover the target packages, -- but can also cover other packages in the environment. New targets can -- only be added if there are available choices remaining for them. - !(PackageIndex (InstalledOrSource installed source)) + constraintsAvailable :: !(PackageIndex (InstalledOrSource installed source)), -- | The excluded set. Choices that we have excluded by applying -- constraints. Excluded choices are tagged with the reason. - !(PackageIndex (ExcludedPkg (InstalledOrSource installed source) reason)) + constraintsExcluded :: !(PackageIndex (ExcludedPkg (InstalledOrSource installed source) reason)), -- | Paired choices, this is an ugly hack. - !(Map PackageName (Version, Version)) + constraintsPaired :: !(Map PackageName (Version, Version)), -- | Purely for the invariant, we keep a copy of the original index - !(PackageIndex (InstalledOrSource installed source)) + constraintsIndex :: !(PackageIndex (InstalledOrSource installed source)) + + } -- | Reasons for excluding all, or some choices for a package version. @@ -106,10 +108,12 @@ data Constraints installed source reason -- from reasons for constraints that excluded just one instance. -- data ExcludedPkg pkg reason - = ExcludedPkg pkg - [reason] -- ^ reasons for excluding both source and installed instances - [reason] -- ^ reasons for excluding the installed instance - [reason] -- ^ reasons for excluding the source instance + = ExcludedPkg { + excludedPkg :: pkg, + excludedPkgSrcInstReasons :: [reason], -- ^ reasons for excluding both source and installed instances + excludedPkgInstReasons :: [reason], -- ^ reasons for excluding the installed instance + excludedPkgSrcReasons :: [reason] -- ^ reasons for excluding the source instance + } instance Package pkg => Package (ExcludedPkg pkg reason) where packageId (ExcludedPkg p _ _ _) = packageId p diff --git a/cabal-install/Distribution/Client/Init/Heuristics.hs b/cabal-install/Distribution/Client/Init/Heuristics.hs index b0175a2fafa..1456de84f6f 100644 --- a/cabal-install/Distribution/Client/Init/Heuristics.hs +++ b/cabal-install/Distribution/Client/Init/Heuristics.hs @@ -278,12 +278,13 @@ authorGuessIO = AuthorGuessIO type AuthorGuess = (Flag String, Flag String) type Enviro = [(String, String)] data GitLoc = Local | Global -data AuthorGuessIO = AuthorGuessIO - Enviro -- ^ Environment lookup table - (Maybe String) -- ^ Contents of local darcs author info - (Maybe String) -- ^ Contents of global darcs author info - AuthorGuess -- ^ Git config --local - AuthorGuess -- ^ Git config --global +data AuthorGuessIO = AuthorGuessIO { + authorGuessEnv :: Enviro, -- ^ Environment lookup table + authorGuessLocalDarcs :: (Maybe String), -- ^ Contents of local darcs author info + authorGuessGlobalDarcs :: (Maybe String), -- ^ Contents of global darcs author info + authorGuessLocalGit :: AuthorGuess, -- ^ Git config --local + authorGuessGlobalGit :: AuthorGuess -- ^ Git config --global + } darcsEnv :: Enviro -> AuthorGuess darcsEnv = maybe mempty nameAndMail . lookup "DARCS_EMAIL" diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 134c84a74fc..17aae5d70e4 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -1314,10 +1314,10 @@ elaborateInstallPlan platform compiler compilerprogdb -- package config validation/resolution pass. --TODO: [nice to have] config consistency checking: - -- * profiling libs & exes, exe needs lib, recursive - -- * shared libs & exes, exe needs lib, recursive - -- * vanilla libs & exes, exe needs lib, recursive - -- * ghci or shared lib needed by TH, recursive, ghc version dependent + -- + profiling libs & exes, exe needs lib, recursive + -- + shared libs & exes, exe needs lib, recursive + -- + vanilla libs & exes, exe needs lib, recursive + -- + ghci or shared lib needed by TH, recursive, ghc version dependent --------------------------- diff --git a/cabal-install/Distribution/Client/Sandbox.hs b/cabal-install/Distribution/Client/Sandbox.hs index 1c253f0c78b..829c3e35e7a 100644 --- a/cabal-install/Distribution/Client/Sandbox.hs +++ b/cabal-install/Distribution/Client/Sandbox.hs @@ -598,7 +598,7 @@ loadConfigOrSandboxConfig verbosity globalFlags = do -- A @cabal.sandbox.config@ file (and possibly @cabal.config@) is present. SandboxPackageEnvironment -> do (sandboxDir, pkgEnv) <- tryLoadSandboxConfig verbosity globalFlags - -- ^ Prints an error message and exits on error. + -- Prints an error message and exits on error. let config = pkgEnvSavedConfig pkgEnv return (UseSandbox sandboxDir, config) diff --git a/cabal-install/Distribution/Client/Setup.hs b/cabal-install/Distribution/Client/Setup.hs index 0d9b8579421..50f8b30622c 100644 --- a/cabal-install/Distribution/Client/Setup.hs +++ b/cabal-install/Distribution/Client/Setup.hs @@ -353,7 +353,7 @@ configureOptions = commandOptions configureCommand filterConfigureFlags :: ConfigFlags -> Version -> ConfigFlags filterConfigureFlags flags cabalLibVersion | cabalLibVersion >= Version [1,23,0] [] = flags_latest - -- ^ NB: we expect the latest version to be the most common case. + -- NB: we expect the latest version to be the most common case. | cabalLibVersion < Version [1,3,10] [] = flags_1_3_10 | cabalLibVersion < Version [1,10,0] [] = flags_1_10_0 | cabalLibVersion < Version [1,12,0] [] = flags_1_12_0 @@ -1716,7 +1716,7 @@ data SDistExFlags = SDistExFlags { } deriving (Show, Generic) -data ArchiveFormat = TargzFormat | ZipFormat -- | ... +data ArchiveFormat = TargzFormat | ZipFormat -- ... deriving (Show, Eq) defaultSDistExFlags :: SDistExFlags diff --git a/cabal-install/Distribution/Solver/Modular/Solver.hs b/cabal-install/Distribution/Solver/Modular/Solver.hs index 4cab88686c0..2950fb324c2 100644 --- a/cabal-install/Distribution/Solver/Modular/Solver.hs +++ b/cabal-install/Distribution/Solver/Modular/Solver.hs @@ -87,14 +87,14 @@ data SolverConfig = SolverConfig { -- seems to be no statistically significant performance impact of cycle -- detection in the common case where there are no cycles. -- -solve :: SolverConfig -> -- ^ solver parameters - CompilerInfo -> - Index -> -- ^ all available packages as an index - PkgConfigDb -> -- ^ available pkg-config pkgs - (PN -> PackagePreferences) -> -- ^ preferences - Map PN [LabeledPackageConstraint] -> -- ^ global constraints - [PN] -> -- ^ global goals - Log Message (Assignment, RevDepMap) +solve :: SolverConfig -- ^ solver parameters + -> CompilerInfo + -> Index -- ^ all available packages as an index + -> PkgConfigDb -- ^ available pkg-config pkgs + -> (PN -> PackagePreferences) -- ^ preferences + -> Map PN [LabeledPackageConstraint] -- ^ global constraints + -> [PN] -- ^ global goals + -> Log Message (Assignment, RevDepMap) solve sc cinfo idx pkgConfigDB userPrefs userConstraints userGoals = explorePhase $ detectCycles $ From f323af63bb3bb53e1ff2ac799da974318938dbad Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 11 Jul 2016 12:52:51 -0400 Subject: [PATCH 3/5] Use the fields to prevent GHC warnings from bleating. Signed-off-by: Edward Z. Yang --- .../Client/Dependency/TopDown/Constraints.hs | 49 ++++++++++++------- .../Distribution/Client/Init/Heuristics.hs | 6 ++- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs b/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs index d23098a8d77..03d7def95a2 100644 --- a/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs +++ b/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs @@ -96,7 +96,7 @@ data Constraints installed source reason constraintsPaired :: !(Map PackageName (Version, Version)), -- | Purely for the invariant, we keep a copy of the original index - constraintsIndex :: !(PackageIndex (InstalledOrSource installed source)) + constraintsOriginal :: !(PackageIndex (InstalledOrSource installed source)) } @@ -110,13 +110,13 @@ data Constraints installed source reason data ExcludedPkg pkg reason = ExcludedPkg { excludedPkg :: pkg, - excludedPkgSrcInstReasons :: [reason], -- ^ reasons for excluding both source and installed instances - excludedPkgInstReasons :: [reason], -- ^ reasons for excluding the installed instance - excludedPkgSrcReasons :: [reason] -- ^ reasons for excluding the source instance + _excludedPkgSrcInstReasons :: [reason], -- ^ reasons for excluding both source and installed instances + _excludedPkgInstReasons :: [reason], -- ^ reasons for excluding the installed instance + _excludedPkgSrcReasons :: [reason] -- ^ reasons for excluding the source instance } instance Package pkg => Package (ExcludedPkg pkg reason) where - packageId (ExcludedPkg p _ _ _) = packageId p + packageId = packageId . excludedPkg -- | There is a conservation of packages property. Packages are never gained or @@ -124,7 +124,10 @@ instance Package pkg => Package (ExcludedPkg pkg reason) where -- invariant :: (Package installed, Package source) => Constraints installed source a -> Bool -invariant (Constraints targets available excluded _ original) = +invariant (Constraints { constraintsTargets = targets + , constraintsAvailable = available + , constraintsExcluded = excluded + , constraintsOriginal = original }) = -- Relationship between available, excluded and original all check merged @@ -186,8 +189,7 @@ invariant (Constraints targets available excluded _ original) = transitionsTo :: (Package installed, Package source) => Constraints installed source a -> Constraints installed source a -> Bool -transitionsTo constraints @(Constraints _ available excluded _ _) - constraints'@(Constraints _ available' excluded' _ _) = +transitionsTo constraints constraints' = invariant constraints && invariant constraints' && null availableGained && null excludedLost @@ -203,13 +205,13 @@ transitionsTo constraints @(Constraints _ available excluded _ _) availableChange = mergeBy (\a b -> packageId a `compare` packageId b) - (PackageIndex.allPackages available) - (PackageIndex.allPackages available') + (PackageIndex.allPackages (constraintsAvailable constraints)) + (PackageIndex.allPackages (constraintsAvailable constraints')) excludedChange = mergeBy (\a b -> packageId a `compare` packageId b) - [ pkg | ExcludedPkg pkg _ _ _ <- PackageIndex.allPackages excluded ] - [ pkg | ExcludedPkg pkg _ _ _ <- PackageIndex.allPackages excluded' ] + (map excludedPkg (PackageIndex.allPackages (constraintsExcluded constraints))) + (map excludedPkg (PackageIndex.allPackages (constraintsExcluded constraints'))) lostAndGained mr rest = case mr of OnlyInLeft pkg -> Left pkg : rest @@ -236,7 +238,13 @@ empty :: PackageIndex InstalledPackageEx -> PackageIndex UnconfiguredPackage -> Constraints InstalledPackageEx UnconfiguredPackage reason empty installed source = - Constraints targets pkgs excluded pairs pkgs + Constraints { + constraintsTargets = targets, + constraintsAvailable = pkgs, + constraintsExcluded = excluded, + constraintsPaired = pairs, + constraintsOriginal = pkgs + } where targets = mempty excluded = mempty @@ -260,23 +268,26 @@ empty installed source = || any ((pkgid2==) . packageId) (sourceDeps pkg1) ] +-- NB: we don't export the record fields directly to prevent users from +-- being to apply a record update. + -- | The package targets. -- packages :: Constraints installed source reason -> Set PackageName -packages (Constraints ts _ _ _ _) = ts +packages = constraintTargets -- | The package choices that are still available. -- choices :: Constraints installed source reason -> PackageIndex (InstalledOrSource installed source) -choices (Constraints _ available _ _ _) = available +choices = constraintsAvailable isPaired :: Constraints installed source reason -> PackageId -> Maybe PackageId -isPaired (Constraints _ _ _ pairs _) (PackageIdentifier name version) = - case Map.lookup name pairs of +isPaired constraints (PackageIdentifier name version) = + case Map.lookup name (constraintsPairs constraints) of Just (v1, v2) | version == v1 -> Just (PackageIdentifier name v2) | version == v2 -> Just (PackageIdentifier name v1) @@ -597,7 +608,7 @@ conflicting :: (Package installed, Package source) => Constraints installed source reason -> Dependency -> [(PackageId, [reason])] -conflicting (Constraints _ _ excluded _ _) dep = +conflicting constraints dep = [ (packageId pkg, reasonsAll ++ reasonsAvail ++ reasonsInstalled) --TODO | ExcludedPkg pkg reasonsAll reasonsAvail reasonsInstalled <- - PackageIndex.lookupDependency excluded dep ] + PackageIndex.lookupDependency (constraintsExcluded constraints) dep ] diff --git a/cabal-install/Distribution/Client/Init/Heuristics.hs b/cabal-install/Distribution/Client/Init/Heuristics.hs index 1456de84f6f..e083b196b8e 100644 --- a/cabal-install/Distribution/Client/Init/Heuristics.hs +++ b/cabal-install/Distribution/Client/Init/Heuristics.hs @@ -254,7 +254,11 @@ guessAuthorNameMail = fmap authorGuessPure authorGuessIO -- Ordered in increasing preference, since Flag-as-monoid is identical to -- Last. authorGuessPure :: AuthorGuessIO -> AuthorGuess -authorGuessPure (AuthorGuessIO env darcsLocalF darcsGlobalF gitLocal gitGlobal) +authorGuessPure (AuthorGuessIO { authorGuessEnv = env + , authorGuessLocalDarcs = darcsLocalF + , authorGuessGlobalDarcs = darcsGlobalF + , authorGuessLocalGit = gitLocal + , authorGuessGlobalGit = gitGlobal }) = mconcat [ emailEnv env , gitGlobal From 48502d1bd742a537be9e31d2cd292784aff44f07 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 11 Jul 2016 11:16:06 -0700 Subject: [PATCH 4/5] Bugfixes. Signed-off-by: Edward Z. Yang --- .../Distribution/Client/Dependency/TopDown/Constraints.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs b/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs index 03d7def95a2..1ba3d4e2212 100644 --- a/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs +++ b/cabal-install/Distribution/Client/Dependency/TopDown/Constraints.hs @@ -93,7 +93,7 @@ data Constraints installed source reason constraintsExcluded :: !(PackageIndex (ExcludedPkg (InstalledOrSource installed source) reason)), -- | Paired choices, this is an ugly hack. - constraintsPaired :: !(Map PackageName (Version, Version)), + constraintsPairs :: !(Map PackageName (Version, Version)), -- | Purely for the invariant, we keep a copy of the original index constraintsOriginal :: !(PackageIndex (InstalledOrSource installed source)) @@ -242,7 +242,7 @@ empty installed source = constraintsTargets = targets, constraintsAvailable = pkgs, constraintsExcluded = excluded, - constraintsPaired = pairs, + constraintsPairs = pairs, constraintsOriginal = pkgs } where @@ -275,7 +275,7 @@ empty installed source = -- packages :: Constraints installed source reason -> Set PackageName -packages = constraintTargets +packages = constraintsTargets -- | The package choices that are still available. From 13a9fe103180e8dad5a70a579137ff3bcb14f821 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 12 Jul 2016 17:21:25 -0700 Subject: [PATCH 5/5] Always generate registration info if a file is requested, even for internal libraries. Signed-off-by: Edward Z. Yang --- Cabal/Distribution/Simple/Register.hs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Cabal/Distribution/Simple/Register.hs b/Cabal/Distribution/Simple/Register.hs index 24d636e539b..f2fa07eb824 100644 --- a/Cabal/Distribution/Simple/Register.hs +++ b/Cabal/Distribution/Simple/Register.hs @@ -83,12 +83,21 @@ import qualified Data.ByteString.Lazy.Char8 as BS.Char8 register :: PackageDescription -> LocalBuildInfo -> RegisterFlags -- ^Install in the user's database?; verbose -> IO () -register pkg_descr lbi flags = when (hasPublicLib pkg_descr) doRegister +register pkg_descr lbi flags = + -- We do NOT register libraries outside of the inplace database + -- if there is no public library, since no one else can use it + -- usefully (they're not public.) If we start supporting scoped + -- packages, we'll have to relax this. + -- + -- HOWEVER, we ALWAYS do work if we are asked to generate + -- a file or script. + when (hasPublicLib pkg_descr || modeGenerateRegFile + || modeGenerateRegScript) doRegister where - -- We do NOT register libraries outside of the inplace database - -- if there is no public library, since no one else can use it - -- usefully (they're not public.) If we start supporting scoped - -- packages, we'll have to relax this. + -- Urk, duplicate with 'registerAll' + modeGenerateRegFile = isJust (flagToMaybe (regGenPkgConf flags)) + modeGenerateRegScript = fromFlag (regGenScript flags) + doRegister = do targets <- readBuildTargets pkg_descr (regArgs flags) targets' <- checkBuildTargets verbosity pkg_descr targets