Permalink
Browse files

Using -package-db if GHC >= 7.6.

  • Loading branch information...
1 parent 3207744 commit 259c12e30eb6269ca5191543b300087f7c2ffdd7 @kazu-yamamoto committed Feb 18, 2013
Showing with 26 additions and 2 deletions.
  1. +7 −2 Commands.hs
  2. +18 −0 GHCVer.hs
  3. +1 −0 cab.cabal
View
@@ -9,6 +9,7 @@ import Data.Char
import Data.List
import Data.Maybe
import GenPaths
+import GHCVer
import PkgDB
import System.Exit
import System.IO
@@ -94,10 +95,14 @@ unregister doit opts (name,ver) =
pkgConfOpt :: [Option] -> IO String
pkgConfOpt opts = case getSandbox opts of
- Nothing -> return ""
+ Nothing -> return ""
Just path -> do
+ ghcver <- ghcVersion
+ print ghcver
pkgConf <- getPackageConf path
- return $ "--package-conf=" ++ pkgConf ++ " "
+ let pkgOpt | ghcver >= 706 = "--package-db="
+ | otherwise = "--package-conf="
+ return $ pkgOpt ++ pkgConf ++ " "
----------------------------------------------------------------
View
@@ -0,0 +1,18 @@
+module GHCVer where
+
+import Control.Applicative
+import Distribution.Simple.Program (ghcProgram)
+import Distribution.Simple.Program.Types (programName, programFindVersion)
+import Distribution.Verbosity (silent)
+import Distribution.Version (versionBranch)
+
+ghcVersion :: IO Int
+ghcVersion = toInt <$> ghcVer
+ where
+ ghcVer = programFindVersion ghcProgram silent (programName ghcProgram)
+ toInt Nothing = 0
+ toInt (Just v)
+ | length vs < 2 = 0
+ | otherwise = (vs !! 0) * 100 + (vs !! 1)
+ where
+ vs = versionBranch v
View
@@ -39,6 +39,7 @@ Executable cab
Commands
Env
GenPaths
+ GHCVer
PkgDB
Program
Types

0 comments on commit 259c12e

Please sign in to comment.