From 9baadd471c0a918398df71d44e0f85b4c316fc67 Mon Sep 17 00:00:00 2001 From: Nicolas Dudebout Date: Fri, 18 Jan 2013 16:16:32 -0500 Subject: [PATCH 1/5] Removes two trailing empty lines. --- yesod/ghcwrapper.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/yesod/ghcwrapper.hs b/yesod/ghcwrapper.hs index bd0488cc..ef5e1f27 100644 --- a/yesod/ghcwrapper.hs +++ b/yesod/ghcwrapper.hs @@ -58,5 +58,3 @@ main = do when e $ writeFile outFile (show args ++ "\n") ex <- runProgram cmd args exitWith ex - - From 373ff896b30c34804f5389099cb27ae1528d59b6 Mon Sep 17 00:00:00 2001 From: Nicolas Dudebout Date: Fri, 18 Jan 2013 16:18:51 -0500 Subject: [PATCH 2/5] Detects when hsenv is activated and read the necessary GHC flags. --- yesod/GhcBuild.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/yesod/GhcBuild.hs b/yesod/GhcBuild.hs index 712999f7..439e6bcf 100644 --- a/yesod/GhcBuild.hs +++ b/yesod/GhcBuild.hs @@ -22,6 +22,7 @@ import qualified Control.Exception as Ex import Control.Monad (when) import Data.IORef import System.Process (rawSystem) +import System.Environment (getEnvironment) import CmdLineParser import Data.Char (toLower) @@ -53,7 +54,8 @@ import Util (consIORef, looksLikeModuleName) getBuildFlags :: IO [Located String] getBuildFlags = do argv0 <- fmap read $ readFile "yesod-devel/ghcargs.txt" -- generated by yesod-ghc-wrapper - let (minusB_args, argv1) = partition ("-B" `isPrefixOf`) argv0 + argv0' <- addHsenvArgs argv0 + let (minusB_args, argv1) = partition ("-B" `isPrefixOf`) argv0' mbMinusB | null minusB_args = Nothing | otherwise = Just (drop 2 (last minusB_args)) let argv1' = map (mkGeneralLocated "on the commandline") argv1 @@ -61,6 +63,14 @@ getBuildFlags = do (argv2, staticFlagWarnings) <- GHC.parseStaticFlags argv1' return argv2 +addHsenvArgs :: [String] -> IO [String] +addHsenvArgs argv = do + env <- getEnvironment + return $ case (lookup "HSENV" env) of + Nothing -> argv + _ -> argv ++ hsenvArgv + where hsenvArgv = words $ fromMaybe "" (lookup "PACKAGE_DB_FOR_GHC" env) + buildPackage :: [Located String] -> FilePath -> FilePath -> IO Bool buildPackage a ld ar = buildPackage' a ld ar `Ex.catch` \e -> do putStrLn ("exception building package: " ++ show (e :: Ex.SomeException)) From a42ddb564c05fc62d6154c7588fd530512d4ebed Mon Sep 17 00:00:00 2001 From: Nicolas Dudebout Date: Fri, 18 Jan 2013 16:19:00 -0500 Subject: [PATCH 3/5] Removes a trailing empty line. --- yesod/GhcBuild.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/yesod/GhcBuild.hs b/yesod/GhcBuild.hs index 439e6bcf..4b326076 100644 --- a/yesod/GhcBuild.hs +++ b/yesod/GhcBuild.hs @@ -426,4 +426,3 @@ isCompManagerMode DoMake = True isCompManagerMode DoInteractive = True isCompManagerMode (DoEval _) = True isCompManagerMode _ = False - From e056d5169cb878c7497008862f6c0e8c5cb7b297 Mon Sep 17 00:00:00 2001 From: Nicolas Dudebout Date: Fri, 18 Jan 2013 16:19:23 -0500 Subject: [PATCH 4/5] Aligns the import statements to reflect new length. --- yesod/GhcBuild.hs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/yesod/GhcBuild.hs b/yesod/GhcBuild.hs index 4b326076..411b3d07 100644 --- a/yesod/GhcBuild.hs +++ b/yesod/GhcBuild.hs @@ -19,30 +19,30 @@ module GhcBuild (getBuildFlags, buildPackage) where import qualified Control.Exception as Ex -import Control.Monad (when) +import Control.Monad (when) import Data.IORef -import System.Process (rawSystem) +import System.Process (rawSystem) import System.Environment (getEnvironment) import CmdLineParser -import Data.Char (toLower) -import Data.List (isPrefixOf, partition) -import Data.Maybe (fromMaybe) -import DriverPhases (Phase (..), anyHsc, isHaskellSrcFilename, - isSourceFilename, startPhase) -import DriverPipeline (compileFile, link, linkBinary, oneShot) -import DynFlags (DynFlags, compilerInfo) +import Data.Char (toLower) +import Data.List (isPrefixOf, partition) +import Data.Maybe (fromMaybe) +import DriverPhases (Phase (..), anyHsc, isHaskellSrcFilename, + isSourceFilename, startPhase) +import DriverPipeline (compileFile, link, linkBinary, oneShot) +import DynFlags (DynFlags, compilerInfo) import qualified DynFlags import qualified GHC -import GHC.Paths (libdir) -import HscTypes (HscEnv (..), emptyHomePackageTable) -import MonadUtils (liftIO) -import Panic (ghcError, panic) -import SrcLoc (Located, mkGeneralLocated) -import StaticFlags (v_Ld_inputs) +import GHC.Paths (libdir) +import HscTypes (HscEnv (..), emptyHomePackageTable) +import MonadUtils (liftIO) +import Panic (ghcError, panic) +import SrcLoc (Located, mkGeneralLocated) +import StaticFlags (v_Ld_inputs) import qualified StaticFlags -import System.FilePath (normalise, ()) -import Util (consIORef, looksLikeModuleName) +import System.FilePath (normalise, ()) +import Util (consIORef, looksLikeModuleName) {- This contains a huge hack: From 34474f9844179642f2a918000cea18080a2d0891 Mon Sep 17 00:00:00 2001 From: Nicolas Dudebout Date: Mon, 21 Jan 2013 10:50:07 -0500 Subject: [PATCH 5/5] Prepends the hsenv arguments instead of appending them. --- yesod/GhcBuild.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yesod/GhcBuild.hs b/yesod/GhcBuild.hs index 411b3d07..be4fecf7 100644 --- a/yesod/GhcBuild.hs +++ b/yesod/GhcBuild.hs @@ -54,7 +54,7 @@ import Util (consIORef, looksLikeModuleName) getBuildFlags :: IO [Located String] getBuildFlags = do argv0 <- fmap read $ readFile "yesod-devel/ghcargs.txt" -- generated by yesod-ghc-wrapper - argv0' <- addHsenvArgs argv0 + argv0' <- prependHsenvArgv argv0 let (minusB_args, argv1) = partition ("-B" `isPrefixOf`) argv0' mbMinusB | null minusB_args = Nothing | otherwise = Just (drop 2 (last minusB_args)) @@ -63,12 +63,12 @@ getBuildFlags = do (argv2, staticFlagWarnings) <- GHC.parseStaticFlags argv1' return argv2 -addHsenvArgs :: [String] -> IO [String] -addHsenvArgs argv = do +prependHsenvArgv :: [String] -> IO [String] +prependHsenvArgv argv = do env <- getEnvironment return $ case (lookup "HSENV" env) of Nothing -> argv - _ -> argv ++ hsenvArgv + _ -> hsenvArgv ++ argv where hsenvArgv = words $ fromMaybe "" (lookup "PACKAGE_DB_FOR_GHC" env) buildPackage :: [Located String] -> FilePath -> FilePath -> IO Bool