summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlarsk <>2016-03-17 03:50:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2016-03-17 03:50:00 (GMT)
commit122bcf6d7cd92bfbdbb1fd327021d422bda3c133 (patch)
tree7a9f91aab762fa307ba20c47217de068528a4a13
parent1a2ed8e45b0668bf0cd90588f1e817b1b155f03f (diff)
version 0.2.140.2.14
-rw-r--r--CHANGELOG.md5
-rw-r--r--Setup.hs75
-rw-r--r--configuration-tools.cabal31
-rw-r--r--constraints-ghc-8.0.194
-rw-r--r--src/Configuration/Utils/Setup.hs56
5 files changed, 217 insertions, 44 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ee986dc..91582c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+0.2.14
+======
+
+* Support for GHC-8 and Cabal-1.24
+
0.2.13
======
diff --git a/Setup.hs b/Setup.hs
index 10e52d5..87a5fb6 100644
--- a/Setup.hs
+++ b/Setup.hs
@@ -1,7 +1,9 @@
-- ------------------------------------------------------ --
+-- Copyright © 2015-2016 Lars Kuhtz <lakuhtz@gmail.com>
-- Copyright © 2014 AlephCloud Systems, Inc.
-- ------------------------------------------------------ --
+{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
@@ -129,7 +131,8 @@ import Data.Monoid
import Prelude hiding (readFile, writeFile)
-import System.Directory (doesFileExist, doesDirectoryExist, createDirectoryIfMissing)
+import System.Directory (doesFileExist, doesDirectoryExist, createDirectoryIfMissing, getCurrentDirectory, canonicalizePath)
+import System.FilePath (isDrive, (</>), takeDirectory)
import System.Exit (ExitCode(ExitSuccess))
#ifndef MIN_VERSION_Cabal
@@ -204,12 +207,18 @@ trim = f . f
where f = reverse . dropWhile isSpace
getVCS :: IO (Maybe RepoType)
-getVCS =
- doesDirectoryExist ".hg" >>= \x0 -> if x0
+getVCS = getCurrentDirectory >>= getVcsOfDir
+
+getVcsOfDir :: FilePath -> IO (Maybe RepoType)
+getVcsOfDir d = do
+ canonicDir <- canonicalizePath d
+ doesDirectoryExist (canonicDir </> ".hg") >>= \x0 -> if x0
then return (Just Mercurial)
- else doesDirectoryExist ".git" >>= \x1 -> return $ if x1
- then Just Git
- else Nothing
+ else doesDirectoryExist (canonicDir </> ".git") >>= \x1 -> if x1
+ then return $ Just Git
+ else if isDrive canonicDir
+ then return Nothing
+ else getVcsOfDir (takeDirectory canonicDir)
flagNameStr :: FlagName -> String
flagNameStr (FlagName s) = s
@@ -273,7 +282,7 @@ pkgInfoModule cName pkgDesc bInfo = do
, " licenseText = " <> (pack . show) licenseString
, ""
, " copyright :: IsString a => a"
- , " copyright = \"" <> (pack . copyright) pkgDesc <> "\""
+ , " copyright = " <> (pack . show . copyright) pkgDesc
, ""
, " author :: IsString a => a"
, " author = \"" <> (pack . author) pkgDesc <> "\""
@@ -358,21 +367,51 @@ licenseFilesText pkgDesc =
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.
+-- 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. In Cabal version 1.24 the
+-- number of constructor fields changed for PackageDescription. When compiling
+-- @Setup.hs@ the @MIN_VERSION_...@ macros are not available. This function is
+-- an ugly hack to do conditional compilation without CPP. It depends on the
+-- @RecordWildCards@ and @Typeable@ extensions and abuses shaddowing of
+-- existing symbols.
--
--- It will break if the number of record fields changes. If that's the case we will probably
--- have to either
+-- Alternative methods would include:
--
--- * 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.
+-- * 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.
+
+-- Return license files of from the @PackageDescription@.
--
getLicenseFiles :: PackageDescription -> [FilePath]
-getLicenseFiles (PackageDescription _ _ l _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) =
- fromMaybe (error "unsupport Cabal library version") $ cast l <|> (return <$> cast l)
+getLicenseFiles pkgDesc = f pkgDesc
+ where
+ -- Recent versions of @PackageDescription@ define a @licenseFiles@ field.
+ -- For older versions the function @licenseFiles@ that is defined below is
+ -- used.
+ --
+ f PackageDescription{..} = licenseFiles
+
+ -- If @PackageDescription@ doesn't define @licenseFiles@ this definition
+ -- will be used. In that case @PackageDescription@ is assumed to define
+ -- @licenseFile@.
+ --
+ licenseFiles :: [FilePath]
+ licenseFiles = fromMaybe (error "unsupported Cabal library version") $
+ return <$> cast (g pkgDesc)
+
+ g PackageDescription{..} = licenseFile
+
+ -- The only purpose of this function is to ensure that licenseFile is
+ -- defined in case PackageDescription doesn't have a @licenseFile@ field.
+ -- This function won't be called with any supported version of the Cabal
+ -- library.
+ --
+ licenseFile :: [FilePath]
+ licenseFile = error "unexpected Cabal library version"
#endif
hgInfo :: IO (String, String, String)
diff --git a/configuration-tools.cabal b/configuration-tools.cabal
index 5fa1792..767409e 100644
--- a/configuration-tools.cabal
+++ b/configuration-tools.cabal
@@ -1,11 +1,11 @@
-- ------------------------------------------------------ --
--- Copyright © 2015 Lars Kuhtz <lakuhtz@gmail.com>
+-- Copyright © 2015-2016 Lars Kuhtz <lakuhtz@gmail.com>
-- Copyright © 2014-2015 AlephCloud Systems, Inc.
-- ------------------------------------------------------ --
-Name: configuration-tools
-Version: 0.2.13
-Synopsis: Tools for specifying and parsing configurations
+Name: configuration-tools
+Version: 0.2.14
+Synopsis: Tools for specifying and parsing configurations
description:
Tools for specifying and parsing configurations
.
@@ -28,15 +28,17 @@ description:
and in the API documentation of the modules "Configuration.Utils" and
"Configuration.Utils.Setup".
-Homepage: https://github.com/alephcloud/hs-configuration-tools
-Bug-reports: https://github.com/alephcloud/hs-configuration-tools/issues
-License: MIT
-License-file: LICENSE
-Author: Lars Kuhtz <lakuhtz@gmail.com>
-Maintainer: Lars Kuhtz <lakuhtz@gmail.com>
-Copyright: Copyright (c) 2015 Lars Kuhtz <lakuhtz@gmail.com>, 2014-2015 AlephCloud, Inc.
-Category: Configuration, Console
-Build-type: Custom
+Homepage: https://github.com/alephcloud/hs-configuration-tools
+Bug-reports: https://github.com/alephcloud/hs-configuration-tools/issues
+License: MIT
+License-file: LICENSE
+Author: Lars Kuhtz <lakuhtz@gmail.com>
+Maintainer: Lars Kuhtz <lakuhtz@gmail.com>
+Copyright:
+ (c) 2015-2016 Lars Kuhtz <lakuhtz@gmail.com>,
+ (c) 2014-2015 AlephCloud, Inc.
+Category: Configuration, Console
+Build-type: Custom
cabal-version: >= 1.18
@@ -48,6 +50,7 @@ extra-doc-files:
extra-source-files:
constraints
constraints.old-transformers
+ constraints-ghc-8.0.1
source-repository head
type: git
@@ -57,7 +60,7 @@ source-repository head
source-repository this
type: git
location: https://github.com/alephcloud/hs-configuration-tools.git
- tag: 0.2.13
+ tag: 0.2.14
flag remote-configs
Description: enable loading of configuration files from HTTP URLs
diff --git a/constraints-ghc-8.0.1 b/constraints-ghc-8.0.1
new file mode 100644
index 0000000..2bcf6ef
--- /dev/null
+++ b/constraints-ghc-8.0.1
@@ -0,0 +1,94 @@
+constraints: Cabal ==1.23.1.0,
+ array ==0.5.1.0,
+ base ==4.9.0.0,
+ ghc-prim ==0.5.0.0,
+ rts ==1.0,
+ integer-gmp ==1.0.0.1,
+ binary ==0.8.2.0,
+ bytestring ==0.10.7.0,
+ deepseq ==1.4.2.0,
+ containers ==0.5.7.1,
+ directory ==1.2.5.0,
+ filepath ==1.4.1.0,
+ time ==1.6,
+ unix ==2.7.2.0,
+ pretty ==1.1.3.2,
+ process ==1.4.2.0,
+ aeson ==0.11.0.0,
+ attoparsec ==0.13.0.1,
+ scientific ==0.3.4.4,
+ hashable ==1.2.4.0,
+ text ==1.2.2.0,
+ vector ==0.11.0.0,
+ primitive ==0.6.1.0,
+ transformers ==0.5.1.0,
+ dlist ==0.7.1.2,
+ fail ==4.9.0.0,
+ mtl ==2.2.1,
+ syb ==0.6,
+ template-haskell ==2.11.0.0,
+ ghc-boot ==8.0.0.20160204,
+ unordered-containers ==0.2.6.0,
+ ansi-wl-pprint ==0.6.7.3,
+ ansi-terminal ==0.6.2.3,
+ base-unicode-symbols ==0.2.2.4,
+ base64-bytestring ==1.0.0.1,
+ case-insensitive ==1.2.0.5,
+ connection ==0.2.5,
+ byteable ==0.1.1,
+ data-default-class ==0.0.1,
+ network ==2.6.2.1,
+ socks ==0.5.4,
+ cereal ==0.5.1.0,
+ tls ==1.3.4,
+ asn1-encoding ==0.9.3,
+ asn1-types ==0.3.2,
+ hourglass ==0.2.9,
+ memory ==0.11,
+ async ==2.1.0,
+ stm ==2.4.4.1,
+ cryptonite ==0.11,
+ x509 ==1.6.3,
+ asn1-parse ==0.9.4,
+ pem ==0.2.2,
+ x509-store ==1.6.1,
+ x509-validation ==1.6.3,
+ x509-system ==1.6.3,
+ data-default ==0.5.3,
+ data-default-instances-base ==0.0.1,
+ data-default-instances-containers ==0.0.1,
+ data-default-instances-dlist ==0.0.1,
+ data-default-instances-old-locale ==0.0.1,
+ old-locale ==1.0.0.7,
+ enclosed-exceptions ==1.0.1.1,
+ lifted-base ==0.2.3.6,
+ monad-control ==1.0.0.5,
+ transformers-base ==0.4.4,
+ transformers-compat ==0.5.1.4,
+ http-client ==0.4.27,
+ blaze-builder ==0.4.0.1,
+ cookie ==0.4.1.6,
+ exceptions ==0.8.2.1,
+ http-types ==0.9,
+ mime-types ==0.1.0.6,
+ network-uri ==2.6.0.3,
+ parsec ==3.1.9,
+ random ==1.0.1.1,
+ streaming-commons ==0.1.15.1,
+ zlib ==0.6.1.1,
+ http-client-tls ==0.2.2,
+ optparse-applicative ==0.12.1.0,
+ profunctors ==5.2,
+ base-orphans ==0.5.1,
+ bifunctors ==5.2.1,
+ comonad ==5,
+ contravariant ==1.4,
+ StateVar ==1.1.0.3,
+ semigroups ==0.18.1,
+ void ==0.7.1,
+ distributive ==0.5.0.2,
+ tagged ==0.8.3,
+ yaml ==0.8.16,
+ conduit ==1.2.6.2,
+ mmorph ==1.0.6,
+ resourcet ==1.1.7.2
diff --git a/src/Configuration/Utils/Setup.hs b/src/Configuration/Utils/Setup.hs
index c583579..494d7bc 100644
--- a/src/Configuration/Utils/Setup.hs
+++ b/src/Configuration/Utils/Setup.hs
@@ -1,7 +1,9 @@
-- ------------------------------------------------------ --
+-- Copyright © 2015-2016 Lars Kuhtz <lakuhtz@gmail.com>
-- Copyright © 2014 AlephCloud Systems, Inc.
-- ------------------------------------------------------ --
+{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
@@ -280,7 +282,7 @@ pkgInfoModule cName pkgDesc bInfo = do
, " licenseText = " <> (pack . show) licenseString
, ""
, " copyright :: IsString a => a"
- , " copyright = \"" <> (pack . copyright) pkgDesc <> "\""
+ , " copyright = " <> (pack . show . copyright) pkgDesc
, ""
, " author :: IsString a => a"
, " author = \"" <> (pack . author) pkgDesc <> "\""
@@ -365,21 +367,51 @@ licenseFilesText pkgDesc =
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.
+-- 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. In Cabal version 1.24 the
+-- number of constructor fields changed for PackageDescription. When compiling
+-- @Setup.hs@ the @MIN_VERSION_...@ macros are not available. This function is
+-- an ugly hack to do conditional compilation without CPP. It depends on the
+-- @RecordWildCards@ and @Typeable@ extensions and abuses shaddowing of
+-- existing symbols.
--
--- It will break if the number of record fields changes. If that's the case we will probably
--- have to either
+-- Alternative methods would include:
--
--- * 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.
+-- * 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.
+
+-- Return license files of from the @PackageDescription@.
--
getLicenseFiles :: PackageDescription -> [FilePath]
-getLicenseFiles (PackageDescription _ _ l _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) =
- fromMaybe (error "unsupported Cabal library version") $ cast l <|> (return <$> cast l)
+getLicenseFiles pkgDesc = f pkgDesc
+ where
+ -- Recent versions of @PackageDescription@ define a @licenseFiles@ field.
+ -- For older versions the function @licenseFiles@ that is defined below is
+ -- used.
+ --
+ f PackageDescription{..} = licenseFiles
+
+ -- If @PackageDescription@ doesn't define @licenseFiles@ this definition
+ -- will be used. In that case @PackageDescription@ is assumed to define
+ -- @licenseFile@.
+ --
+ licenseFiles :: [FilePath]
+ licenseFiles = fromMaybe (error "unsupported Cabal library version") $
+ return <$> cast (g pkgDesc)
+
+ g PackageDescription{..} = licenseFile
+
+ -- The only purpose of this function is to ensure that licenseFile is
+ -- defined in case PackageDescription doesn't have a @licenseFile@ field.
+ -- This function won't be called with any supported version of the Cabal
+ -- library.
+ --
+ licenseFile :: [FilePath]
+ licenseFile = error "unexpected Cabal library version"
#endif
hgInfo :: IO (String, String, String)