Skip to content

Commit

Permalink
WIP2
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Jun 15, 2020
1 parent ea1a8cc commit f963e17
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
16 changes: 7 additions & 9 deletions cabal-install/Distribution/Client/PackageUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ import Distribution.Version (isAnyVersion, withinRange)
-- | The list of dependencies that refer to external packages
-- rather than internal package components.
--
-- Previously we needed to filter internal packages.
-- This is no more the case (see #6083).
-- Internal dependencies are always of the form
--
-- Dependency thisPkgName vr [LSubLibName name, ...]
--
externalBuildDepends :: PackageDescription -> ComponentRequestedSpec -> [Dependency]
externalBuildDepends pkg spec = filter (not . internal) (enabledBuildDepends pkg spec)
where
-- True if this dependency is an internal one (depends on a library
-- defined in the same package).
internal (Dependency depName versionRange _) =
(depName == packageName pkg &&
packageVersion pkg `withinRange` versionRange) ||
(LSubLibName (packageNameToUnqualComponentName depName) `elem` map libName (subLibraries pkg) &&
isAnyVersion versionRange)
externalBuildDepends pkg spec = enabledBuildDepends pkg spec
14 changes: 4 additions & 10 deletions cabal-install/Distribution/Solver/Modular/IndexConversion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ convGPD os arch cinfo constraints strfl solveExes pn
-- by creating a set of package names which are "internal"
-- and dropping them as we convert.

ipns = S.fromList $ [ unqualComponentNameToPackageName nm
| (nm, _) <- sub_libs ]
-- TODO: remove IPNS argument
ipns = S.empty


conv :: Monoid a => Component -> (a -> BuildInfo) -> DependencyReason PN ->
CondTree ConfVar [Dependency] a -> FlaggedDeps PN
Expand Down Expand Up @@ -335,13 +336,6 @@ flagInfo (StrongFlags strfl) =
-- dependencies.
type IPNs = S.Set PN

-- | Convenience function to delete a 'Dependency' if it's
-- for a 'PN' that isn't actually real.
filterIPNs :: IPNs -> Dependency -> Maybe Dependency
filterIPNs ipns d@(Dependency pn _ _)
| S.notMember pn ipns = Just d
| otherwise = Nothing

-- | Convert condition trees to flagged dependencies. Mutually
-- recursive with 'convBranch'. See 'convBranch' for an explanation
-- of all arguments preceding the input 'CondTree'.
Expand All @@ -359,7 +353,7 @@ convCondTree flags dr pkg os arch cinfo pn fds comp getInfo ipns solveExes@(Solv
-- of the tree.
mergeSimpleDeps $
[ D.Simple singleDep comp
| dep <- mapMaybe (filterIPNs ipns) ds
| dep <- ds
, singleDep <- convLibDeps dr dep ] -- unconditional package dependencies

++ L.map (\e -> D.Simple (LDep dr (Ext e)) comp) (allExtensions bi) -- unconditional extension dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- pkg-abc-0.1.0.0 (lib:pkg-def) (first run)
- pkg-def-0.1.0.0 (lib) (first run)
- pkg-abc-0.1.0.0 (exe:program) (first run)
Warning: pkg-abc.cabal:19:15: colon specifier is experimental feature (issue #5660)
Configuring library 'pkg-def' for pkg-abc-0.1.0.0..
Preprocessing library 'pkg-def' for pkg-abc-0.1.0.0..
Building library 'pkg-def' for pkg-abc-0.1.0.0..
Warning: pkg-def.cabal:13:27: visibility is experimental feature (issue #5660)
Configuring library for pkg-def-0.1.0.0..
Preprocessing library for pkg-def-0.1.0.0..
Building library for pkg-def-0.1.0.0..
Warning: pkg-abc.cabal:19:15: colon specifier is experimental feature (issue #5660)
Configuring executable 'program' for pkg-abc-0.1.0.0..
Warning: The package has an extraneous version range for a dependency on an internal library: pkg-def >=0 && ==0.1.0.0. This version range includes the current package but isn't needed as the current package's library will always be used.
Preprocessing executable 'program' for pkg-abc-0.1.0.0..
Building executable 'program' for pkg-abc-0.1.0.0..
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import Test.Cabal.Prelude
-- https://github.com/haskell/cabal/issues/6083
-- see pkg-abc.cabal
main = cabalTest $
cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-abc:pkg-def"
cabal' "v2-run" ["pkg-abc:program"] >>= assertOutputContains "pkg-def:pkg-def"

0 comments on commit f963e17

Please sign in to comment.