diff --git a/.hlint.yaml b/.hlint.yaml index f425ae527a8..5197217f02c 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -98,5 +98,6 @@ - --ignore-glob=cabal-testsuite/PackageTests/CmmSourcesDyn/src/Demo.hs - --ignore-glob=Cabal-syntax/src/Distribution/Fields/Lexer.hs - --ignore-glob=templates/Paths_pkg.template.hs + - --ignore-glob=templates/PackageInfo_pkg.template.hs - --ignore-glob=templates/SPDX.LicenseExceptionId.template.hs - --ignore-glob=templates/SPDX.LicenseId.template.hs diff --git a/Cabal/src/Distribution/Simple/Build/PackageInfoModule.hs b/Cabal/src/Distribution/Simple/Build/PackageInfoModule.hs index 66b4af7b05b..0315f211a16 100644 --- a/Cabal/src/Distribution/Simple/Build/PackageInfoModule.hs +++ b/Cabal/src/Distribution/Simple/Build/PackageInfoModule.hs @@ -20,6 +20,7 @@ import Prelude () import Distribution.Package import Distribution.PackageDescription +import Distribution.Pretty (prettyShow) import Distribution.Simple.Compiler import Distribution.Simple.LocalBuildInfo import Distribution.Utils.ShortText @@ -37,12 +38,22 @@ generatePackageInfoModule :: PackageDescription -> LocalBuildInfo -> String generatePackageInfoModule pkg_descr lbi = Z.render Z.Z - { Z.zPackageName = showPkgName $ packageName pkg_descr + { Z.zPackageName = packageName pkg_descr , Z.zVersionDigits = show $ versionNumbers $ packageVersion pkg_descr - , Z.zSynopsis = fromShortText $ synopsis pkg_descr - , Z.zCopyright = fromShortText $ copyright pkg_descr - , Z.zHomepage = fromShortText $ homepage pkg_descr + , Z.zLicense = show $ prettyShow $ license pkg_descr + , Z.zCopyright = show $ fromShortText $ copyright pkg_descr + , Z.zMaintainer = show $ fromShortText $ maintainer pkg_descr + , Z.zAuthor = show $ fromShortText $ author pkg_descr + , Z.zStability = show $ fromShortText $ stability pkg_descr + , Z.zHomepage = show $ fromShortText $ homepage pkg_descr + , Z.zPkgUrl = show $ fromShortText $ pkgUrl pkg_descr + , Z.zBugReports = show $ fromShortText $ bugReports pkg_descr + , Z.zSynopsis = show $ fromShortText $ synopsis pkg_descr + , Z.zDescription = show $ fromShortText $ description pkg_descr + , Z.zCategory = show $ fromShortText $ category pkg_descr , Z.zSupportsNoRebindableSyntax = supports_rebindable_syntax + , Z.zManglePkgName = showPkgName + , Z.zShow = show } where supports_rebindable_syntax = ghc_newer_than (mkVersion [7, 0, 1]) diff --git a/Cabal/src/Distribution/Simple/Build/PackageInfoModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PackageInfoModule/Z.hs index 6bc97314809..ad4d8dc99fa 100644 --- a/Cabal/src/Distribution/Simple/Build/PackageInfoModule/Z.hs +++ b/Cabal/src/Distribution/Simple/Build/PackageInfoModule/Z.hs @@ -1,37 +1,51 @@ +{- FOURMOLU_DISABLE -} {-# LANGUAGE DeriveGeneric #-} - -module Distribution.Simple.Build.PackageInfoModule.Z (render, Z (..)) where - +module Distribution.Simple.Build.PackageInfoModule.Z (render, Z(..)) where import Distribution.ZinzaPrelude - -data Z = Z - { zPackageName :: String - , zVersionDigits :: String - , zSynopsis :: String - , zCopyright :: String - , zHomepage :: String - , zSupportsNoRebindableSyntax :: Bool - } - deriving (Generic) - +data Z + = Z {zPackageName :: PackageName, + zVersionDigits :: String, + zLicense :: String, + zCopyright :: String, + zMaintainer :: String, + zAuthor :: String, + zStability :: String, + zHomepage :: String, + zPkgUrl :: String, + zBugReports :: String, + zSynopsis :: String, + zDescription :: String, + zCategory :: String, + zSupportsNoRebindableSyntax :: Bool, + zManglePkgName :: (PackageName -> String), + zShow :: (String -> String)} + deriving Generic render :: Z -> String render z_root = execWriter $ do if (zSupportsNoRebindableSyntax z_root) - then do - tell "{-# LANGUAGE NoRebindableSyntax #-}\n" - return () - else do - return () + then do + tell "{-# LANGUAGE NoRebindableSyntax #-}\n" + return () + else do + return () tell "{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}\n" tell "{-# OPTIONS_GHC -w #-}\n" tell "module PackageInfo_" - tell (zPackageName z_root) - tell " (\n" - tell " name,\n" - tell " version,\n" - tell " synopsis,\n" - tell " copyright,\n" - tell " homepage,\n" + tell (zManglePkgName z_root (zPackageName z_root)) + tell "\n" + tell " ( name\n" + tell " , version\n" + tell " , license\n" + tell " , copyright\n" + tell " , maintainer\n" + tell " , author\n" + tell " , stability\n" + tell " , homepage\n" + tell " , pkgUrl\n" + tell " , bugReports\n" + tell " , synopsis\n" + tell " , description\n" + tell " , category\n" tell " ) where\n" tell "\n" tell "import Data.Version (Version(..))\n" @@ -39,22 +53,65 @@ render z_root = execWriter $ do tell "\n" tell "name :: String\n" tell "name = " - tell (show $ zPackageName z_root) + tell (zShow z_root (zManglePkgName z_root (zPackageName z_root))) + tell "\n" tell "\n" tell "version :: Version\n" tell "version = Version " tell (zVersionDigits z_root) tell " []\n" tell "\n" - tell "synopsis :: String\n" - tell "synopsis = " - tell (show $ zSynopsis z_root) + tell "license :: String\n" + tell "license = " + tell (zLicense z_root) + tell "\n" tell "\n" tell "copyright :: String\n" tell "copyright = " - tell (show $ zCopyright z_root) + tell (zCopyright z_root) + tell "\n" + tell "\n" + tell "maintainer :: String\n" + tell "maintainer = " + tell (zMaintainer z_root) + tell "\n" + tell "\n" + tell "author :: String\n" + tell "author = " + tell (zAuthor z_root) + tell "\n" + tell "\n" + tell "stability :: String\n" + tell "stability = " + tell (zStability z_root) + tell "\n" tell "\n" tell "homepage :: String\n" tell "homepage = " - tell (show $ zHomepage z_root) + tell (zHomepage z_root) + tell "\n" + tell "\n" + tell "pkgUrl :: String\n" + tell "pkgUrl = " + tell (zPkgUrl z_root) + tell "\n" + tell "\n" + tell "bugReports :: String\n" + tell "bugReports = " + tell (zBugReports z_root) + tell "\n" + tell "\n" + tell "synopsis :: String\n" + tell "synopsis = " + tell (zSynopsis z_root) + tell "\n" + tell "\n" + tell "description :: String\n" + tell "description = " + tell (zDescription z_root) + tell "\n" + tell "\n" + tell "category :: String\n" + tell "category = " + tell (zCategory z_root) tell "\n" diff --git a/Cabal/src/Distribution/Simple/Build/PathsModule.hs b/Cabal/src/Distribution/Simple/Build/PathsModule.hs index 892e5bd384f..4dc286ae07b 100644 --- a/Cabal/src/Distribution/Simple/Build/PathsModule.hs +++ b/Cabal/src/Distribution/Simple/Build/PathsModule.hs @@ -24,10 +24,12 @@ import Prelude () import Distribution.Package import Distribution.PackageDescription +import Distribution.Pretty () import Distribution.Simple.Compiler import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Utils (shortRelativePath) import Distribution.System +import Distribution.Utils.Path (getSymbolicPath) import Distribution.Version import qualified Distribution.Simple.Build.PathsModule.Z as Z @@ -44,6 +46,7 @@ generatePathsModule pkg_descr lbi clbi = Z.Z { Z.zPackageName = packageName pkg_descr , Z.zVersionDigits = show $ versionNumbers $ packageVersion pkg_descr + , Z.zLicenseFiles = show $ getSymbolicPath <$> licenseFiles pkg_descr , Z.zSupportsCpp = supports_cpp , Z.zSupportsNoRebindableSyntax = supports_rebindable_syntax , Z.zAbsolute = absolute @@ -58,6 +61,7 @@ generatePathsModule pkg_descr lbi clbi = , Z.zLibdir = zLibdir , Z.zDynlibdir = zDynlibdir , Z.zDatadir = zDatadir + , Z.zDocdir = zDocdir , Z.zLibexecdir = zLibexecdir , Z.zSysconfdir = zSysconfdir } @@ -93,6 +97,7 @@ generatePathsModule pkg_descr lbi clbi = , libdir = flat_libdir , dynlibdir = flat_dynlibdir , datadir = flat_datadir + , docdir = flat_docdir , libexecdir = flat_libexecdir , sysconfdir = flat_sysconfdir , prefix = flat_prefix @@ -103,17 +108,19 @@ generatePathsModule pkg_descr lbi clbi = , libdir = flat_libdirrel , dynlibdir = flat_dynlibdirrel , datadir = flat_datadirrel + , docdir = flat_docdirrel , libexecdir = flat_libexecdirrel , sysconfdir = flat_sysconfdirrel } = prefixRelativeComponentInstallDirs (packageId pkg_descr) lbi cid - zBindir, zLibdir, zDynlibdir, zDatadir, zLibexecdir, zSysconfdir :: String - (zBindir, zLibdir, zDynlibdir, zDatadir, zLibexecdir, zSysconfdir) + zBindir, zLibdir, zDynlibdir, zDatadir, zDocdir, zLibexecdir, zSysconfdir :: String + (zBindir, zLibdir, zDynlibdir, zDatadir, zDocdir, zLibexecdir, zSysconfdir) | relocatable lbi = ( show flat_bindir_reloc , show flat_libdir_reloc , show flat_dynlibdir_reloc , show flat_datadir_reloc + , show flat_docdir_reloc , show flat_libexecdir_reloc , show flat_sysconfdir_reloc ) @@ -122,6 +129,7 @@ generatePathsModule pkg_descr lbi clbi = , show flat_libdir , show flat_dynlibdir , show flat_datadir + , show flat_docdir , show flat_libexecdir , show flat_sysconfdir ) @@ -130,6 +138,7 @@ generatePathsModule pkg_descr lbi clbi = , mkGetDir flat_libdir flat_libdirrel , mkGetDir flat_dynlibdir flat_dynlibdirrel , mkGetDir flat_datadir flat_datadirrel + , mkGetDir flat_docdir flat_docdirrel , mkGetDir flat_libexecdir flat_libexecdirrel , mkGetDir flat_sysconfdir flat_sysconfdirrel ) @@ -144,6 +153,7 @@ generatePathsModule pkg_descr lbi clbi = flat_libdir_reloc = shortRelativePath flat_prefix flat_libdir flat_dynlibdir_reloc = shortRelativePath flat_prefix flat_dynlibdir flat_datadir_reloc = shortRelativePath flat_prefix flat_datadir + flat_docdir_reloc = shortRelativePath flat_prefix flat_docdir flat_libexecdir_reloc = shortRelativePath flat_prefix flat_libexecdir flat_sysconfdir_reloc = shortRelativePath flat_prefix flat_sysconfdir diff --git a/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs index 25c924720ec..583f2e57670 100644 --- a/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs +++ b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs @@ -5,6 +5,7 @@ import Distribution.ZinzaPrelude data Z = Z {zPackageName :: PackageName, zVersionDigits :: String, + zLicenseFiles :: String, zSupportsCpp :: Bool, zSupportsNoRebindableSyntax :: Bool, zAbsolute :: Bool, @@ -17,6 +18,7 @@ data Z zLibdir :: FilePath, zDynlibdir :: FilePath, zDatadir :: FilePath, + zDocdir :: FilePath, zLibexecdir :: FilePath, zSysconfdir :: FilePath, zNot :: (Bool -> Bool), @@ -55,9 +57,9 @@ render z_root = execWriter $ do tell "module Paths_" tell (zManglePkgName z_root (zPackageName z_root)) tell " (\n" - tell " version,\n" - tell " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n" - tell " getDataFileName, getSysconfDir\n" + tell " version, licenseFiles,\n" + tell " getBinDir, getLibDir, getDynLibDir, getDataDir, getDocDir, getLibexecDir,\n" + tell " getDataFileName, getDocFileName, getSysconfDir\n" tell " ) where\n" tell "\n" if (zNot z_root (zAbsolute z_root)) @@ -106,12 +108,22 @@ render z_root = execWriter $ do tell (zVersionDigits z_root) tell " []\n" tell "\n" + tell "licenseFiles :: [FilePath]\n" + tell "licenseFiles = " + tell (zLicenseFiles z_root) + tell "\n" + tell "\n" tell "getDataFileName :: FilePath -> IO FilePath\n" tell "getDataFileName name = do\n" tell " dir <- getDataDir\n" tell " return (dir `joinFileName` name)\n" tell "\n" - tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n" + tell "getDocFileName :: FilePath -> IO FilePath\n" + tell "getDocFileName name = do\n" + tell " dir <- getDocDir\n" + tell " return (dir `joinFileName` name)\n" + tell "\n" + tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getDocDir, getLibexecDir, getSysconfDir :: IO FilePath\n" tell "\n" let z_var0_function_defs = do @@ -168,6 +180,11 @@ render z_root = execWriter $ do tell "_datadir\") (\\_ -> getPrefixDirReloc $ " tell (zDatadir z_root) tell ")\n" + tell "getDocDir = catchIO (getEnv \"" + tell (zManglePkgName z_root (zPackageName z_root)) + tell "_docdir\") (\\_ -> getPrefixDirReloc $ " + tell (zDocdir z_root) + tell ")\n" tell "getLibexecDir = catchIO (getEnv \"" tell (zManglePkgName z_root (zPackageName z_root)) tell "_libexecdir\") (\\_ -> getPrefixDirReloc $ " @@ -199,6 +216,9 @@ render z_root = execWriter $ do tell "datadir = " tell (zDatadir z_root) tell "\n" + tell "docdir = " + tell (zDocdir z_root) + tell "\n" tell "libexecdir = " tell (zLibexecdir z_root) tell "\n" @@ -218,6 +238,9 @@ render z_root = execWriter $ do tell "getDataDir = catchIO (getEnv \"" tell (zManglePkgName z_root (zPackageName z_root)) tell "_datadir\") (\\_ -> return datadir)\n" + tell "getDocDir = catchIO (getEnv \"" + tell (zManglePkgName z_root (zPackageName z_root)) + tell "_docdir\") (\\_ -> return docdir)\n" tell "getLibexecDir = catchIO (getEnv \"" tell (zManglePkgName z_root (zPackageName z_root)) tell "_libexecdir\") (\\_ -> return libexecdir)\n" @@ -249,6 +272,9 @@ render z_root = execWriter $ do tell "_datadir\") (\\_ -> " tell (zDatadir z_root) tell ")\n" + tell "getDocDir = " + tell (zDocdir z_root) + tell "\n" tell "getLibexecDir = " tell (zLibexecdir z_root) tell "\n" diff --git a/Makefile b/Makefile index 6d8394aa64e..fb65648e595 100644 --- a/Makefile +++ b/Makefile @@ -44,8 +44,9 @@ $(SPDX_EXCEPTION_HS) : templates/SPDX.LicenseExceptionId.template.hs cabal-dev-s TEMPLATE_MACROS:=Cabal/src/Distribution/Simple/Build/Macros/Z.hs TEMPLATE_PATHS:=Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs +TEMPLATE_PKGINFO:=Cabal/src/Distribution/Simple/Build/PackageInfoModule/Z.hs -templates : phony $(TEMPLATE_MACROS) $(TEMPLATE_PATHS) +templates : phony $(TEMPLATE_MACROS) $(TEMPLATE_PATHS) $(TEMPLATE_PKGINFO) $(TEMPLATE_MACROS) : templates/cabal_macros.template.h cabal-dev-scripts/src/GenCabalMacros.hs cabal run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-cabal-macros -- $< $@ @@ -53,6 +54,9 @@ $(TEMPLATE_MACROS) : templates/cabal_macros.template.h cabal-dev-scripts/src/Gen $(TEMPLATE_PATHS) : templates/Paths_pkg.template.hs cabal-dev-scripts/src/GenPathsModule.hs cabal run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-paths-module -- $< $@ +$(TEMPLATE_PKGINFO) : templates/PackageInfo_pkg.template.hs cabal-dev-scripts/src/GenPackageInfoModule.hs + cabal run --builddir=dist-newstyle-meta --project-file=cabal.project.meta gen-pkg-info-module -- $< $@ + # generated docs buildinfo-fields-reference : phony diff --git a/cabal-dev-scripts/cabal-dev-scripts.cabal b/cabal-dev-scripts/cabal-dev-scripts.cabal index dcf40f84371..a4d7d8eab7e 100644 --- a/cabal-dev-scripts/cabal-dev-scripts.cabal +++ b/cabal-dev-scripts/cabal-dev-scripts.cabal @@ -18,7 +18,7 @@ executable gen-spdx ghc-options: -Wall build-depends: , aeson ^>=1.4.1.0 || ^>=1.5.2.0 || ^>=2.1.1.0 - , base >=4.10 && <4.17 + , base >=4.10 , bytestring , containers , Diff ^>=0.4 @@ -35,7 +35,7 @@ executable gen-spdx-exc ghc-options: -Wall build-depends: , aeson ^>=1.4.1.0 || ^>=1.5.2.0 || ^>=2.1.1.0 - , base >=4.10 && <4.17 + , base >=4.10 , bytestring , containers , Diff ^>=0.4 @@ -84,6 +84,20 @@ executable gen-paths-module , template-haskell , zinza ^>=0.2 +executable gen-pkg-info-module + default-language: Haskell2010 + main-is: GenPackageInfoModule.hs + other-modules: Capture + hs-source-dirs: src + ghc-options: -Wall + build-depends: + , base + , bytestring + , Cabal + , syb ^>=0.7.1 + , template-haskell + , zinza ^>=0.2 + executable gen-cabal-install-cabal default-language: Haskell2010 main-is: GenCabalInstallCabal.hs diff --git a/cabal-dev-scripts/src/GenPackageInfoModule.hs b/cabal-dev-scripts/src/GenPackageInfoModule.hs new file mode 100644 index 00000000000..ace5a7e7c98 --- /dev/null +++ b/cabal-dev-scripts/src/GenPackageInfoModule.hs @@ -0,0 +1,96 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TemplateHaskell #-} +{-# OPTIONS_GHC -Wno-orphans #-} +module Main (main) where + +import Control.Exception (SomeException (..), catch, displayException) +import Distribution.Types.PackageName (PackageName) +import GHC.Generics (Generic) +import System.Environment (getArgs) +import System.Exit (exitFailure) +import Zinza + (ModuleConfig (..), Ty (..), Zinza (..), genericFromValueSFP, genericToTypeSFP, + genericToValueSFP, parseAndCompileModuleIO) + +import Capture + +------------------------------------------------------------------------------- +-- Inputs +------------------------------------------------------------------------------- + +$(capture "decls" [d| + data Z = Z + { zPackageName :: PackageName + , zVersionDigits :: String + , zLicense :: String + , zCopyright :: String + , zMaintainer :: String + , zAuthor :: String + , zStability :: String + , zHomepage :: String + , zPkgUrl :: String + , zBugReports :: String + , zSynopsis :: String + , zDescription :: String + , zCategory :: String + + , zSupportsNoRebindableSyntax :: Bool + + , zManglePkgName :: PackageName -> String + , zShow :: String -> String + } + deriving (Generic) + |]) + +------------------------------------------------------------------------------- +-- Main +------------------------------------------------------------------------------- + +withIO :: (FilePath -> FilePath -> IO a) -> IO a +withIO k = do + args <- getArgs + case args of + [src,tgt] -> k src tgt `catch` \(SomeException e) -> do + putStrLn $ "Exception: " ++ displayException e + exitFailure + _ -> do + putStrLn "Usage cabal run ... source.temeplate.ext target.ext" + exitFailure + +main :: IO () +main = withIO $ \src tgt -> do + mdl <- parseAndCompileModuleIO config src + writeFile tgt mdl + +config :: ModuleConfig Z +config = ModuleConfig + { mcRender = "render" + , mcHeader = + [ "{- FOURMOLU_DISABLE -}" + , "{-# LANGUAGE DeriveGeneric #-}" + , "module Distribution.Simple.Build.PackageInfoModule.Z (render, Z(..)) where" + , "import Distribution.ZinzaPrelude" + , decls + , "render :: Z -> String" + ] + } + +------------------------------------------------------------------------------- +-- Zinza instances +------------------------------------------------------------------------------- + +instance Zinza Z where + toType = genericToTypeSFP + toValue = genericToValueSFP + fromValue = genericFromValueSFP + +------------------------------------------------------------------------------- +-- Orphans +------------------------------------------------------------------------------- + +instance Zinza PackageName where + toType _ = TyString (Just "prettyShow") + toValue _ = error "not needed" + fromValue _ = error "not needed" diff --git a/cabal-dev-scripts/src/GenPathsModule.hs b/cabal-dev-scripts/src/GenPathsModule.hs index 46ef779e2af..1a0d32cd432 100644 --- a/cabal-dev-scripts/src/GenPathsModule.hs +++ b/cabal-dev-scripts/src/GenPathsModule.hs @@ -25,6 +25,7 @@ $(capture "decls" [d| data Z = Z { zPackageName :: PackageName , zVersionDigits :: String + , zLicenseFiles :: String , zSupportsCpp :: Bool , zSupportsNoRebindableSyntax :: Bool , zAbsolute :: Bool @@ -38,6 +39,7 @@ $(capture "decls" [d| , zLibdir :: FilePath , zDynlibdir :: FilePath , zDatadir :: FilePath + , zDocdir :: FilePath , zLibexecdir :: FilePath , zSysconfdir :: FilePath diff --git a/templates/PackageInfo_pkg.template.hs b/templates/PackageInfo_pkg.template.hs new file mode 100644 index 00000000000..fe7433eebd6 --- /dev/null +++ b/templates/PackageInfo_pkg.template.hs @@ -0,0 +1,62 @@ +{% if supportsNoRebindableSyntax %} +{-# LANGUAGE NoRebindableSyntax #-} +{% endif %} +{-# OPTIONS_GHC -fno-warn-missing-import-lists #-} +{-# OPTIONS_GHC -w #-} +module PackageInfo_{{ manglePkgName packageName }} + ( name + , version + , license + , copyright + , maintainer + , author + , stability + , homepage + , pkgUrl + , bugReports + , synopsis + , description + , category + ) where + +import Data.Version (Version(..)) +import Prelude + +name :: String +name = {{ show (manglePkgName packageName) }} + +version :: Version +version = Version {{ versionDigits }} [] + +license :: String +license = {{ license }} + +copyright :: String +copyright = {{ copyright }} + +maintainer :: String +maintainer = {{ maintainer }} + +author :: String +author = {{ author }} + +stability :: String +stability = {{ stability }} + +homepage :: String +homepage = {{ homepage }} + +pkgUrl :: String +pkgUrl = {{ pkgUrl }} + +bugReports :: String +bugReports = {{ bugReports }} + +synopsis :: String +synopsis = {{ synopsis }} + +description :: String +description = {{ description }} + +category :: String +category = {{ category }} diff --git a/templates/Paths_pkg.template.hs b/templates/Paths_pkg.template.hs index 8e1e03d27e4..30cc703c30e 100644 --- a/templates/Paths_pkg.template.hs +++ b/templates/Paths_pkg.template.hs @@ -15,9 +15,9 @@ {-# OPTIONS_GHC -fno-warn-missing-import-lists #-} {-# OPTIONS_GHC -w #-} module Paths_{{ manglePkgName packageName }} ( - version, - getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, - getDataFileName, getSysconfDir + version, licenseFiles, + getBinDir, getLibDir, getDynLibDir, getDataDir, getDocDir, getLibexecDir, + getDataFileName, getDocFileName, getSysconfDir ) where {% if not absolute %} @@ -56,12 +56,20 @@ catchIO = Exception.catch version :: Version version = Version {{ versionDigits }} [] +licenseFiles :: [FilePath] +licenseFiles = {{ licenseFiles }} + getDataFileName :: FilePath -> IO FilePath getDataFileName name = do dir <- getDataDir return (dir `joinFileName` name) -getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath +getDocFileName :: FilePath -> IO FilePath +getDocFileName name = do + dir <- getDocDir + return (dir `joinFileName` name) + +getBinDir, getLibDir, getDynLibDir, getDataDir, getDocDir, getLibexecDir, getSysconfDir :: IO FilePath {% defblock function_defs %} minusFileName :: FilePath -> String -> FilePath @@ -100,6 +108,7 @@ getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\ getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> getPrefixDirReloc $ {{ libdir }}) getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> getPrefixDirReloc $ {{ dynlibdir }}) getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> getPrefixDirReloc $ {{ datadir }}) +getDocDir = catchIO (getEnv "{{ manglePkgName packageName }}_docdir") (\_ -> getPrefixDirReloc $ {{ docdir }}) getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> getPrefixDirReloc $ {{ libexecdir }}) getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> getPrefixDirReloc $ {{ sysconfdir }}) @@ -112,6 +121,7 @@ bindir = {{ bindir }} libdir = {{ libdir }} dynlibdir = {{ dynlibdir }} datadir = {{ datadir }} +docdir = {{ docdir }} libexecdir = {{ libexecdir }} sysconfdir = {{ sysconfdir }} @@ -119,6 +129,7 @@ getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\ getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> return libdir) getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> return dynlibdir) getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> return datadir) +getDocDir = catchIO (getEnv "{{ manglePkgName packageName }}_docdir") (\_ -> return docdir) getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> return libexecdir) getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> return sysconfdir) @@ -131,6 +142,7 @@ getBinDir = getPrefixDirRel $ {{ bindir }} getLibDir = {{ libdir }} getDynLibDir = {{ dynlibdir }} getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> {{ datadir }}) +getDocDir = {{ docdir }} getLibexecDir = {{ libexecdir }} getSysconfDir = {{ sysconfdir }}