From 69ce5fea57d58e221598b375817cf8eadab1f21c Mon Sep 17 00:00:00 2001 From: Luite Stegeman Date: Tue, 3 Apr 2012 20:26:20 +0200 Subject: [PATCH] make it work with GHC 7.0 --- yesod/Devel.hs | 8 ++++++-- yesod/GhcBuild.hs | 16 ++++++++++++++++ yesod/yesod.cabal | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/yesod/Devel.hs b/yesod/Devel.hs index ad4c967f..36c35b01 100644 --- a/yesod/Devel.hs +++ b/yesod/Devel.hs @@ -71,6 +71,7 @@ devel isCabalDev passThroughArgs = do diffArgs | isCabalDev = [ "--cabal-install-arg=--with-compiler=yesod-ghc-wrapper" + , "--cabal-install-arg=--with-hc-pkg=ghc-pkg" , "--cabal-install-arg=--with-ld=yesod-ld-wrapper" , "--cabal-install-arg=--with-ar=yesod-ar-wrapper" , "--cabal-install-arg=-fdevel" -- legacy @@ -78,6 +79,7 @@ devel isCabalDev passThroughArgs = do ] | otherwise = [ "--with-compiler=yesod-ghc-wrapper" + , "--with-hc-pkg=ghc-pkg" , "--with-ld=yesod-ld-wrapper" , "--with-ar=yesod-ar-wrapper" , "-fdevel" -- legacy @@ -120,8 +122,10 @@ mkRebuild ghcVer cabalFile cabalCmd | GHC.cProjectVersion == ghcVer = do bf <- getBuildFlags return $ do - n <- cabalFile `isNewerThan` "dist/ghcargs.txt" - if n + n1 <- cabalFile `isNewerThan` "dist/ghcargs.txt" + n2 <- cabalFile `isNewerThan` "dist/arargs.txt" + n3 <- cabalFile `isNewerThan` "dist/ldargs.txt" + if n1 || n2 || n3 then rebuildCabal cabalCmd else rebuildGhc bf | otherwise = return $ do diff --git a/yesod/GhcBuild.hs b/yesod/GhcBuild.hs index aaa71362..76bb6c67 100644 --- a/yesod/GhcBuild.hs +++ b/yesod/GhcBuild.hs @@ -26,6 +26,7 @@ import Data.Char (toLower) import Data.Maybe (fromMaybe) import Panic (panic, ghcError) import Data.List (partition, isPrefixOf) +import qualified DynFlags getBuildFlags :: IO [Located String] getBuildFlags = do @@ -60,12 +61,20 @@ buildPackage' argv2 = do haskellish (f,Nothing) = looksLikeModuleName f || isHaskellSrcFilename f || '.' `notElem` f haskellish (_,Just phase) = +#if MIN_VERSION_ghc(7,4,0) phase `notElem` [As, Cc, Cobjc, Cobjcpp, CmmCpp, Cmm, StopLn] +#else + phase `notElem` [As, Cc, CmmCpp, Cmm, StopLn] +#endif hsc_env <- GHC.getSession -- if (null hs_srcs) -- then liftIO (oneShot hsc_env StopLn srcs) -- else do +#if MIN_VERSION_ghc(7,2,0) o_files <- mapM (\x -> liftIO $ compileFile hsc_env StopLn x) +#else + o_files <- mapM (\x -> compileFile hsc_env StopLn x) +#endif non_hs_srcs liftIO $ mapM_ (consIORef v_Ld_inputs) (reverse o_files) targets <- mapM (uncurry GHC.guessTarget) hs_srcs @@ -290,7 +299,14 @@ showInfoMode = mkPreLoadMode ShowInfo printSetting :: String -> Mode printSetting k = mkPreLoadMode (PrintWithDynFlags f) where f dflags = fromMaybe (panic ("Setting not found: " ++ show k)) +#if MIN_VERSION_ghc(7,2,0) $ lookup k (compilerInfo dflags) +#else + $ fmap convertPrintable (lookup k compilerInfo) + where + convertPrintable (DynFlags.String s) = s + convertPrintable (DynFlags.FromDynFlags f) = f dflags +#endif mkPreLoadMode :: PreLoadMode -> Mode mkPreLoadMode = Right . Left diff --git a/yesod/yesod.cabal b/yesod/yesod.cabal index ca56929b..eafd655e 100644 --- a/yesod/yesod.cabal +++ b/yesod/yesod.cabal @@ -130,7 +130,7 @@ executable yesod , filepath >= 1.1 , fast-logger >= 0.0.2 && < 0.1 , process - , ghc >= 7.4.1 + , ghc >= 7.0.3 , ghc-paths >= 0.1.0.8 ghc-options: -Wall if flag(threaded)