Make “sublibrary” standard terminology in docs
[cabal.git] / Cabal / src / Distribution / Simple / Build / PackageInfoModule.hs
blob66b4af7b05b7bd02157de4384e0c28d463f322e9
1 -----------------------------------------------------------------------------
3 -- |
4 -- Module : Distribution.Simple.Build.PackageInfoModule
5 -- Copyright :
6 --
7 -- Maintainer : cabal-devel@haskell.org
8 -- Portability : portable
9 --
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
16 ) where
18 import Distribution.Compat.Prelude
19 import 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 =
38 Z.render
39 Z.Z
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
47 where
48 supports_rebindable_syntax = ghc_newer_than (mkVersion [7, 0, 1])
50 ghc_newer_than minVersion =
51 case compilerCompatVersion GHC (compiler lbi) of
52 Nothing -> False
53 Just version -> version `withinRange` orLaterVersion minVersion
55 showPkgName :: PackageName -> String
56 showPkgName = map fixchar . unPackageName
58 fixchar :: Char -> Char
59 fixchar '-' = '_'
60 fixchar c = c