Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

enable pkgconfig-depends for tests and benchmarks #1995

Merged
merged 1 commit into from

2 participants

Matt Cox Mikhail Glushenkov
Matt Cox

This patch enables pkgconfig-depends for test suites and benchmarks.

Previously, this field was parsed but its contents were not applied to tests and benchmarks by the configure step.

Cabal/Distribution/Simple/Configure.hs
@@ -907,6 +910,14 @@ configurePkgconfigPackages verbosity pkg_descr conf
bi <- pkgconfigBuildInfo (pkgconfigDepends (buildInfo exe))
return exe { buildInfo = buildInfo exe `mappend` bi }
+ updateTestSuite test = do
Mikhail Glushenkov Collaborator

"update" is not a very informative name. Perhaps addPkgConfigBI{Test,Bench}?

Matt Cox
mcox added a note

updateLibrary and updateExecutable were already in place, I wanted to maintain consistency with them.

Alternatively, all of them could be renamed to addPkgConfigBI{Test,Bench,Lib,Exe} as you suggest.

Mikhail Glushenkov Collaborator

Yes, please do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Cabal/Distribution/Simple/Configure.hs
@@ -867,7 +867,10 @@ configurePkgconfigPackages verbosity pkg_descr conf
mapM_ requirePkg allpkgs
lib' <- updateLibrary (library pkg_descr)
exes' <- mapM updateExecutable (executables pkg_descr)
- let pkg_descr' = pkg_descr { library = lib', executables = exes' }
+ tests' <- mapM updateTestSuite (testSuites pkg_descr)
+ benches' <- mapM updateBenchmark (benchmarks pkg_descr)
+ let pkg_descr' = pkg_descr { library = lib', executables = exes',
+ testSuites = tests', benchmarks = benches' }
Mikhail Glushenkov Collaborator

Indentation is a bit off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Matt Cox

I think all these commits should be squashed into one but await @23Skidoo's comments on 728dbab and 9d2277c before doing so.

Mikhail Glushenkov 23Skidoo commented on the diff
Cabal/Distribution/Simple/Configure.hs
@@ -110,6 +110,8 @@ import qualified Distribution.Simple.Hugs as Hugs
import qualified Distribution.Simple.UHC as UHC
import qualified Distribution.Simple.HaskellSuite as HaskellSuite
+-- Prefer the more generic Data.Traversable.mapM to Prelude.mapM
Mikhail Glushenkov Collaborator

What's the benefit of this?

Matt Cox
mcox added a note

On line 872, mapM is used to run addPkgConfigBILib on an optional library contained in a Maybe functor.

Previously, updateLibrary had type Maybe Library -> IO (Maybe Library) while addPkgConfigBILib has type Library -> IO Library as a result of my refactoring, which uses a common implementation of the conversion from pkgconfig dependencies to cc/ld flags.

Alternatively, I could remove the dependency on Data.Traversable.mapM by defining:

addPkgConfigBILib Nothing = return Nothing
addPkgConfigBILib (Just lib) = addPkgConfigBI ... ... lib
Mikhail Glushenkov Collaborator

Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Matt Cox mcox commented on the diff
Cabal/Distribution/Simple/Configure.hs
@@ -865,9 +869,12 @@ configurePkgconfigPackages verbosity pkg_descr conf
(lessVerbose verbosity) pkgConfigProgram
(orLaterVersion $ Version [0,9,0] []) conf
mapM_ requirePkg allpkgs
- lib' <- updateLibrary (library pkg_descr)
- exes' <- mapM updateExecutable (executables pkg_descr)
- let pkg_descr' = pkg_descr { library = lib', executables = exes' }
+ lib' <- mapM addPkgConfigBILib (library pkg_descr)
Matt Cox
mcox added a note

This mapM uses Maybe as the functor, rather than [].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Mikhail Glushenkov
Collaborator

LGTM.

@mcox Do you want to squash the commits before I merge this?

Matt Cox mcox enable pkgconfig-depends for tests and benchmarks
implement a common BuildInfo processor for all package components

change names of component BuildInfo processors to be more descriptive
3191db7
Matt Cox

@23Skidoo Squashed and ready.

Mikhail Glushenkov 23Skidoo merged commit 0da666f into from
Mikhail Glushenkov
Collaborator

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 17, 2014
  1. Matt Cox

    enable pkgconfig-depends for tests and benchmarks

    mcox authored
    implement a common BuildInfo processor for all package components
    
    change names of component BuildInfo processors to be more descriptive
