Skip to content

Commit

Permalink
Try each pkg-config query separatedly if returned list doesn't match …
Browse files Browse the repository at this point in the history
…query length

MinGW's pkg-config returns only one version even if queried for
multiple libraries.

(cherry picked from commit 3afd3a3)

# Conflicts:
#	cabal-install-solver/src/Distribution/Solver/Types/PkgConfigDb.hs
  • Loading branch information
jasagredo authored and mergify[bot] committed Dec 21, 2023
1 parent b14a01d commit 663f35c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ readPkgConfigDb verbosity progdb = handle ioErrorHandler $ do
(outs, _errs, exitCode) <-
getProgramInvocationOutputAndErrors verbosity
(programInvocation pkgConfig ("--modversion" : pkgNames))
<<<<<<< HEAD
let pkgVersions = lines outs
if exitCode == ExitSuccess && length pkgVersions == length pkgNames
then (return . pkgConfigDbFromList . zip pkgNames) pkgVersions
=======
if exitCode == ExitSuccess && length pkgNames == length pkgList
then (return . pkgConfigDbFromList . zip pkgNames) (lines pkgVersions)
>>>>>>> 3afd3a392 (Try each pkg-config query separatedly if returned list doesn't match query length)
else
-- if there's a single broken pc file the above fails, so we fall back
-- into calling it individually
Expand All @@ -99,7 +104,7 @@ readPkgConfigDb verbosity progdb = handle ioErrorHandler $ do
getIndividualVersion pkgConfig pkg = do
(pkgVersion, _errs, exitCode) <-
getProgramInvocationOutputAndErrors verbosity
(programInvocation pkgConfig ["--modversion",pkg])
(programInvocation pkgConfig ["--modversion", pkg])
return $ case exitCode of
ExitSuccess -> Just (pkg, pkgVersion)
_ -> Nothing
Expand Down
8 changes: 8 additions & 0 deletions changelog.d/pkgconfig-once
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
synopsis: PkgConfig individual calls
prs: #9134

description: {

- `cabal` invokes `pkg-config` individually for each lib if querying for all doesn't return the expected result

}

0 comments on commit 663f35c

Please sign in to comment.