[project @ 2003-07-16 13:13:50 by simonmar]
authorsimonmar <unknown>
Wed, 16 Jul 2003 13:13:50 +0000 (13:13 +0000)
committersimonmar <unknown>
Wed, 16 Jul 2003 13:13:50 +0000 (13:13 +0000)
Respect -odir in one-shot compilations.

ghc/compiler/main/DriverPipeline.hs

index f6f65a0..a5fe7c7 100644 (file)
@@ -381,6 +381,7 @@ genOutputFilenameFunc :: Bool -> Maybe FilePath -> Phase -> String
 genOutputFilenameFunc keep_output maybe_output_filename stop_phase basename
  = do
    hcsuf      <- readIORef v_HC_suf
+   odir       <- readIORef v_Output_dir
    osuf       <- readIORef v_Object_suf
    keep_hc    <- readIORef v_Keep_hc_files
 #ifdef ILX
@@ -398,12 +399,14 @@ genOutputFilenameFunc keep_output maybe_output_filename stop_phase basename
                | next_phase == stop_phase
                      = case maybe_output_filename of
                             Just file -> return file
-                            Nothing | keep_output -> return persistent
-                                    | otherwise   -> newTempName suffix
+                            Nothing
+                                | Ln <- next_phase -> return odir_persistent
+                                | keep_output      -> return persistent
+                                | otherwise        -> newTempName suffix
                        -- sometimes, we keep output from intermediate stages
                | otherwise
                     = case next_phase of
-                            Ln                  -> return persistent
+                            Ln                  -> return odir_persistent
                             Mangle | keep_raw_s -> return persistent
                             As     | keep_s     -> return persistent
                             HCc    | keep_hc    -> return persistent
@@ -412,6 +415,10 @@ genOutputFilenameFunc keep_output maybe_output_filename stop_phase basename
                suffix = myPhaseInputExt next_phase
                persistent = basename ++ '.':suffix
 
+               odir_persistent
+                  | Just d <- odir = replaceFilenameDirectory persistent d
+                  | otherwise      = persistent
+
    return func