Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a ghc-pkg command, and fix the cabal file to specify the version …

…of containers more precisely to make the build work with more versions of GHC
  • Loading branch information...
commit 0bd810dc004c9d7efd034cbe0e7870174502eec9 1 parent 057798a
Josh Hoyt authored
Showing with 68 additions and 2 deletions.
  1. +17 −1 cabal-dev.cabal
  2. +42 −0 src/Distribution/Dev/GhcPkg.hs
  3. +9 −1 src/Main.hs
View
18 cabal-dev.cabal
@@ -39,6 +39,7 @@ Cabal-version: >=1.6
Data-Files:
admin/cabal-config.in,
admin/00-index.tar
+Tested-with: ghc == 6.12.3, ghc == 6.10.4, ghc == 7.0.3
source-repository head
type: git
@@ -73,9 +74,24 @@ Executable cabal-dev
Build-depends:
base >= 3 && < 4
+ -- Containers 0.2 did not specify a constraint on base, so we
+ -- avoid using it:
+ if impl(ghc >= 6.12)
+ Build-depends:
+ containers >= 0.3 && < 0.5
+
+ -- Require this specific version that came with GHC 6.10 because
+ -- of packaging problems with containers-0.2
+ if impl(ghc == 6.10)
+ Build-depends:
+ containers == 0.2.0.1
+
+ if impl(ghc == 6.8)
+ Build-depends:
+ containers == 0.1.0.2
+
Build-depends:
bytestring >= 0.9 && < 0.10,
- containers == 0.2.*,
directory >= 1.0 && < 1.3,
filepath >= 1.1 && < 1.3,
Cabal >= 1.10.0.0 && < 1.11,
View
42 src/Distribution/Dev/GhcPkg.hs
@@ -0,0 +1,42 @@
+{-|
+
+Invoke ghc-pkg with the appropriate arguments to run in the cabal-dev
+sandbox.
+
+-}
+module Distribution.Dev.GhcPkg
+ ( actions
+ )
+where
+
+import Distribution.Dev.Command ( CommandActions(..), CommandResult(..) )
+import System.Console.GetOpt ( OptDescr )
+import Distribution.Dev.Flags ( Config, getVerbosity )
+import Distribution.Dev.InitPkgDb ( initPkgDb )
+import Distribution.Dev.Sandbox ( resolveSandbox, getVersion
+ , PackageDbType(..), pkgConf )
+import Distribution.Simple.Program ( emptyProgramConfiguration
+ , requireProgram
+ , runProgram
+ , ghcPkgProgram
+ )
+
+actions :: CommandActions
+actions = CommandActions
+ { cmdDesc = "Invoke ghc-pkg on the package database in"
+ , cmdRun = \cfg _ args -> invokeGhcPkg cfg args
+ , cmdOpts = [] :: [OptDescr ()]
+ , cmdPassFlags = True
+ }
+
+invokeGhcPkg :: Config -> [String] -> IO CommandResult
+invokeGhcPkg cfg args = do
+ let v = getVerbosity cfg
+ s <- initPkgDb v =<< resolveSandbox cfg
+ (ghcPkg, _) <- requireProgram v ghcPkgProgram emptyProgramConfiguration
+ let extraArgs = case getVersion s of
+ GHC_6_8_Db _ -> id
+ _ -> ("--no-user-package-conf":)
+
+ runProgram v ghcPkg $ extraArgs $ "--package-conf" : pkgConf s : args
+ return CommandOk
View
10 src/Main.hs
@@ -25,6 +25,7 @@ import qualified Distribution.Dev.Ghci as Ghci
import qualified Distribution.Dev.InvokeCabal as InvokeCabal
import qualified Distribution.Dev.InstallDependencies as InstallDeps
import qualified Distribution.Dev.BuildOpts as BuildOpts
+import qualified Distribution.Dev.GhcPkg as GhcPkg
import qualified Distribution.Dev.CabalInstall as CI
import Paths_cabal_dev ( version )
@@ -59,6 +60,12 @@ cabalDevCommands = [ ( "add-source"
, "Extract the options that would be passed to the " ++
"compiler when building"
)
+ , ( "ghc-pkg"
+ , GhcPkg.actions
+ , "Invoke ghc-pkg including the appropriate " ++
+ "--package-conf argument to run on the sandbox's " ++
+ "package database."
+ )
]
cabalInstallCommands :: [(String, CommandActions)]
@@ -124,7 +131,8 @@ main = do
globalUsage :: IO String
globalUsage = do
progName <- getProgName
- let fmtCommands cmds = fmtTable " " [ [[""], [n], wrap 60 d] | (n, _, d) <- cmds ]
+ let fmtCommands cmds =
+ fmtTable " " [ [[""], [n], wrap 60 d] | (n, _, d) <- cmds ]
let preamble =
unlines $
[ ""
Please sign in to comment.
Something went wrong with that request. Please try again.