summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlarsk <>2015-02-16 07:55:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2015-02-16 07:55:00 (GMT)
commit27dec4745b5bbb29fb65d036742ce1ed0db0b103 (patch)
treef644ff79d474436b4882d2bc28ae03775b46e779
parent9c32f87bb12f62919b8e67c3b0e2519973643080 (diff)
version 0.2.110.2.11
-rw-r--r--CHANGELOG.md7
-rw-r--r--Setup.hs41
-rw-r--r--configuration-tools.cabal10
-rw-r--r--src/Configuration/Utils/Setup.hs41
4 files changed, 90 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e2112fd..e25aea4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
======
diff --git a/Setup.hs b/Setup.hs
index adffbcd..10e52d5 100644
--- a/Setup.hs
+++ b/Setup.hs
@@ -2,7 +2,9 @@
-- Copyright © 2014 AlephCloud Systems, Inc.
-- ------------------------------------------------------ --
+{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_HADDOCK show-extensions #-}
@@ -130,6 +132,16 @@ import Prelude hiding (readFile, writeFile)
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,13 +343,38 @@ updatePkgInfoModule cName pkgDesc bInfo = do
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
tag <- trim <$> readProcess "hg" ["id", "-r", "max(ancestors(\".\") and tag())", "-t"] ""
diff --git a/configuration-tools.cabal b/configuration-tools.cabal
index 5e20e3b..bb03864 100644
--- a/configuration-tools.cabal
+++ b/configuration-tools.cabal
@@ -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 @@ Copyright: Copyright (c) 2014-2015 AlephCloud, Inc.
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 head
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 @@ Library
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 @@ Test-Suite url-example-test
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,
diff --git a/src/Configuration/Utils/Setup.hs b/src/Configuration/Utils/Setup.hs
index 1a4f3b1..4ff38ac 100644
--- a/src/Configuration/Utils/Setup.hs
+++ b/src/Configuration/Utils/Setup.hs
@@ -2,7 +2,9 @@
-- Copyright © 2014 AlephCloud Systems, Inc.
-- ------------------------------------------------------ --
+{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_HADDOCK show-extensions #-}
@@ -130,6 +132,16 @@ import Prelude hiding (readFile, writeFile)
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,13 +343,38 @@ updatePkgInfoModule cName pkgDesc bInfo = do
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
tag <- trim <$> readProcess "hg" ["id", "-r", "max(ancestors(\".\") and tag())", "-t"] ""