Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/668c860b361f16c71d23dd41af2eeb97f6716360 >--------------------------------------------------------------- commit 668c860b361f16c71d23dd41af2eeb97f6716360 Author: Ian Lynagh <[email protected]> Date: Fri Nov 18 02:06:57 2011 +0000 Add -dumpdir flag; fixes trac #5198 -ddump-* files are put in the given directory. -outputdir also sets the dumpdir. >--------------------------------------------------------------- compiler/main/DynFlags.hs | 9 ++++++- compiler/main/ErrUtils.lhs | 31 ++++++++++++++++------------ docs/users_guide/flags.xml | 8 ++++++- docs/users_guide/separate_compilation.xml | 15 +++++++++++++- 4 files changed, 46 insertions(+), 17 deletions(-) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 2c71f33..821b9cc 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -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)) diff --git a/compiler/main/ErrUtils.lhs b/compiler/main/ErrUtils.lhs index 96bd500..3f49863 100644 --- a/compiler/main/ErrUtils.lhs +++ b/compiler/main/ErrUtils.lhs @@ -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 diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml index 1245d25..f4a8ba8 100644 --- a/docs/users_guide/flags.xml +++ b/docs/users_guide/flags.xml @@ -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> diff --git a/docs/users_guide/separate_compilation.xml b/docs/users_guide/separate_compilation.xml index e2c9c33..9d482e1 100644 --- a/docs/users_guide/separate_compilation.xml +++ b/docs/users_guide/separate_compilation.xml @@ -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> _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
