Skip to content

Loading…

Changes for Cabal > 1.10 #11

Merged
merged 4 commits into from

2 participants

@serras

In the last days I've tried to compile "scion" in Cabal 1.11 (the development version). That needed some changes, which I did, so I think it's helpful to have it already in the main repo.
I've also corrected a bug regarding test suites that I introduced in the last pull request.

@JPMoresmau JPMoresmau merged commit b98dfda into JPMoresmau:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 25, 2011
  1. @serras
Commits on Jul 31, 2011
  1. @serras
  2. @serras
  3. @serras

    Ammend previous commit.

    serras committed
Showing with 109 additions and 57 deletions.
  1. +34 −15 lib/Scion/Cabal.hs
  2. +5 −0 lib/Scion/Types.hs
  3. +70 −42 scion.cabal
View
49 lib/Scion/Cabal.hs
@@ -37,17 +37,23 @@ import Data.Maybe
import qualified Data.Map as DM
import System.Directory ( doesFileExist, getDirectoryContents,
getModificationTime, removeFile )
-import System.FilePath ( (</>), dropFileName, takeExtension,dropExtension,(<.>) )
+import System.FilePath ( (</>), dropFileName, takeExtension, dropExtension, (<.>) )
import System.Exit ( ExitCode(..) )
import qualified Distribution.ModuleName as PD
( ModuleName, components )
-- FIXME: unused import Distribution.Simple.Configure
import Distribution.Simple.GHC ( ghcOptions )
+#if CABAL_VERSION > 110
+import Distribution.Simple.LocalBuildInfo hiding ( libdir, Component(..) )
+#else
import Distribution.Simple.LocalBuildInfo hiding ( libdir )
+#endif
import Distribution.Simple.Build ( initialBuildSteps )
import Distribution.Simple.BuildPaths ( exeExtension )
+#if CABAL_VERSION < 112
import Distribution.Simple.PreProcess ( knownSuffixHandlers )
+#endif
import qualified Distribution.PackageDescription as PD
import Distribution.Package
import Distribution.InstalledPackageInfo
@@ -252,7 +258,7 @@ cabalDynFlags component = do
lbi <- cabal_build_info (cabalFile component)
bi <- component_build_info component (localPkgDescr lbi)
let odir0 = buildDir lbi
- let odir
+ let odir
| Executable {exe_name=exeName'} <- component
= odir0 </> dropExtension exeName'
#if CABAL_VERSION > 108
@@ -277,7 +283,8 @@ cabalDynFlags component = do
= fromJustD "library" $ libraryConfig lbi
let opts = ghcOptions lbi bi clbi odir
#endif
- return $ opts ++ output_file_opts odir
+ o_file_opts <- output_file_opts odir
+ return $ opts ++ o_file_opts
where
component_build_info Library{} pd
| Just lib <- PD.library pd = return (PD.libBuildInfo lib)
@@ -299,18 +306,23 @@ cabalDynFlags component = do
output_file_opts odir =
case component of
Executable{exe_name=exeName'} ->
- ["-o", odir </> exeName' <.>
- (if null $ takeExtension exeName'
- then exeExtension
- else "")]
+ return ["-o", odir </> exeName' <.> (if null $ takeExtension exeName'
+ then exeExtension
+ else "")]
#if CABAL_VERSION > 108
- TestSuite{test_name=test_name'} ->
- ["-o", odir </> test_name' <.>
- (if null $ takeExtension test_name'
- then exeExtension
- else "")]
+ TestSuite{test_name=test_name',cabalFile=f} -> do
+ pd <- cabal_package f
+ let ex0 = filter ((test_name' ==) . PD.testName) (PD.testSuites pd)
+ case ex0 of
+ [ts] -> case PD.testInterface ts of
+ PD.TestSuiteExeV10 _ _ -> return ["-o", odir </> test_name' <.>
+ (if null $ takeExtension test_name'
+ then exeExtension
+ else "")]
+ _ -> return []
+ _ -> error "Zero or more than one testsuites with the same name"
#endif
- _ -> []
+ _ -> return []
fromJustD :: [Char] -> Maybe a -> a
fromJustD msg Nothing=error msg
@@ -466,7 +478,11 @@ preprocessPackage :: FilePath
preprocessPackage dist_dir = do
lbi <- liftIO $ getPersistBuildConfig (localBuildInfoFile dist_dir)
let pd = localPkgDescr lbi
+#if CABAL_VERSION > 110
+ liftIO $ initialBuildSteps dist_dir pd lbi V.normal
+#else
liftIO $ initialBuildSteps dist_dir pd lbi V.normal knownSuffixHandlers
+#endif
return ()
cabalModuleNameToTarget :: PD.ModuleName -> Target
@@ -511,7 +527,7 @@ configureCabalProject root_dir dist_dir = do
{ configDistPref = Flag dist_dir
, configVerbosity = Flag V.deafening
, configUserInstall = Flag True
-#if CABAL_VERSION > 108
+#if CABAL_VERSION > 108
, configTests = Flag True
#endif
, configConfigurationsFlags = map (\(n,v)->(PD.FlagName n,v)) user_flags
@@ -529,8 +545,11 @@ configureCabalProject root_dir dist_dir = do
config_flags
#endif
liftIO $ writePersistBuildConfig dist_dir lbi
+#if CABAL_VERSION > 110
liftIO $ initialBuildSteps dist_dir (localPkgDescr lbi) lbi V.normal
- knownSuffixHandlers
+#else
+ liftIO $ initialBuildSteps dist_dir (localPkgDescr lbi) lbi V.normal knownSuffixHandlers
+#endif
return lbi
where
find_cabal_file = do
View
5 lib/Scion/Types.hs
@@ -37,7 +37,12 @@ import qualified Data.MultiSet as MS
import qualified Data.Set as Set
import qualified Data.Foldable as Fold
+#if CABAL_VERSION > 110
+import Distribution.Simple.LocalBuildInfo hiding ( Component(..) )
+#else
import Distribution.Simple.LocalBuildInfo
+#endif
+
import System.Directory
( setCurrentDirectory
, getCurrentDirectory
View
112 scion.cabal
@@ -44,6 +44,10 @@ flag cabal_1_10
description: Enable the Cabal library 1.10 features
default: False
+flag cabal_1_12
+ description: Enable the Cabal library 1.12 features
+ default: False
+
library
build-depends:
base == 4.*,
@@ -76,22 +80,28 @@ library
ghc-syb,
ghc-syb-utils,
time == 1.1.*
-
- if flag(cabal_1_10)
+
+ if flag(cabal_1_12)
build-depends:
- Cabal >= 1.10,
- hslogger >= 1.1
- cpp-options: -DCABAL_VERSION=110
+ Cabal >= 1.11,
+ hslogger >= 1.1
+ cpp-options: -DCABAL_VERSION=112
else
- if flag(cabal_1_8)
+ if flag(cabal_1_10)
build-depends:
- Cabal >= 1.8,
+ Cabal >= 1.10,
hslogger >= 1.1
- cpp-options: -DCABAL_VERSION=108
+ cpp-options: -DCABAL_VERSION=110
else
- build-depends:
- Cabal == 1.6.*
- cpp-options: -DCABAL_VERSION=106
+ if flag(cabal_1_8)
+ build-depends:
+ Cabal >= 1.8,
+ hslogger >= 1.1
+ cpp-options: -DCABAL_VERSION=108
+ else
+ build-depends:
+ Cabal == 1.6.*
+ cpp-options: -DCABAL_VERSION=106
hs-source-dirs: lib
extensions: CPP, PatternGuards, DeriveDataTypeable
@@ -174,21 +184,27 @@ executable scion-server
ghc-syb-utils,
time == 1.1.*
- if flag(cabal_1_10)
+ if flag(cabal_1_12)
build-depends:
- Cabal >= 1.10,
- hslogger >= 1.1
- cpp-options: -DCABAL_VERSION=110
+ Cabal >= 1.11,
+ hslogger >= 1.1
+ cpp-options: -DCABAL_VERSION=112
else
- if flag(cabal_1_8)
+ if flag(cabal_1_10)
build-depends:
- Cabal >= 1.8,
- hslogger >= 1.1
- cpp-options: -DCABAL_VERSION=108
+ Cabal >= 1.10,
+ hslogger >= 1.1
+ cpp-options: -DCABAL_VERSION=110
else
- build-depends:
- Cabal == 1.6.*
- cpp-options: -DCABAL_VERSION=106
+ if flag(cabal_1_8)
+ build-depends:
+ Cabal >= 1.8,
+ hslogger >= 1.1
+ cpp-options: -DCABAL_VERSION=108
+ else
+ build-depends:
+ Cabal == 1.6.*
+ cpp-options: -DCABAL_VERSION=106
if flag(server)
@@ -283,21 +299,27 @@ executable scion-test
ghc-syb-utils,
time == 1.1.*
- if flag(cabal_1_10)
+ if flag(cabal_1_12)
build-depends:
- Cabal >= 1.10,
- hslogger >= 1.1
- cpp-options: -DCABAL_VERSION=110
+ Cabal >= 1.11,
+ hslogger >= 1.1
+ cpp-options: -DCABAL_VERSION=112
else
- if flag(cabal_1_8)
+ if flag(cabal_1_10)
build-depends:
- Cabal >= 1.8,
+ Cabal >= 1.10,
hslogger >= 1.1
- cpp-options: -DCABAL_VERSION=108
+ cpp-options: -DCABAL_VERSION=110
else
- build-depends:
- Cabal == 1.6.*
- cpp-options: -DCABAL_VERSION=106
+ if flag(cabal_1_8)
+ build-depends:
+ Cabal >= 1.8,
+ hslogger >= 1.1
+ cpp-options: -DCABAL_VERSION=108
+ else
+ build-depends:
+ Cabal == 1.6.*
+ cpp-options: -DCABAL_VERSION=106
hs-source-dirs: lib
extensions: CPP, PatternGuards, DeriveDataTypeable
@@ -361,21 +383,27 @@ executable STypeNotes-test
filepath == 1.1.*,
ghc >= 6.10 && < 6.13
- if flag(cabal_1_10)
+ if flag(cabal_1_12)
build-depends:
- Cabal >= 1.10,
- hslogger >= 1.1
- cpp-options: -DCABAL_VERSION=110
+ Cabal >= 1.11,
+ hslogger >= 1.1
+ cpp-options: -DCABAL_VERSION=112
else
- if flag(cabal_1_8)
+ if flag(cabal_1_10)
build-depends:
- Cabal >= 1.8,
+ Cabal >= 1.10,
hslogger >= 1.1
- cpp-options: -DCABAL_VERSION=108
+ cpp-options: -DCABAL_VERSION=110
else
- build-depends:
- Cabal == 1.6.*
- cpp-options: -DCABAL_VERSION=106
+ if flag(cabal_1_8)
+ build-depends:
+ Cabal >= 1.8,
+ hslogger >= 1.1
+ cpp-options: -DCABAL_VERSION=108
+ else
+ build-depends:
+ Cabal == 1.6.*
+ cpp-options: -DCABAL_VERSION=106
hs-source-dirs: lib
extensions: CPP, PatternGuards
Something went wrong with that request. Please try again.