1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
-----------------------------------------------------------------------------
-- |
-- Module : Distribution.Client.PackageUtils
-- Copyright : (c) Duncan Coutts 2010
-- License : BSD-like
--
-- Maintainer : cabal-devel@gmail.com
-- Stability : provisional
-- Portability : portable
--
-- Various package description utils that should be in the Cabal lib
-----------------------------------------------------------------------------
module Distribution.Client.PackageUtils (
externalBuildDepends,
) where
import Distribution.Package
( packageVersion, packageName, Dependency(..) )
import Distribution.PackageDescription
( PackageDescription(..) )
import Distribution.Version
( withinRange )
-- | The list of dependencies that refer to external packages
-- rather than internal package components.
--
externalBuildDepends :: PackageDescription -> [Dependency]
externalBuildDepends pkg = filter (not . internal) (buildDepends pkg)
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
|