X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Fcompiler%2Fmain%2FDriverMkDepend.hs;h=80d906c4a7c0e8b0c91ca2e94029238f877658aa;hb=9d7da331989abcd1844e9d03b8d1e4163796fa85;hp=36990cbdc97ee109ce5c723263afb794651a8d46;hpb=8d6afe743a98a77c08f917438d012d95857c278d;p=ghc-hetmet.git diff --git a/ghc/compiler/main/DriverMkDepend.hs b/ghc/compiler/main/DriverMkDepend.hs index 36990cb..80d906c 100644 --- a/ghc/compiler/main/DriverMkDepend.hs +++ b/ghc/compiler/main/DriverMkDepend.hs @@ -20,7 +20,7 @@ import HscTypes ( HscEnv, IsBootInterface, msObjFilePath, msHsFilePath ) import Packages ( PackageIdH(..) ) import SysTools ( newTempName ) import qualified SysTools -import Module ( Module, ModLocation(..), mkModule, moduleUserString, +import Module ( Module, ModLocation(..), mkModule, addBootSuffix_maybe ) import Digraph ( SCC(..) ) import Finder ( findModule, FindResult(..) ) @@ -30,19 +30,20 @@ import Panic import SrcLoc ( unLoc ) import CmdLineParser +#if __GLASGOW_HASKELL__ <= 408 +import Panic ( catchJust, ioErrors ) +#endif +import ErrUtils ( debugTraceMsg, printErrorsAndWarnings ) + import DATA_IOREF ( IORef, readIORef, writeIORef ) import EXCEPTION +import System ( ExitCode(..), exitWith ) import Directory import IO import Monad ( when ) import Maybe ( isJust ) -#if __GLASGOW_HASKELL__ <= 408 -import Panic ( catchJust, ioErrors ) -#endif -import ErrUtils ( debugTraceMsg ) - ----------------------------------------------------------------- -- -- The main function @@ -59,22 +60,24 @@ doMkDependHS session srcs ; targets <- mapM (\s -> GHC.guessTarget s Nothing) srcs ; GHC.setTargets session targets ; excl_mods <- readIORef v_Dep_exclude_mods - ; GHC.depanal session excl_mods - ; mod_summaries <- GHC.getModuleGraph session + ; r <- GHC.depanal session excl_mods True {- Allow dup roots -} + ; case r of + Nothing -> exitWith (ExitFailure 1) + Just mod_summaries -> do { -- Sort into dependency order -- There should be no cycles - ; let sorted = GHC.topSortModuleGraph False mod_summaries Nothing + let sorted = GHC.topSortModuleGraph False mod_summaries Nothing -- Print out the dependencies if wanted - ; debugTraceMsg dflags 2 (showSDoc (text "Module dependencies" $$ ppr sorted)) - + ; debugTraceMsg dflags 2 (text "Module dependencies" $$ ppr sorted) + -- Prcess them one by one, dumping results into makefile -- and complaining about cycles - ; mapM (processDeps session (mkd_tmp_hdl files)) sorted + ; mapM (processDeps session excl_mods (mkd_tmp_hdl files)) sorted -- Tidy up - ; endMkDependHS dflags files } + ; endMkDependHS dflags files }} ----------------------------------------------------------------- -- @@ -150,6 +153,7 @@ beginMkDependHS dflags = do ----------------------------------------------------------------- processDeps :: Session + -> [Module] -> Handle -- Write dependencies to here -> SCC ModSummary -> IO () @@ -168,11 +172,11 @@ processDeps :: Session -- -- For {-# SOURCE #-} imports the "hi" will be "hi-boot". -processDeps session hdl (CyclicSCC nodes) +processDeps session excl_mods hdl (CyclicSCC nodes) = -- There shouldn't be any cycles; report them throwDyn (ProgramError (showSDoc $ GHC.cyclicModuleErr nodes)) -processDeps session hdl (AcyclicSCC node) +processDeps session excl_mods hdl (AcyclicSCC node) = do { extra_suffixes <- readIORef v_Dep_suffixes ; hsc_env <- GHC.sessionHscEnv session ; include_pkg_deps <- readIORef v_Dep_include_pkg_deps @@ -200,8 +204,14 @@ processDeps session hdl (AcyclicSCC node) ; writeDependency hdl obj_files src_file -- Emit a dependency for each import - ; mapM_ (do_imp True . unLoc) (ms_srcimps node) -- SOURCE imports - ; mapM_ (do_imp False . unLoc) (ms_imps node) -- regular imports + + -- SOURCE imports + ; mapM_ (do_imp True) + (filter (`notElem` excl_mods) (map unLoc (ms_srcimps node))) + + -- regular imports + ; mapM_ (do_imp False) + (filter (`notElem` excl_mods) (map unLoc (ms_imps node))) }