X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fmain%2FDriverMkDepend.hs;h=95587cd6c1cb6da086fb2491a3c569ce187f8abb;hp=74ee4dcd1fd841c2ef8f46279b4b2b99bf66e088;hb=d83e1ac43a43dc30c7e4f5b64f7b77e32d31886d;hpb=a896a832ab7306da8c638df7f44619b3548bd518 diff --git a/compiler/main/DriverMkDepend.hs b/compiler/main/DriverMkDepend.hs index 74ee4dc..95587cd 100644 --- a/compiler/main/DriverMkDepend.hs +++ b/compiler/main/DriverMkDepend.hs @@ -1,3 +1,10 @@ +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + ----------------------------------------------------------------------------- -- -- Makefile Dependency Generation @@ -15,7 +22,7 @@ module DriverMkDepend ( import qualified GHC import GHC ( Session, ModSummary(..) ) import DynFlags -import Util ( escapeSpaces, splitFilename, joinFileExt ) +import Util import HscTypes ( HscEnv, IsBootInterface, msObjFilePath, msHsFilePath ) import SysTools ( newTempName ) import qualified SysTools @@ -28,16 +35,15 @@ import Panic import SrcLoc import Data.List import CmdLineParser +import FastString -#if __GLASGOW_HASKELL__ <= 408 -import Panic ( catchJust, ioErrors ) -#endif import ErrUtils ( debugTraceMsg, putMsg ) import Data.IORef ( IORef, readIORef, writeIORef ) import Control.Exception import System.Exit ( ExitCode(..), exitWith ) import System.Directory +import System.FilePath import System.IO import SYSTEM_IO_ERROR ( isEOFError ) import Control.Monad ( when ) @@ -243,10 +249,10 @@ findDependency hsc_env src imp is_boot include_pkg_deps ----------------------------- writeDependency :: Handle -> [FilePath] -> FilePath -> IO () -- (writeDependency h [t1,t2] dep) writes to handle h the dependency --- t1 t2 : dep +-- t1 t2 : dep writeDependency hdl targets dep - = hPutStrLn hdl (unwords (map escapeSpaces targets) ++ " : " - ++ escapeSpaces dep) + = hPutStrLn hdl (unwords (map forOutput targets) ++ " : " ++ forOutput dep) + where forOutput = escapeSpaces . reslash Forwards . normalise ----------------------------- insertSuffixes @@ -268,9 +274,11 @@ insertSuffixes -- Lots of other things will break first! insertSuffixes file_name extras - = file_name : [ basename `joinFileExt` (extra ++ "_" ++ suffix) | extra <- extras ] + = file_name : [ basename <.> (extra ++ "_" ++ suffix) | extra <- extras ] where - (basename, suffix) = splitFilename file_name + (basename, suffix) = case splitExtension file_name of + -- Drop the "." from the extension + (b, s) -> (b, drop 1 s) ----------------------------------------------------------------- @@ -325,16 +333,16 @@ dumpModCycles dflags mod_summaries = return () | null cycles - = putMsg dflags (ptext SLIT("No module cycles")) + = putMsg dflags (ptext (sLit "No module cycles")) | otherwise - = putMsg dflags (hang (ptext SLIT("Module cycles found:")) 2 pp_cycles) + = putMsg dflags (hang (ptext (sLit "Module cycles found:")) 2 pp_cycles) where cycles :: [[ModSummary]] cycles = [ c | CyclicSCC c <- GHC.topSortModuleGraph True mod_summaries Nothing ] - pp_cycles = vcat [ (ptext SLIT("---------- Cycle") <+> int n <+> ptext SLIT("----------")) + pp_cycles = vcat [ (ptext (sLit "---------- Cycle") <+> int n <+> ptext (sLit "----------")) $$ pprCycle c $$ text "" | (n,c) <- [1..] `zip` cycles ] @@ -364,7 +372,7 @@ pprCycle summaries = pp_group (CyclicSCC summaries) pp_ms summary = text mod_str <> text (take (20 - length mod_str) (repeat ' ')) <+> (pp_imps empty (ms_imps summary) $$ - pp_imps (ptext SLIT("{-# SOURCE #-}")) (ms_srcimps summary)) + pp_imps (ptext (sLit "{-# SOURCE #-}")) (ms_srcimps summary)) where mod_str = moduleNameString (moduleName (ms_mod summary)) @@ -373,7 +381,7 @@ pprCycle summaries = pp_group (CyclicSCC summaries) pp_imps what lms = case [m | L _ m <- lms, m `elem` cycle_mods] of [] -> empty - ms -> what <+> ptext SLIT("imports") <+> + ms -> what <+> ptext (sLit "imports") <+> pprWithCommas ppr ms ----------------------------------------------------------------- @@ -398,7 +406,11 @@ dep_opts = [ ( "s", SepArg (consIORef v_Dep_suffixes) ) , ( "f", SepArg (writeIORef v_Dep_makefile) ) , ( "w", NoArg (writeIORef v_Dep_warnings False) ) + , ( "-include-prelude", NoArg (writeIORef v_Dep_include_pkg_deps True) ) + -- -include-prelude is the old name for -include-pkg-deps, kept around + -- for backward compatibility, but undocumented + , ( "-include-pkg-deps", NoArg (writeIORef v_Dep_include_pkg_deps True) ) , ( "-exclude-module=", Prefix (consIORef v_Dep_exclude_mods . mkModuleName) ) , ( "x", Prefix (consIORef v_Dep_exclude_mods . mkModuleName) )