Skip to content

Commit

Permalink
Add support for changing constraints of 'pkgconfig-depends'
Browse files Browse the repository at this point in the history
Closes #596

(cherry picked from commit 52e33fb)
  • Loading branch information
hvr committed Jul 9, 2017
1 parent db09c68 commit 8df1329
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions Distribution/Server/Util/CabalRevisions.hs
Expand Up @@ -302,7 +302,7 @@ checkCondTree checkElem (componentName, condNodeA)
where
checkCondNode (CondNode dataA constraintsA componentsA)
(CondNode dataB constraintsB componentsB) = do
checkDependencies componentName PackageDependency constraintsA constraintsB
checkDependencies componentName LibDependency constraintsA constraintsB
checkList "Cannot add or remove 'if' conditionals"
checkComponent componentsA componentsB
checkElem componentName dataA dataB
Expand All @@ -316,8 +316,9 @@ checkCondTree checkElem (componentName, condNodeA)
checkCondNode thenPartA thenPartB

data DependencyType
= PackageDependency -- ^ build-depends
= LibDependency -- ^ build-depends
| BuildToolDependency -- ^ build-tools
| PkgConfigDependency -- ^ pkgconfig-depends
deriving (Eq)

checkDependencies :: ComponentName -> DependencyType -> Check [Dependency]
Expand All @@ -342,11 +343,13 @@ checkDependencies componentName s ds1 ds2 = do
cnameStr = showComponentName componentName

depKind = case s of
PackageDependency -> "library dependency"
LibDependency -> "library dependency"
BuildToolDependency -> "tool dependency"
PkgConfigDependency -> "pkg-config dependency"

additionWhitelist
| s == PackageDependency =
additionWhitelist :: [PackageName]
additionWhitelist = case s of
LibDependency ->
-- Special case: there are some pretty weird broken packages out there, see
-- https://github.com/haskell/hackage-server/issues/303
-- which need us to add a new dep on `base`
Expand All @@ -371,8 +374,21 @@ checkDependencies componentName s ds1 ds2 = do
--
, PackageName "network-uri-flag"
]
-- No whitelist for build-tools
| otherwise = []

BuildToolDependency ->
-- list of trusted tools cabal supports w/o explicit build-tools
-- c.f. Distribution.Simple.BuildToolDepends.desugarBuildTool
-- and 'knownSuffixHandlers' in "Distribution.Client.Init.Heuristics"
[ PackageName "alex"
, PackageName "c2hs"
, PackageName "cpphs"
, PackageName "greencard"
, PackageName "happy"
, PackageName "hsc2hs"
]

-- No whitelist for pkg-config
PkgConfigDependency -> []

-- The result tuple represents the 3 canonicalised dependency
-- (removed deps (old ranges), retained deps (old & new ranges), added deps (new ranges))
Expand Down Expand Up @@ -458,11 +474,12 @@ checkBuildInfo componentName biA biB = do
(Set.fromList $ otherExtensions biA) (Set.fromList $ otherExtensions biB)

checkDependencies componentName BuildToolDependency (buildTools biA) (buildTools biB)
checkDependencies componentName PkgConfigDependency (pkgconfigDepends biA) (pkgconfigDepends biB)

checkSame "Cannot change build information \
\(just the dependency version constraints)"
(biA { targetBuildDepends = [], targetBuildRenaming = Map.empty, otherExtensions = [], buildTools = [] })
(biB { targetBuildDepends = [], targetBuildRenaming = Map.empty, otherExtensions = [], buildTools = [] })
(biA { targetBuildDepends = [], targetBuildRenaming = Map.empty, otherExtensions = [], buildTools = [], pkgconfigDepends = [] })
(biB { targetBuildDepends = [], targetBuildRenaming = Map.empty, otherExtensions = [], buildTools = [], pkgconfigDepends = [] })

changesOk' :: Eq a => Severity -> String -> (a -> String) -> Check a
changesOk' rel what render a b
Expand Down

0 comments on commit 8df1329

Please sign in to comment.