cabal-toolkit 0.0.3 → 0.0.4
raw patch · 2 files changed
+54/−7 lines, 2 filesdep ~Cabaldep ~base
Dependency ranges changed: Cabal, base
Files
- cabal-toolkit.cabal +13/−4
- src/Distribution/Simple/Toolkit.hs +41/−3
cabal-toolkit.cabal view
@@ -1,10 +1,17 @@--- This file has been generated from package.yaml by hpack version 0.17.1.+-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack+--+-- hash: bbfe5abf3fb2315c5b297aa754349297649bad1bc491dd3fea8b8b0ee224a4a8 name: cabal-toolkit-version: 0.0.3+version: 0.0.4 synopsis: Helper functions for writing custom Setup.hs scripts.+description: Helper functions for writing custom Setup.hs scripts.+ .+ This is useful to access configuration parameters of a @Cabal@-based project+ at runtime, e.g. when you want to supply the right+ @GHC_PACKAGE_PATH@ to @ghc@ oder @ghci@. category: Distribution stability: alpha homepage: https://github.com/TerrorJack/cabal-toolkit#readme@@ -31,13 +38,15 @@ other-extensions: TemplateHaskell ghc-options: -Wall build-depends:- base >= 4.10 && < 5+ Cabal >=1.24 && <2.2+ , base >=4.9 && <5 , binary , bytestring , containers- , Cabal >= 2.0 && < 2.2 , ghc , template-haskell exposed-modules: Distribution.Simple.Toolkit+ other-modules:+ Paths_cabal_toolkit default-language: Haskell2010
src/Distribution/Simple/Toolkit.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -Wno-deprecations #-} {-# OPTIONS_HADDOCK show-extensions #-}@@ -45,9 +46,11 @@ import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Program import Distribution.Simple.Setup+#if !MIN_VERSION_Cabal(2,0,0)+import qualified Distribution.Simple.InstallDirs as InstallDirs+#endif import Distribution.System-import Distribution.Types.BuildInfo-import Distribution.Types.PackageDescription+import Distribution.PackageDescription import Distribution.Verbosity import DynFlags import Language.Haskell.TH.Syntax@@ -103,6 +106,23 @@ localBuildInfoTypedQ :: Q (TExp LocalBuildInfo) localBuildInfoTypedQ = unsafeTExpCoerce localBuildInfoQ +#if !MIN_VERSION_Cabal(2,0,0)+-- | As defined in @Cabal-2.0.0.2@. See 'Distribution.Simple.InstallDirs.absoluteInstallDirs'.+absoluteComponentInstallDirs + :: PackageDescription -> LocalBuildInfo+ -> UnitId+ -> CopyDest+ -> InstallDirs FilePath+absoluteComponentInstallDirs pkg lbi uid copydest =+ InstallDirs.absoluteInstallDirs+ (packageId pkg)+ uid+ (Distribution.Simple.compilerInfo (compiler lbi))+ copydest+ (hostPlatform lbi)+ (installDirTemplates lbi)+#endif+ {-| Retrieve the 'InstallDirs' corresponding to a 'ComponentName', assuming that component does exist and is unique. -}@@ -151,8 +171,11 @@ prog (withPrograms lbi) ++#if MIN_VERSION_Cabal(2,0,0) {-|-Extract 'PackageDBFlag's from 'LocalBuildInfo' to put into the 'packageDBFlags' field of 'DynFlags'. This is useful to ensure the invocation of GHC API shares the same package databases (e.g. a @stack@ snapshot)+Extract 'PackageDBFlag's from 'LocalBuildInfo' to put into the 'packageDBFlags' field of 'DynFlags'. +This is useful to ensure the invocation of GHC API shares the same package databases (e.g. a @stack@ snapshot) -} getGHCPackageDBFlags :: LocalBuildInfo -> [PackageDBFlag] getGHCPackageDBFlags lbi =@@ -169,6 +192,21 @@ single UserPackageDB = PackageDB UserPkgConf isSpecific (SpecificPackageDB _) = True isSpecific _ = False+#else+-- 'PackageDBFlag' is a new wrapper around 'PkgConfRef' introduced in ghc-8.2.1 and Cabal-2.+-- ghc-8.0.2/Cabal-1.24 has a similar mechanism around 'extraPkgConfs' which was superseded+-- by 'packageDBFlags'.+{-|+Extract 'PkgConfRef's from 'LocalBuildInfo' to be prepended to the 'extraPkgConfs' field of 'DynFlags'. +This is useful to ensure the invocation of GHC API shares the same package databases (e.g. a @stack@ snapshot)+-}+getGHCPackageDBFlags :: LocalBuildInfo -> [PkgConfRef]+getGHCPackageDBFlags = reverse . fmap toPkgConfRef . withPackageDB+ where+ toPkgConfRef (SpecificPackageDB db) = PkgConfFile db+ toPkgConfRef GlobalPackageDB = GlobalPkgConf+ toPkgConfRef UserPackageDB = UserPkgConf+#endif endOfFirstLineVersion :: Verbosity -> FilePath -> IO (Maybe Version) endOfFirstLineVersion =