1 -----------------------------------------------------------------------------
4 -- Module : Distribution.Simple.Build.PackageInfoModule
7 -- Maintainer : cabal-devel@haskell.org
8 -- Portability : portable
10 -- Generating the PackageInfo_pkgname module.
12 -- This is a module that Cabal generates for the benefit of packages. It
13 -- enables them to find their package informations.
14 module Distribution
.Simple
.Build
.PackageInfoModule
15 ( generatePackageInfoModule
18 import Distribution
.Compat
.Prelude
21 import Distribution
.Package
22 import Distribution
.PackageDescription
23 import Distribution
.Simple
.Compiler
24 import Distribution
.Simple
.LocalBuildInfo
25 import Distribution
.Utils
.ShortText
26 import Distribution
.Version
28 import qualified Distribution
.Simple
.Build
.PackageInfoModule
.Z
as Z
30 -- ------------------------------------------------------------
32 -- * Building Paths_<pkg>.hs
34 -- ------------------------------------------------------------
36 generatePackageInfoModule
:: PackageDescription
-> LocalBuildInfo
-> String
37 generatePackageInfoModule pkg_descr lbi
=
40 { Z
.zPackageName
= showPkgName
$ packageName pkg_descr
41 , Z
.zVersionDigits
= show $ versionNumbers
$ packageVersion pkg_descr
42 , Z
.zSynopsis
= fromShortText
$ synopsis pkg_descr
43 , Z
.zCopyright
= fromShortText
$ copyright pkg_descr
44 , Z
.zHomepage
= fromShortText
$ homepage pkg_descr
45 , Z
.zSupportsNoRebindableSyntax
= supports_rebindable_syntax
48 supports_rebindable_syntax
= ghc_newer_than
(mkVersion
[7, 0, 1])
50 ghc_newer_than minVersion
=
51 case compilerCompatVersion GHC
(compiler lbi
) of
53 Just version
-> version `withinRange` orLaterVersion minVersion
55 showPkgName
:: PackageName
-> String
56 showPkgName
= map fixchar
. unPackageName
58 fixchar
:: Char -> Char