Skip to content
This repository has been archived by the owner on Mar 4, 2023. It is now read-only.

Commit

Permalink
Make sure Cabal configures with the correct version of GHC.
Browse files Browse the repository at this point in the history
  • Loading branch information
nominolo committed May 9, 2011
1 parent 1f4be85 commit 14df18b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Scion/Worker/Main.hs
Expand Up @@ -16,12 +16,13 @@ import Scion.Ghc
import qualified GHC as Ghc
import qualified HscTypes as Ghc
import DynFlags as Ghc
import GHC.Paths ( libdir )
import GHC.Paths ( libdir, ghc, ghc_pkg )
import qualified ErrUtils as Ghc
import Outputable ( ppr, showSDoc, withPprStyle, SDoc )
import qualified Outputable as O
import Exception ( gcatch )

import qualified Distribution.Compiler as C
import qualified Distribution.Simple.Configure as C
import qualified Distribution.PackageDescription as C
import qualified Distribution.PackageDescription.Parse as C
Expand Down Expand Up @@ -316,6 +317,7 @@ maybeConfigureCabal cabal_file config_flags odir = do
is_old <- checkPersistBuildConfigOutdated odir cabal_file
if is_old then conf else do
t <- getModificationTime (C.localBuildInfoFile odir)
debugMsg "Project already configured"
return (lbi, t)
where
conf = configureCabal cabal_file config_flags odir
Expand Down Expand Up @@ -352,17 +354,29 @@ configureCabal cabal_file0 config_flags odir = do
-- .cabal file
setCurrentDirectory (dropFileName cabal_file)

debugMsg $ "Configuring Cabal project: " ++ show cabal_file

-- 3. Convince Cabal to parse a @configure ...stuff..@ command line.
gen_pkg_descr <- C.readPackageDescription C.normal cabal_file
cf0 <- case C.commandsRun confCmd commands config_flags of
C.CommandReadyToGo (flags_, _args) -> return flags_
-- TODO: Better error messages.
_ -> throwIO $ userError "Could not parse config flags."

--debugMsg $ "GHC: " ++ show ghc ++ " " ++ show ghc_pkg

-- 4. Now we do Cabal's configuration step.
-- TODO: We should probably specify the version of GHC more tightly.
let conf_flags =
cf0{ C.configDistPref = C.toFlag odir }
cf0{ C.configDistPref = C.toFlag odir,
-- Make sure we use the exact same GHC version that we
-- linked against
C.configHcPath = C.toFlag ghc,
C.configHcPkg = C.toFlag ghc_pkg,
C.configHcFlavor = C.toFlag C.GHC
}
debugMsg $ "ConfigFlags: " ++ show conf_flags

lcl_build_info <- C.configure (gen_pkg_descr, C.emptyHookedBuildInfo)
conf_flags

Expand Down

0 comments on commit 14df18b

Please sign in to comment.