Commit b9a124cf authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Make BuildInfo an instance of Monoid

parent 11dc13ee
...@@ -63,7 +63,6 @@ module Distribution.PackageDescription ( ...@@ -63,7 +63,6 @@ module Distribution.PackageDescription (
BuildInfo(..), BuildInfo(..),
emptyBuildInfo, emptyBuildInfo,
allBuildInfo, allBuildInfo,
unionBuildInfo,
hcOptions, hcOptions,
-- ** Supplementary build information -- ** Supplementary build information
...@@ -299,6 +298,10 @@ data BuildInfo = BuildInfo { ...@@ -299,6 +298,10 @@ data BuildInfo = BuildInfo {
} }
deriving (Show,Read,Eq) deriving (Show,Read,Eq)
instance Monoid BuildInfo where
mempty = nullBuildInfo
mappend = unionBuildInfo
nullBuildInfo :: BuildInfo nullBuildInfo :: BuildInfo
nullBuildInfo = BuildInfo { nullBuildInfo = BuildInfo {
buildable = True, buildable = True,
......
...@@ -68,8 +68,7 @@ import Distribution.Simple.PackageIndex (PackageIndex) ...@@ -68,8 +68,7 @@ import Distribution.Simple.PackageIndex (PackageIndex)
import Distribution.PackageDescription as PD import Distribution.PackageDescription as PD
( PackageDescription(..), GenericPackageDescription(..) ( PackageDescription(..), GenericPackageDescription(..)
, Library(..), hasLibs, Executable(..), BuildInfo(..) , Library(..), hasLibs, Executable(..), BuildInfo(..)
, HookedBuildInfo, updatePackageDescription , HookedBuildInfo, updatePackageDescription, allBuildInfo )
, allBuildInfo, emptyBuildInfo, unionBuildInfo )
import Distribution.PackageDescription.Configuration import Distribution.PackageDescription.Configuration
( finalizePackageDescription ) ( finalizePackageDescription )
import Distribution.PackageDescription.Check import Distribution.PackageDescription.Check
...@@ -120,6 +119,8 @@ import Data.List ...@@ -120,6 +119,8 @@ import Data.List
( nub, partition, isPrefixOf, maximumBy ) ( nub, partition, isPrefixOf, maximumBy )
import Data.Maybe import Data.Maybe
( fromMaybe, isNothing ) ( fromMaybe, isNothing )
import Data.Monoid
( Monoid(..) )
import System.Directory import System.Directory
( doesFileExist, getModificationTime, createDirectoryIfMissing ) ( doesFileExist, getModificationTime, createDirectoryIfMissing )
import System.Exit import System.Exit
...@@ -550,11 +551,11 @@ configurePkgconfigPackages verbosity pkg_descr conf ...@@ -550,11 +551,11 @@ configurePkgconfigPackages verbosity pkg_descr conf
updateLibrary Nothing = return Nothing updateLibrary Nothing = return Nothing
updateLibrary (Just lib) = do updateLibrary (Just lib) = do
bi <- pkgconfigBuildInfo (pkgconfigDepends (libBuildInfo lib)) bi <- pkgconfigBuildInfo (pkgconfigDepends (libBuildInfo lib))
return $ Just lib { libBuildInfo = libBuildInfo lib `unionBuildInfo` bi } return $ Just lib { libBuildInfo = libBuildInfo lib `mappend` bi }
updateExecutable exe = do updateExecutable exe = do
bi <- pkgconfigBuildInfo (pkgconfigDepends (buildInfo exe)) bi <- pkgconfigBuildInfo (pkgconfigDepends (buildInfo exe))
return exe { buildInfo = buildInfo exe `unionBuildInfo` bi } return exe { buildInfo = buildInfo exe `mappend` bi }
pkgconfigBuildInfo :: [Dependency] -> IO BuildInfo pkgconfigBuildInfo :: [Dependency] -> IO BuildInfo
pkgconfigBuildInfo pkgdeps = do pkgconfigBuildInfo pkgdeps = do
...@@ -578,7 +579,7 @@ ccLdOptionsBuildInfo cflags ldflags = ...@@ -578,7 +579,7 @@ ccLdOptionsBuildInfo cflags ldflags =
let (includeDirs', cflags') = partition ("-I" `isPrefixOf`) cflags let (includeDirs', cflags') = partition ("-I" `isPrefixOf`) cflags
(extraLibs', ldflags') = partition ("-l" `isPrefixOf`) ldflags (extraLibs', ldflags') = partition ("-l" `isPrefixOf`) ldflags
(extraLibDirs', ldflags'') = partition ("-L" `isPrefixOf`) ldflags' (extraLibDirs', ldflags'') = partition ("-L" `isPrefixOf`) ldflags'
in emptyBuildInfo { in mempty {
PD.includeDirs = map (drop 2) includeDirs', PD.includeDirs = map (drop 2) includeDirs',
PD.extraLibs = map (drop 2) extraLibs', PD.extraLibs = map (drop 2) extraLibs',
PD.extraLibDirs = map (drop 2) extraLibDirs', PD.extraLibDirs = map (drop 2) extraLibDirs',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment