packages feed

cabal-pkg-config-version-hook 0.1.0.0 → 0.1.0.1

raw patch · 3 files changed

+21/−7 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Distribution.PkgConfigVersionHook: composeConfHook :: Settings -> ((GenericPackageDescription, b1) -> ConfigFlags -> IO b2) -> (GenericPackageDescription, b1) -> ConfigFlags -> IO b2
+ Distribution.PkgConfigVersionHook: composeConfHook :: Settings -> ((GenericPackageDescription, a) -> ConfigFlags -> IO b) -> (GenericPackageDescription, a) -> ConfigFlags -> IO b

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for cabal-pkg-config-version-hook +## 0.1.0.1 -- 2023-06-28++* Fix an incomplete pattern match+ ## 0.1.0.0 -- 2022-03-07  * First version. Main feature is room for improvement.
cabal-pkg-config-version-hook.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               cabal-pkg-config-version-hook-version:            0.1.0.0+version:            0.1.0.1 synopsis:           Make Cabal aware of pkg-config package versions description:        A setup hook for Cabal that determines the compile-time version of a pkg-config package and adds CPP macros and enables flags. -- A URL where users can report bugs.
src/Distribution/PkgConfigVersionHook.hs view
@@ -1,3 +1,6 @@+-- This is the default, but we have to instruct the formatter used on the repo:+{-# LANGUAGE NoImportQualifiedPost #-}+ -- | -- --  Example:@@ -39,12 +42,12 @@ import Data.Foldable (toList) import Data.Function ((&)) import qualified Data.List as L-import Distribution.Simple-import Distribution.Simple.Setup (configConfigurationsFlags)+import Distribution.Simple (UserHooks (confHook))+import Distribution.Simple.Setup (ConfigFlags, configConfigurationsFlags) import Distribution.Types.BuildInfo.Lens (ccOptions, cppOptions, cxxOptions) import Distribution.Types.Flag (flagName, mkFlagAssignment, mkFlagName, unFlagName) import Distribution.Types.GenericPackageDescription.Lens-  ( allCondTrees,+  ( GenericPackageDescription,     condBenchmarks,     condExecutables,     condForeignLibs,@@ -91,11 +94,17 @@ mkSettings name =   Settings     { pkgConfigName = name,-      macroName = map (\x -> case x of '-' -> '_') name,+      macroName = map (\c -> case c of '-' -> '_'; x -> x) name,       flagPrefixName = name     }  -- | Extend the value of 'confHook'. It's what powers 'addHook'.+composeConfHook ::+  Settings ->+  ((GenericPackageDescription, a) -> ConfigFlags -> IO b) ->+  (GenericPackageDescription, a) ->+  Distribution.Simple.Setup.ConfigFlags ->+  IO b composeConfHook settings origHook = \(genericPackageDescription, hookedBuildInfo) confFlags -> do   (actualMajor, actualMinor, actualPatch) <- getPkgConfigPackageVersion (pkgConfigName settings) @@ -145,14 +154,14 @@  unambiguously :: P.ReadP a -> String -> Maybe a unambiguously p s =-  case filter (\(a, x) -> x == "") $ P.readP_to_S p s of+  case filter (\(_a, x) -> x == "") $ P.readP_to_S p s of     [(v, _)] -> Just v     _ -> Nothing  getPkgConfigPackageVersion :: String -> IO (Int, Int, Int) getPkgConfigPackageVersion pkgName = do   s <- readProcess "pkg-config" ["--modversion", pkgName] ""-  case L.sortOn (\(_, s) -> length s) $ P.readP_to_S parseVersion s of+  case L.sortOn (\(_, remainder) -> length remainder) $ P.readP_to_S parseVersion s of     [] -> error ("Could not parse version " ++ show s ++ " returned by pkg-config for package " ++ pkgName)     (v, r) : _ -> do       when (L.dropWhile C.isSpace r /= "") $ do@@ -161,4 +170,5 @@       pure (v' L.!! 0, v' L.!! 1, v' L.!! 2)  -- Should probably use a Cabal function?+log :: String -> IO () log = hPutStrLn stderr