Commit 668c860b authored by Ian Lynagh's avatar Ian Lynagh

Add -dumpdir flag; fixes trac #5198

-ddump-* files are put in the given directory.

-outputdir also sets the dumpdir.
parent 62a34c72
......@@ -486,6 +486,7 @@ data DynFlags = DynFlags {
dylibInstallName :: Maybe String,
hiDir :: Maybe String,
stubDir :: Maybe String,
dumpDir :: Maybe String,
objectSuf :: String,
hcSuf :: String,
......@@ -851,6 +852,7 @@ defaultDynFlags mySettings =
dylibInstallName = Nothing,
hiDir = Nothing,
stubDir = Nothing,
dumpDir = Nothing,
objectSuf = phaseInputExt StopLn,
hcSuf = phaseInputExt HCc,
......@@ -1105,7 +1107,8 @@ getVerbFlags dflags
| verbosity dflags >= 4 = ["-v"]
| otherwise = []
setObjectDir, setHiDir, setStubDir, setOutputDir, setDylibInstallName,
setObjectDir, setHiDir, setStubDir, setDumpDir, setOutputDir,
setDylibInstallName,
setObjectSuf, setHiSuf, setHcSuf, parseDynLibLoaderMode,
setPgmP, addOptl, addOptP,
addCmdlineFramework, addHaddockOpts
......@@ -1119,7 +1122,8 @@ setStubDir f d = d{ stubDir = Just f, includePaths = f : includePaths d }
-- -stubdir D adds an implicit -I D, so that gcc can find the _stub.h file
-- \#included from the .hc file when compiling via C (i.e. unregisterised
-- builds).
setOutputDir f = setObjectDir f . setHiDir f . setStubDir f
setDumpDir f d = d{ dumpDir = Just f}
setOutputDir f = setObjectDir f . setHiDir f . setStubDir f . setDumpDir f
setDylibInstallName f d = d{ dylibInstallName = Just f}
setObjectSuf f d = d{ objectSuf = f}
......@@ -1435,6 +1439,7 @@ dynamic_flags = [
, Flag "hidir" (hasArg setHiDir)
, Flag "tmpdir" (hasArg setTmpDir)
, Flag "stubdir" (hasArg setStubDir)
, Flag "dumpdir" (hasArg setDumpDir)
, Flag "outputdir" (hasArg setOutputDir)
, Flag "ddump-file-prefix" (hasArg (setDumpPrefixForce . Just))
......
......@@ -41,6 +41,7 @@ import DynFlags
import StaticFlags ( opt_ErrorSpans )
import System.Exit ( ExitCode(..), exitWith )
import System.FilePath
import Data.List
import qualified Data.Set as Set
import Data.IORef
......@@ -247,23 +248,27 @@ dumpSDoc dflags dflag hdr doc
chooseDumpFile :: DynFlags -> DynFlag -> Maybe String
chooseDumpFile dflags dflag
-- dump file location is being forced
-- by the --ddump-file-prefix flag.
| dumpToFile
, Just prefix <- dumpPrefixForce dflags
= Just $ prefix ++ (beautifyDumpName dflag)
| dopt Opt_DumpToFile dflags
, Just prefix <- getPrefix
= Just $ setDir (prefix ++ (beautifyDumpName dflag))
-- dump file location chosen by DriverPipeline.runPipeline
| dumpToFile
, Just prefix <- dumpPrefix dflags
= Just $ prefix ++ (beautifyDumpName dflag)
-- we haven't got a place to put a dump file.
| otherwise
= Nothing
where dumpToFile = dopt Opt_DumpToFile dflags
where getPrefix
-- dump file location is being forced
-- by the --ddump-file-prefix flag.
| Just prefix <- dumpPrefixForce dflags
= Just prefix
-- dump file location chosen by DriverPipeline.runPipeline
| Just prefix <- dumpPrefix dflags
= Just prefix
-- we haven't got a place to put a dump file.
| otherwise
= Nothing
setDir f = case dumpDir dflags of
Just d -> d </> f
Nothing -> f
-- | Build a nice file name from name of a DynFlag constructor
beautifyDumpName :: DynFlag -> String
......
......@@ -266,7 +266,13 @@
</row>
<row>
<entry><option>-stubdir</option> <replaceable>dir</replaceable></entry>
<entry>redirect FFi stub files</entry>
<entry>redirect FFI stub files</entry>
<entry>dynamic</entry>
<entry>-</entry>
</row>
<row>
<entry><option>-dumpdir</option> <replaceable>dir</replaceable></entry>
<entry>redirect dump files</entry>
<entry>dynamic</entry>
<entry>-</entry>
</row>
......
......@@ -374,6 +374,19 @@ $ ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `uname -m`
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-dumpdir</option> <replaceable>dir</replaceable>
<indexterm><primary><option>-dumpdir</option></primary></indexterm>
</term>
<listitem>
<para>Redirects all dump files into
<replaceable>dir</replaceable>. Dump files are generated when
<literal>-ddump-to-file</literal> is used with other
<literal>-ddump-*</literal> flags.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-outputdir</option> <replaceable>dir</replaceable>
......@@ -383,7 +396,7 @@ $ ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `uname -m`
<para>The <option>-outputdir</option> option is shorthand for
the combination
of <option>-odir</option>, <option>-hidir</option>,
and <option>-stubdir</option>.
<option>-stubdir</option> and <option>-dumpdir</option>.
</para>
</listitem>
</varlistentry>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment