configuration-tools 0.2.10 → 0.2.11
raw patch · 4 files changed
+90/−9 lines, 4 filesdep ~Cabalsetup-changedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Cabal
API changes (from Hackage documentation)
Files
- CHANGELOG.md +7/−0
- Setup.hs +39/−2
- configuration-tools.cabal +5/−5
- src/Configuration/Utils/Setup.hs +39/−2
CHANGELOG.md view
@@ -1,3 +1,10 @@+0.2.11+======++* Added support for Cabal-1.18. This is supposed to make the build more+ robust and simplify integration with existing build infrastructure+ and other packages.+ 0.2.10 ======
Setup.hs view
@@ -2,7 +2,9 @@ -- Copyright © 2014 AlephCloud Systems, Inc. -- ------------------------------------------------------ -- +{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_HADDOCK show-extensions #-} @@ -130,6 +132,16 @@ import System.Directory (doesFileExist, doesDirectoryExist, createDirectoryIfMissing) import System.Exit (ExitCode(ExitSuccess)) +#ifndef MIN_VERSION_Cabal+#define NO_CABAL_MACROS 1+#define MIN_VERSION_Cabal(a,b,c) 0+#endif++#ifdef NO_CABAL_MACROS+import Data.Maybe+import Data.Typeable+#endif+ -- | Include this function when your setup doesn't contain any -- extra functionality. --@@ -331,12 +343,37 @@ fileName = pkgInfoFileName cName bInfo licenseFilesText :: PackageDescription -> IO B.ByteString-licenseFilesText PackageDescription{ licenseFiles = fileNames } =- B.intercalate "\n------------------------------------------------------------\n" <$> mapM fileText fileNames+licenseFilesText pkgDesc =+ B.intercalate "\n------------------------------------------------------------\n" <$> mapM fileText+#ifdef NO_CABAL_MACROS+ (getLicenseFiles pkgDesc)+#elif MIN_VERSION_Cabal(1,20,0)+ (licenseFiles pkgDesc)+#else+ [licenseFile pkgDesc]+#endif where fileText file = doesFileExist file >>= \x -> if x then B.readFile file else return ""++#ifdef NO_CABAL_MACROS+-- The name and the type of the @licenseFile :: String@ field of 'PackageDescription' changed+-- in Cabal version 1.20 to @licenseFiles :: [String]@. Both versions are used with GHC-7.8.+-- When compiling @Setup.hs@ the @MIN_VERSION_...@ macros are not available. This function is an+-- ugly hack to do conditional compilation without CPP.+--+-- It will break if the number of record fields changes. If that's the case we will probably+-- have to either+--+-- * Use typeable to pattern match on the number of constructor arguments for 'PackageDescription',+-- * use TH hacks ala @$( if versionBranch cabalVersion < [...] ... )@, and/or+-- * make guesses about the cabal version based on the @__GLASGOW_HASKELL__@ macro.+--+getLicenseFiles :: PackageDescription -> [FilePath]+getLicenseFiles (PackageDescription _ _ l _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) =+ fromMaybe (error "unsupport Cabal library version") $ cast l <|> (return <$> cast l)+#endif hgInfo :: IO (String, String, String) hgInfo = do
configuration-tools.cabal view
@@ -3,7 +3,7 @@ -- ------------------------------------------------------ -- Name: configuration-tools-Version: 0.2.10+Version: 0.2.11 Synopsis: Tools for specifying and parsing configurations description: Tools for specifying and parsing configurations@@ -37,7 +37,7 @@ Category: Configuration, Console Build-type: Custom -cabal-version: >= 1.20+cabal-version: >= 1.18 extra-doc-files: README.md,@@ -54,7 +54,7 @@ source-repository this type: git location: https://github.com/alephcloud/hs-configuration-tools.git- tag: 0.2.10+ tag: 0.2.11 flag remote-configs Description: enable loading of configuration files from HTTP URLs@@ -82,7 +82,7 @@ Configuration.Utils.Internal.HttpsCertPolicy build-depends:- Cabal >= 1.20,+ Cabal >= 1.18, aeson >= 0.7.0.6, ansi-wl-pprint >= 0.6, attoparsec >= 0.11.3.4,@@ -140,7 +140,7 @@ base >= 4.6 && < 5.0, base-unicode-symbols >= 0.2.2.4, bytestring >= 0.10,- Cabal >= 1.20,+ Cabal >= 1.18, configuration-tools, errors >= 1.4.3, mtl >= 2.2,
src/Configuration/Utils/Setup.hs view
@@ -2,7 +2,9 @@ -- Copyright © 2014 AlephCloud Systems, Inc. -- ------------------------------------------------------ -- +{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_HADDOCK show-extensions #-} @@ -130,6 +132,16 @@ import System.Directory (doesFileExist, doesDirectoryExist, createDirectoryIfMissing) import System.Exit (ExitCode(ExitSuccess)) +#ifndef MIN_VERSION_Cabal+#define NO_CABAL_MACROS 1+#define MIN_VERSION_Cabal(a,b,c) 0+#endif++#ifdef NO_CABAL_MACROS+import Data.Maybe+import Data.Typeable+#endif+ -- | Include this function when your setup doesn't contain any -- extra functionality. --@@ -331,12 +343,37 @@ fileName = pkgInfoFileName cName bInfo licenseFilesText :: PackageDescription -> IO B.ByteString-licenseFilesText PackageDescription{ licenseFiles = fileNames } =- B.intercalate "\n------------------------------------------------------------\n" <$> mapM fileText fileNames+licenseFilesText pkgDesc =+ B.intercalate "\n------------------------------------------------------------\n" <$> mapM fileText+#ifdef NO_CABAL_MACROS+ (getLicenseFiles pkgDesc)+#elif MIN_VERSION_Cabal(1,20,0)+ (licenseFiles pkgDesc)+#else+ [licenseFile pkgDesc]+#endif where fileText file = doesFileExist file >>= \x -> if x then B.readFile file else return ""++#ifdef NO_CABAL_MACROS+-- The name and the type of the @licenseFile :: String@ field of 'PackageDescription' changed+-- in Cabal version 1.20 to @licenseFiles :: [String]@. Both versions are used with GHC-7.8.+-- When compiling @Setup.hs@ the @MIN_VERSION_...@ macros are not available. This function is an+-- ugly hack to do conditional compilation without CPP.+--+-- It will break if the number of record fields changes. If that's the case we will probably+-- have to either+--+-- * Use typeable to pattern match on the number of constructor arguments for 'PackageDescription',+-- * use TH hacks ala @$( if versionBranch cabalVersion < [...] ... )@, and/or+-- * make guesses about the cabal version based on the @__GLASGOW_HASKELL__@ macro.+--+getLicenseFiles :: PackageDescription -> [FilePath]+getLicenseFiles (PackageDescription _ _ l _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) =+ fromMaybe (error "unsupport Cabal library version") $ cast l <|> (return <$> cast l)+#endif hgInfo :: IO (String, String, String) hgInfo = do