module Distribution.Simple.Build.Macros (
generate
) where
import Distribution.Package
( PackageIdentifier(PackageIdentifier) )
import Distribution.Version
( Version(versionBranch) )
import Distribution.PackageDescription
( PackageDescription )
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo, externalPackageDeps )
import Distribution.Text
( display )
generate :: PackageDescription -> LocalBuildInfo -> String
generate _pkg_descr lbi = concat :: [[a]] -> [a]concat ($) :: (a -> b) -> a -> b$
"/* DO NOT EDIT: This file is automatically generated by Cabal */\n\n" (:) :: a -> [a] -> [a]:
[ concat :: [[a]] -> [a]concat
["/* package ",display :: Text a => a -> Stringdisplay pkgid :: PackageIdpkgid," */\n"
,"#define VERSION_",pkgname :: [Char]pkgname," ",show :: Show a => a -> Stringshow (display :: Text a => a -> Stringdisplay version :: Versionversion),"\n"
,"#define MIN_VERSION_",pkgname :: [Char]pkgname,"(major1,major2,minor) (\\\n"
," (major1) < ",major1 :: Stringmajor1," || \\\n"
," (major1) == ",major1 :: Stringmajor1," && (major2) < ",major2 :: Stringmajor2," || \\\n"
," (major1) == ",major1 :: Stringmajor1," && (major2) == ",major2 :: Stringmajor2," && (minor) <= ",minor :: Stringminor,")"
,"\n\n"
]
| (_, pkgid@(PackageIdentifier name version)) <- externalPackageDeps ::
LocalBuildInfo -> [(InstalledPackageId, PackageId)]externalPackageDeps lbi :: LocalBuildInfolbi
, let (major1:major2:minor:_) = map :: (a -> b) -> [a] -> [b]map show :: Show a => a -> Stringshow (versionBranch :: Version -> [Int]versionBranch version :: Versionversion (++) :: [a] -> [a] -> [a]++ repeat :: a -> [a]repeat 0)
pkgname = map :: (a -> b) -> [a] -> [b]map fixchar :: Char -> Charfixchar (display :: Text a => a -> Stringdisplay name :: PackageNamename)
]
where fixchar '-' = '_'
fixchar c = c :: Charc