X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fmain%2FFinder.lhs;h=a5db92671d25264682a7389ae89184a53834a873;hb=c5d45a35695a91a552a180951c67355e3d3ef4e0;hp=f5fa6647e20c4066b5b19166eff261c2efa67888;hpb=6df372f956e949fd1c84445ecc44c0c81ffd0897;p=ghc-hetmet.git diff --git a/ghc/compiler/main/Finder.lhs b/ghc/compiler/main/Finder.lhs index f5fa664..a5db926 100644 --- a/ghc/compiler/main/Finder.lhs +++ b/ghc/compiler/main/Finder.lhs @@ -64,17 +64,27 @@ maybeHomeModule :: ModuleName -> Bool -> IO (Maybe (Module, ModuleLocation)) 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- and .hi-boot hi_boot_ver = "hi-boot-" ++ cHscIfaceFileVersion @@ -116,7 +126,7 @@ mkHomeModuleLocn mod_name -- take the *last* component of the module name (if a hierarchical name), -- and append it to the directory to get the .hi file name. - let (_,mod_str) = split_longest_prefix (moduleNameUserString mod_name) '.' + let (_,mod_str) = split_longest_prefix (moduleNameUserString mod_name) (=='.') hi_filename = mod_str ++ '.':hisuf hi_path | Just d <- hidir = d | otherwise = getdir basename @@ -148,6 +158,15 @@ findPackageMod mod_name hiOnly = do let imp_dirs = concatMap (\ pkg -> map ((,) pkg) (import_dirs pkg)) pkgs mod_str = moduleNameUserString mod_name basename = map (\c -> if c == '.' then '/' else c) mod_str + + mkPackageModule mod_name pkg mbFName path = + return ( mkModule mod_name (mkFastString (name pkg)) + , ModuleLocation{ ml_hspp_file = Nothing + , ml_hs_file = mbFName + , ml_hi_file = path ++ '.':package_hisuf + , ml_obj_file = Nothing + }) + searchPathExts imp_dirs basename ((package_hisuf,\ pkg fName path -> mkPackageModule mod_name pkg Nothing path) : @@ -157,13 +176,6 @@ findPackageMod mod_name hiOnly = do , ("lhs", \ pkg fName path -> mkPackageModule mod_name pkg (Just fName) path) ])) where - mkPackageModule mod_name pkg mbFName path = - return ( mkModule mod_name (mkFastString (name pkg)) - , ModuleLocation{ ml_hspp_file = Nothing - , ml_hs_file = mbFName - , ml_hi_file = path ++".hi" - , ml_obj_file = Nothing - }) findPackageModule :: ModuleName -> IO (Maybe (Module, ModuleLocation)) findPackageModule mod_name = findPackageMod mod_name True