This page is out of date. Refresh to see the latest.
Showing with 29 additions and 10 deletions.
  1. +29 −10 Cabal/Distribution/Simple/Configure.hs
39 Cabal/Distribution/Simple/Configure.hs
View
@@ -110,6 +110,8 @@ import qualified Distribution.Simple.Hugs as Hugs
import qualified Distribution.Simple.UHC as UHC
import qualified Distribution.Simple.HaskellSuite as HaskellSuite
+-- Prefer the more generic Data.Traversable.mapM to Prelude.mapM
Mikhail Glushenkov Collaborator

What's the benefit of this?

Matt Cox
mcox added a note

On line 872, mapM is used to run addPkgConfigBILib on an optional library contained in a Maybe functor.

Previously, updateLibrary had type Maybe Library -> IO (Maybe Library) while addPkgConfigBILib has type Library -> IO Library as a result of my refactoring, which uses a common implementation of the conversion from pkgconfig dependencies to cc/ld flags.

Alternatively, I could remove the dependency on Data.Traversable.mapM by defining:

addPkgConfigBILib Nothing = return Nothing
addPkgConfigBILib (Just lib) = addPkgConfigBI ... ... lib
Mikhail Glushenkov Collaborator

Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+import Prelude hiding ( mapM )
import Control.Monad
( when, unless, foldM, filterM )
import Data.List
@@ -120,6 +122,8 @@ import Data.Monoid
( Monoid(..) )
import qualified Data.Map as Map
import Data.Map (Map)
+import Data.Traversable
+ ( mapM )
import System.Directory
( doesFileExist, createDirectoryIfMissing, getTemporaryDirectory )
import System.FilePath
@@ -865,9 +869,12 @@ configurePkgconfigPackages verbosity pkg_descr conf
(lessVerbose verbosity) pkgConfigProgram
(orLaterVersion $ Version [0,9,0] []) conf
mapM_ requirePkg allpkgs
- lib' <- updateLibrary (library pkg_descr)
- exes' <- mapM updateExecutable (executables pkg_descr)
- let pkg_descr' = pkg_descr { library = lib', executables = exes' }
+ lib' <- mapM addPkgConfigBILib (library pkg_descr)
Matt Cox
mcox added a note

This mapM uses Maybe as the functor, rather than [].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ exes' <- mapM addPkgConfigBIExe (executables pkg_descr)
+ tests' <- mapM addPkgConfigBITest (testSuites pkg_descr)
+ benches' <- mapM addPkgConfigBIBench (benchmarks pkg_descr)
+ let pkg_descr' = pkg_descr { library = lib', executables = exes',
+ testSuites = tests', benchmarks = benches' }
return (pkg_descr', conf')
where
@@ -898,14 +905,26 @@ configurePkgconfigPackages verbosity pkg_descr conf
| isAnyVersion range = ""
| otherwise = " version " ++ display range
- updateLibrary Nothing = return Nothing
- updateLibrary (Just lib) = do
- bi <- pkgconfigBuildInfo (pkgconfigDepends (libBuildInfo lib))
- return $ Just lib { libBuildInfo = libBuildInfo lib `mappend` bi }
+ -- 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)
- updateExecutable exe = do
- bi <- pkgconfigBuildInfo (pkgconfigDepends (buildInfo exe))
- return exe { buildInfo = buildInfo exe `mappend` bi }
+ -- Adds pkgconfig dependencies to the build info for a library
+ addPkgConfigBILib = addPkgConfigBI libBuildInfo $
+ \lib bi -> lib { libBuildInfo = bi }
+
+ -- Adds pkgconfig dependencies to the build info for an executable
+ addPkgConfigBIExe = addPkgConfigBI buildInfo $
+ \exe bi -> exe { buildInfo = bi }
+
+ -- Adds pkgconfig dependencies to the build info for a test suite
+ addPkgConfigBITest = addPkgConfigBI testBuildInfo $
+ \test bi -> test { testBuildInfo = bi }
+
+ -- Adds pkgconfig dependencies to the build info for a benchmark
+ addPkgConfigBIBench = addPkgConfigBI benchmarkBuildInfo $
+ \bench bi -> bench { benchmarkBuildInfo = bi }
pkgconfigBuildInfo :: [Dependency] -> IO BuildInfo
pkgconfigBuildInfo [] = return mempty
Something went wrong with that request. Please try again.