diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-11-02 21:42:33 +0000 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-11-02 22:15:20 +0000 |
commit | af072fc35d8dbe7962e62700da052593e999c0ef (patch) | |
tree | e32ca8fbfa251cbd6e6734953183f3833d6b3094 /compiler/main/DriverMkDepend.hs | |
parent | d8684910b18203e0d15d3c77374382f5841e991d (diff) | |
download | haskell-af072fc35d8dbe7962e62700da052593e999c0ef.tar.gz |
Change how dependency generation works; fixes #7381
We now do the initial dependency generation for the vanilla way
regardless of what way flags and hisuf/osuf flags are given. This
makes it easier to generate the right dependency info in the end.
Diffstat (limited to 'compiler/main/DriverMkDepend.hs')
-rw-r--r-- | compiler/main/DriverMkDepend.hs | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/compiler/main/DriverMkDepend.hs b/compiler/main/DriverMkDepend.hs index 953b2c4568..7355e31593 100644 --- a/compiler/main/DriverMkDepend.hs +++ b/compiler/main/DriverMkDepend.hs @@ -51,7 +51,25 @@ import Data.Maybe ( isJust ) doMkDependHS :: GhcMonad m => [FilePath] -> m () doMkDependHS srcs = do -- Initialisation - dflags <- GHC.getSessionDynFlags + dflags0 <- GHC.getSessionDynFlags + + -- We kludge things a bit for dependency generation. Rather than + -- generating dependencies for each way separately, we generate + -- them once and then duplicate them for each way's osuf/hisuf. + -- We therefore do the initial dependency generation with an empty + -- way and .o/.hi extensions, regardless of any flags that might + -- be specified. + let dflags = dflags0 { + ways = [], + buildTag = mkBuildTag [], + hiSuf = "hi", + objectSuf = "o" + } + _ <- GHC.setSessionDynFlags dflags + + when (null (depSuffixes dflags)) $ + ghcError (ProgramError "You must specify at least one -dep-suffix") + files <- liftIO $ beginMkDependHS dflags -- Do the downsweep to find all the modules @@ -263,24 +281,13 @@ writeDependency root hdl targets dep ----------------------------- insertSuffixes :: FilePath -- Original filename; e.g. "foo.o" - -> [String] -- Extra suffices e.g. ["x","y"] - -> [FilePath] -- Zapped filenames e.g. ["foo.o", "foo.x_o", "foo.y_o"] + -> [String] -- Suffix prefixes e.g. ["x_", "y_"] + -> [FilePath] -- Zapped filenames e.g. ["foo.x_o", "foo.y_o"] -- Note that that the extra bit gets inserted *before* the old suffix - -- We assume the old suffix contains no dots, so we can strip it with removeSuffix - - -- NOTE: we used to have this comment - -- In order to construct hi files with alternate suffixes, we - -- now have to find the "basename" of the hi file. This is - -- difficult because we can't just split the hi filename - -- at the last dot - the hisuf might have dots in it. So we - -- check whether the hi filename ends in hisuf, and if it does, - -- we strip off hisuf, otherwise we strip everything after the - -- last dot. - -- But I'm not sure we care about hisufs with dots in them. - -- Lots of other things will break first! - + -- We assume the old suffix contains no dots, so we know where to + -- split it insertSuffixes file_name extras - = file_name : [ basename <.> (extra ++ "_" ++ suffix) | extra <- extras ] + = [ basename <.> (extra ++ suffix) | extra <- extras ] where (basename, suffix) = case splitExtension file_name of -- Drop the "." from the extension |