Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasufell/26cb52d51e4170d4a3bf05fd0a0823bd to your computer and use it in GitHub Desktop.
Save hasufell/26cb52d51e4170d4a3bf05fd0a0823bd to your computer and use it in GitHub Desktop.
From 382e3e0ed04f43351133fff3f1e6ad6655c6b4e3 Mon Sep 17 00:00:00 2001
From: Julian Ospald <hasufell@posteo.de>
Date: Sat, 9 May 2020 22:48:18 +0200
Subject: [PATCH] Don't prematurely fail during configure due to pkg-config
---
Cabal/Distribution/Simple/Configure.hs | 32 +++-----------------------
1 file changed, 3 insertions(+), 29 deletions(-)
diff --git a/Cabal/Distribution/Simple/Configure.hs b/Cabal/Distribution/Simple/Configure.hs
index 7c93c3b4..b7df25da 100644
--- a/Cabal/Distribution/Simple/Configure.hs
+++ b/Cabal/Distribution/Simple/Configure.hs
@@ -1598,7 +1598,6 @@ configurePkgconfigPackages verbosity pkg_descr progdb enabled
(_, _, progdb') <- requireProgramVersion
(lessVerbose verbosity) pkgConfigProgram
(orLaterVersion $ mkVersion [0,9,0]) progdb
- traverse_ requirePkg allpkgs
mlib' <- traverse addPkgConfigBILib (library pkg_descr)
libs' <- traverse addPkgConfigBILib (subLibraries pkg_descr)
exes' <- traverse addPkgConfigBIExe (executables pkg_descr)
@@ -1614,36 +1613,11 @@ configurePkgconfigPackages verbosity pkg_descr progdb enabled
pkgconfig = getDbProgramOutput (lessVerbose verbosity)
pkgConfigProgram progdb
- requirePkg dep@(PkgconfigDependency pkgn range) = do
- version <- pkgconfig ["--modversion", pkg]
- `catchIO` (\_ -> die' verbosity notFound)
- `catchExit` (\_ -> die' verbosity notFound)
- let trim = dropWhile isSpace . dropWhileEnd isSpace
- let v = PkgconfigVersion (toUTF8BS $ trim version)
- if not (withinPkgconfigVersionRange v range)
- then die' verbosity (badVersion v)
- else info verbosity (depSatisfied v)
- where
- notFound = "The pkg-config package '" ++ pkg ++ "'"
- ++ versionRequirement
- ++ " is required but it could not be found."
- badVersion v = "The pkg-config package '" ++ pkg ++ "'"
- ++ versionRequirement
- ++ " is required but the version installed on the"
- ++ " system is version " ++ prettyShow v
- depSatisfied v = "Dependency " ++ prettyShow dep
- ++ ": using version " ++ prettyShow v
-
- versionRequirement
- | isAnyPkgconfigVersion range = ""
- | otherwise = " version " ++ prettyShow range
-
- pkg = unPkgconfigName pkgn
-
-- Adds pkgconfig dependencies to the build info for a component
addPkgConfigBI compBI setCompBI comp = do
- bi <- pkgconfigBuildInfo (pkgconfigDepends (compBI comp))
- return $ setCompBI comp (compBI comp `mappend` bi)
+ bi <- fmap Just (pkgconfigBuildInfo (pkgconfigDepends (compBI comp)))
+ <|> pure Nothing
+ return $ setCompBI comp (maybe id (\x y -> mappend y x) bi $ compBI comp)
-- Adds pkgconfig dependencies to the build info for a library
addPkgConfigBILib = addPkgConfigBI libBuildInfo $
--
2.25.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment