Adapt to changes in Cabal.
authorPaolo Capriotti <p.capriotti@gmail.com>
Mon, 7 May 2012 16:45:00 +0000 (17:45 +0100)
committerPaolo Capriotti <p.capriotti@gmail.com>
Mon, 7 May 2012 22:24:58 +0000 (23:24 +0100)
utils/ghc-cabal/Main.hs
utils/ghctags/Main.hs

index 75d1faf..c24f127 100644 (file)
@@ -19,6 +19,7 @@ import Distribution.Verbosity
 import qualified Distribution.InstalledPackageInfo as Installed
 import qualified Distribution.Simple.PackageIndex as PackageIndex
 
+import Control.Monad
 import Data.List
 import Data.Maybe
 import System.IO
@@ -184,36 +185,20 @@ doInstall ghc ghcpkg strip topdir directory distDir
                             htmldir   = toPathTemplate "$docdir"
                         }
                 progs = withPrograms lbi
-                ghcProg = ConfiguredProgram {
-                              programId = programName ghcProgram,
-                              programVersion = Nothing,
-                              programDefaultArgs = ["-B" ++ topdir],
-                              programOverrideArgs = [],
-                              programLocation = UserSpecified ghc
-                          }
                 ghcpkgconf = topdir </> "package.conf.d"
-                ghcPkgProg = ConfiguredProgram {
-                                 programId = programName ghcPkgProgram,
-                                 programVersion = Nothing,
-                                 programDefaultArgs = ["--global-conf",
-                                                       ghcpkgconf]
-                                               ++ if not (null myDestDir)
-                                                  then ["--force"]
-                                                  else [],
-                                 programOverrideArgs = [],
-                                 programLocation = UserSpecified ghcpkg
-                             }
-                stripProg = ConfiguredProgram {
-                              programId = programName stripProgram,
-                              programVersion = Nothing,
-                              programDefaultArgs = [],
-                              programOverrideArgs = [],
-                              programLocation = UserSpecified strip
-                          }
-                progs' = updateProgram ghcProg
-                       $ updateProgram ghcPkgProg
-                       $ updateProgram stripProg
-                         progs
+                ghcProgram' = ghcProgram {
+                    programPostConf = \_ _ -> return ["-B" ++ topdir],
+                    programFindLocation = \_ -> return (Just ghc) }
+                ghcPkgProgram' = ghcPkgProgram {
+                    programPostConf = \_ _ -> return $ ["--global-conf", ghcpkgconf]
+                                                    ++ ["--force" | not (null myDestDir) ],
+                    programFindLocation = \_ -> return (Just ghcpkg) }
+                stripProgram' = stripProgram {
+                    programFindLocation = \_ -> return (Just strip) }
+                configurePrograms ps conf = foldM (flip (configureProgram verbosity)) conf ps
+
+            progs' <- configurePrograms [ghcProgram', ghcPkgProgram', stripProgram'] progs
+            let Just ghcPkgProg = lookupProgram ghcPkgProgram' progs'
             instInfos <- dump verbosity ghcPkgProg GlobalPackageDB
             let installedPkgs' = PackageIndex.fromList instInfos
             let mlc = libraryConfig lbi
@@ -404,4 +389,3 @@ generate config_args distdir directory
       | otherwise     = return ("\'" ++ s ++ "\'")
      boolToYesNo True = "YES"
      boolToYesNo False = "NO"
-
index ea3300c..f63e039 100644 (file)
@@ -19,10 +19,13 @@ import MonadUtils       ( liftIO )
 import SrcLoc
 
 -- Every GHC comes with Cabal anyways, so this is not a bad new dependency
-import Distribution.Simple.GHC ( ghcOptions )
+import Distribution.Simple.GHC ( componentGhcOptions )
 import Distribution.Simple.Configure ( getPersistBuildConfig )
+import Distribution.Simple.Compiler ( compilerVersion )
+import Distribution.Simple.Program.GHC ( renderGhcOptions )
 import Distribution.PackageDescription ( library, libBuildInfo )
-import Distribution.Simple.LocalBuildInfo ( localPkgDescr, buildDir, libraryConfig )
+import Distribution.Simple.LocalBuildInfo ( localPkgDescr, buildDir, libraryConfig, compiler )
+import qualified Distribution.Verbosity as V
 
 import Control.Monad hiding (mapM)
 import System.Environment
@@ -184,8 +187,9 @@ flagsFromCabal distPref = do
     (Just lib, Just clbi) ->
       let bi = libBuildInfo lib
           odir = buildDir lbi
-          opts = ghcOptions lbi bi clbi odir
-      in return opts
+          opts = componentGhcOptions V.normal lbi bi clbi odir
+          version = compilerVersion (compiler lbi)
+      in return $ renderGhcOptions version opts
     _ -> error "no library"
 
 ----------------------------------------------------------------