remove empty dir
[ghc-hetmet.git] / ghc / compiler / main / DriverPipeline.hs
index 2dbee88..e20bc56 100644 (file)
@@ -112,7 +112,8 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do
               | Just l <- maybe_old_linkable, isObjectLinkable l = True
               | otherwise = False
 
-   showPass dflags0 ("Compiling " ++ showModMsg have_object mod_summary)
+   -- FIXME: We need to know whether or not we're recompiling the file. Move this to HscMain?
+   --showPass dflags0 ("Compiling " ++ showModMsg have_object mod_summary)
 
    let location          = ms_location mod_summary
    let input_fn   = expectJust "compile:hs" (ml_hs_file location) 
@@ -130,7 +131,7 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do
        dflags      = dflags0 { includePaths = current_dir : old_paths }
 
    -- Figure out what lang we're generating
-   let hsc_lang = hscTarget dflags
+   let hsc_lang = hscMaybeAdjustTarget dflags StopLn src_flavour (hscTarget dflags)
    -- ... and what the next phase should be
    let next_phase = hscNextPhase dflags src_flavour hsc_lang
    -- ... and what file to generate the output into
@@ -204,6 +205,8 @@ compile hsc_env mod_summary maybe_old_linkable old_iface mod_index nmods = do
      HscInterpreted | not (isHsBoot src_flavour) -- We can't compile boot files to
                                                  -- bytecode so don't even try.
          -> runCompiler hscCompileInteractive handleInterpreted
+     HscNothing
+         -> runCompiler hscCompileNothing handleBatch
      _other
          -> runCompiler hscCompileBatch handleBatch
 
@@ -717,7 +720,7 @@ runPhase (Hsc src_flavour) stop dflags0 basename suff input_fn get_output_fn _ma
                                  else return False
 
   -- get the DynFlags
-       let hsc_lang = hscTarget dflags
+       let hsc_lang = hscMaybeAdjustTarget dflags stop src_flavour (hscTarget dflags)
        let next_phase = hscNextPhase dflags src_flavour hsc_lang
        output_fn  <- get_output_fn next_phase (Just location4)
 
@@ -765,7 +768,7 @@ runPhase CmmCpp stop dflags basename suff input_fn get_output_fn maybe_loc
 
 runPhase Cmm stop dflags basename suff input_fn get_output_fn maybe_loc
   = do
-       let hsc_lang = hscTarget dflags
+       let hsc_lang = hscMaybeAdjustTarget dflags stop HsSrcFile (hscTarget dflags)
        let next_phase = hscNextPhase dflags HsSrcFile hsc_lang
        output_fn <- get_output_fn next_phase maybe_loc
 
@@ -1376,8 +1379,27 @@ hscNextPhase dflags other hsc_lang =
        HscC -> HCc
        HscAsm | dopt Opt_SplitObjs dflags -> SplitMangle
               | otherwise -> As
-        HscNothing     -> HCc
+       HscNothing     -> StopLn
+       HscInterpreted -> StopLn
        _other         -> StopLn
 
+
+hscMaybeAdjustTarget :: DynFlags -> Phase -> HscSource -> HscTarget -> HscTarget
+hscMaybeAdjustTarget dflags stop HsBootFile current_hsc_lang 
+  = HscNothing         -- No output (other than Foo.hi-boot) for hs-boot files
+hscMaybeAdjustTarget dflags stop other current_hsc_lang 
+  = hsc_lang 
+  where
+       keep_hc = dopt Opt_KeepHcFiles dflags
+       hsc_lang
+               -- don't change the lang if we're interpreting
+                | current_hsc_lang == HscInterpreted = current_hsc_lang
+
+               -- force -fvia-C if we are being asked for a .hc file
+                | HCc <- stop = HscC
+                | keep_hc     = HscC
+               -- otherwise, stick to the plan
+                | otherwise = current_hsc_lang
+
 GLOBAL_VAR(v_Split_info, ("",0), (String,Int))
        -- The split prefix and number of files