maybeHomeModule mod_name is_source = do
home_path <- readIORef v_Import_paths
hisuf <- readIORef v_Hi_suf
+ mode <- readIORef v_GhcMode
let mod_str = moduleNameUserString mod_name
basename = map (\c -> if c == '.' then '/' else c) mod_str
- std_exts =
- [ ("hs", \ _ fName path -> mkHomeModuleLocn mod_name path fName)
- , ("lhs", \ _ fName path -> mkHomeModuleLocn mod_name path fName)
- , (hisuf, \ _ fName path -> mkHiOnlyModuleLocn mod_name fName)
- ]
- -- look for the .hi file last, because if there's a source file about
- -- we want to find it.
+ -- In compilation manager modes, we look for source files in the home
+ -- package because we can compile these automatically. In one-shot
+ -- compilation mode we look for .hi files only.
+ --
+ -- When generating dependencies, we're interested in either category.
+ --
+ source_exts =
+ [ ("hs", \ _ fName path -> mkHomeModuleLocn mod_name path fName)
+ , ("lhs", \ _ fName path -> mkHomeModuleLocn mod_name path fName)
+ ]
+ hi_exts = [ (hisuf, \ _ fName path -> mkHiOnlyModuleLocn mod_name fName) ]
+
+ std_exts
+ | mode == DoMkDependHS = hi_exts ++ source_exts
+ | isCompManagerMode mode = source_exts
+ | otherwise = hi_exts
-- last chance: .hi-boot-<ver> and .hi-boot
hi_boot_ver = "hi-boot-" ++ cHscIfaceFileVersion