Skip to content

Commit 4b87276

Browse files
committed
Try each pkg-config query separatedly if returned list doesn't match query length
MinGW's pkg-config returns only one version even if queried for multiple libraries.
1 parent 2564b54 commit 4b87276

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cabal-install-solver/src/Distribution/Solver/Types/PkgConfigDb.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ readPkgConfigDb verbosity progdb = handle ioErrorHandler $ do
7070
(pkgVersions, _errs, exitCode) <-
7171
getProgramInvocationOutputAndErrors verbosity
7272
(programInvocation pkgConfig ("--modversion" : pkgNames))
73-
case exitCode of
74-
ExitSuccess -> (return . pkgConfigDbFromList . zip pkgNames) (lines pkgVersions)
75-
-- if there's a single broken pc file the above fails, so we fall back into calling it individually
76-
_ -> do
77-
info verbosity ("call to pkg-config --modversion on all packages failed. Falling back to querying pkg-config individually on each package")
78-
pkgConfigDbFromList . catMaybes <$> mapM (getIndividualVersion pkgConfig) pkgNames
73+
if exitCode == ExitSuccess && length pkgNames == length pkgList
74+
then (return . pkgConfigDbFromList . zip pkgNames) (lines pkgVersions)
75+
else -- if there's a single broken pc file the above fails, so we fall back into calling it individually
76+
do
77+
info verbosity ("call to pkg-config --modversion on all packages failed. Falling back to querying pkg-config individually on each package")
78+
pkgConfigDbFromList . catMaybes <$> mapM (getIndividualVersion pkgConfig) pkgNames
7979
where
8080
-- For when pkg-config invocation fails (possibly because of a
8181
-- too long command line).

0 commit comments

Comments
 (0)