Permalink
Browse files

Merge pull request #72 from elliottt/master

GHC-7.6.1 compatibility on Windows 7, with CPP for backwards compat for previous versions
  • Loading branch information...
2 parents 1a0cadb + a30f34e commit 81fb932bcd6b21a4e02259cf40724facba5a92ee @jtdaugherty jtdaugherty committed Oct 19, 2012
View
@@ -1,2 +1,3 @@
dist/
-cabal-dev/
+cabal-dev/
+*.swp
View
@@ -93,7 +93,7 @@ Executable cabal-dev
-- avoid using it:
if impl(ghc >= 6.12)
Build-depends:
- containers >= 0.3 && < 0.5
+ containers >= 0.3 && < 0.6
-- Require this specific version that came with GHC 6.10 because
-- of packaging problems with containers-0.2
@@ -105,17 +105,20 @@ Executable cabal-dev
Build-depends:
containers == 0.1.0.2
+ if impl(ghc >= 7.6.1)
+ CPP-Options: -DNO_PRELUDE_CATCH
+
Build-depends:
- bytestring >= 0.9 && < 0.10,
+ bytestring >= 0.9 && < 0.11,
directory >= 1.0 && < 1.3,
filepath >= 1.1 && < 1.4,
- Cabal >= 1.10.0.0 && < 1.15,
+ Cabal >= 1.10.0.0 && < 1.17,
HTTP >= 4000.0.9 && < 4000.3,
mtl >= 1.1 && < 2.2,
- network >= 2.2 && < 2.4,
+ network >= 2.2 && < 2.5,
pretty >= 1.0 && < 1.2,
process >= 1.0 && < 1.2,
- tar >= 0.3 && < 0.4,
+ tar >= 0.4 && < 0.5,
zlib >= 0.5 && < 0.6,
transformers >= 0.2 && < 0.4,
@@ -126,7 +129,7 @@ Executable cabal-dev
template-haskell
if os(windows)
- build-depends: Win32 >= 2.1 && < 2.3
+ build-depends: Win32 >= 2.1 && < 2.4
Build-tools:
cabal >= 0.8.2
@@ -154,7 +157,7 @@ Executable ghc-pkg-6_8-compat
Main-is: GhcPkgCompat.hs
Build-Depends:
base < 5,
- Cabal >=1.2 && < 1.15
+ Cabal >=1.2 && < 1.17
GHC-Options: -Wall
HS-Source-Dirs: src
@@ -181,7 +184,7 @@ Executable cabal-dev-test
HUnit >= 1.2 && <2
if os(windows)
- build-depends: Win32 >= 2.1 && < 2.3
+ build-depends: Win32 >= 2.1 && < 2.4
Executable fake-ghc-cabal-dev
@@ -16,6 +16,10 @@ where
#define MIN_VERSION_Cabal(a,b,c) 1
#endif
+#ifdef NO_PRELUDE_CATCH
+import Control.Exception ( catch )
+#endif
+
import Control.Applicative ( (<$>), (<*>) )
import Control.Arrow ( right )
import Control.Exception ( bracket )
@@ -164,7 +168,7 @@ readExistingIndex sandbox =
forceEntries es =
let step _ l@(Left _) = l
step x (Right xs) = Right (x:xs)
- es' = T.foldEntries step (Right []) Left es
+ es' = T.foldEntries step (Right []) (Left . show) es
in either (const 0) length es' `seq` return es'
@@ -344,7 +348,7 @@ forcedBS :: L.ByteString -> IO L.ByteString
forcedBS bs = forceBS bs >> return bs
-- |Extract a cabal file from a package tarball
-extractCabalFile :: T.Entries -> Maybe (PackageIdentifier, L.ByteString, PackageDescription)
+extractCabalFile :: T.Entries T.FormatError -> Maybe (PackageIdentifier, L.ByteString, PackageDescription)
extractCabalFile = T.foldEntries step Nothing (const Nothing)
where
step ent Nothing = (,,) <$> entPackageId ent <*> entBytes ent <*> (parseDesc $ entBytes ent)
@@ -18,9 +18,8 @@ import Distribution.Simple.Program ( Program( programFindLocation )
, runProgram
, simpleProgram
)
-import Distribution.Simple.Utils ( writeUTF8File, debug, cabalVersion
- , readUTF8File )
-import Distribution.ParseUtils ( ParseResult(..), Field, readFields )
+import Distribution.Simple.Utils ( writeUTF8File, debug, cabalVersion)
+import Distribution.ParseUtils ( Field )
import Distribution.Version ( Version(..) )
import System.Console.GetOpt ( OptDescr )
@@ -9,6 +9,8 @@ This module is written so that it will work out-of-the-box with GHC >=
6.8 && < 6.13 with no other packages installed.
-}
+{-# LANGUAGE CPP #-}
+
module Distribution.Dev.RewriteCabalConfig
( rewriteCabalConfig
, Rewrite(..)
@@ -18,6 +20,10 @@ module Distribution.Dev.RewriteCabalConfig
)
where
+#ifdef NO_PRELUDE_CATCH
+import Control.Exception ( catch, IOException )
+#endif
+
import Control.Applicative ( Applicative, pure, (<$>) )
import Data.Maybe ( fromMaybe )
import Data.Traversable ( traverse, Traversable )
@@ -38,8 +44,14 @@ readConfig s = case readFields s of
-- XXX: we should avoid this lazy IO that leaks a file handle.
readConfigF :: FilePath -> IO (Either String [Field])
-readConfigF fn =
- (readConfig <$> readUTF8File fn) `catch` \e -> return $ Left $ show e
+readConfigF fn = (readConfig <$> readUTF8File fn) `catch` handler
+ where
+#ifdef NO_PRELUDE_CATCH
+ handler :: IOException -> IO (Either String [Field])
+ handler = return . Left . show
+#else
+ handler = return . Left . show
+#endif
readConfigF_ :: FilePath -> IO [Field]
readConfigF_ fn = either error id <$> readConfigF fn
@@ -72,8 +84,8 @@ rewriteField expand field =
F l name val -> F l name <$> rewriteLeaf name val
Section l name key fs -> Section l name key <$>
rewriteSection name fs
- _ -> error $ "Only top-level fields and sections \
- \supported. Not: " ++ show field
+ _ -> error $ "Only top-level fields and sections "
+ ++ "supported. Not: " ++ show field
where
rewriteLeaf name val
| name `elem` eLeaves expand = eExpand expand val
@@ -25,6 +25,10 @@ import System.Directory ( createDirectoryIfMissing
, doesFileExist, copyFile )
import System.FilePath ( (</>) )
+#ifdef NO_PRELUDE_CATCH
+import Control.Exception ( catch )
+#endif
+
#ifdef mingw32_HOST_OS
import System.IO ( hPutStrLn, stderr )
import System.Win32.Types ( getLastError )

0 comments on commit 81fb932

Please sign in to comment.