From d9f56487e35617166d532257cda3e1f380896b0b Mon Sep 17 00:00:00 2001 From: simonmar Date: Thu, 26 Apr 2001 14:33:44 +0000 Subject: [PATCH] [project @ 2001-04-26 14:33:44 by simonmar] Don't fail during dependency generation if one of the search paths doesn't exist. --- ghc/compiler/main/DriverMkDepend.hs | 7 +++---- ghc/compiler/main/DriverUtil.hs | 14 +++++++++++++- ghc/compiler/main/Finder.lhs | 12 ++---------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ghc/compiler/main/DriverMkDepend.hs b/ghc/compiler/main/DriverMkDepend.hs index f72ab56..544296b 100644 --- a/ghc/compiler/main/DriverMkDepend.hs +++ b/ghc/compiler/main/DriverMkDepend.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverMkDepend.hs,v 1.9 2001/03/28 16:51:03 simonmar Exp $ +-- $Id: DriverMkDepend.hs,v 1.10 2001/04/26 14:33:44 simonmar Exp $ -- -- GHC Driver -- @@ -113,8 +113,8 @@ beginMkDependHS = do -- reference. import_dirs <- readIORef v_Import_paths pkg_import_dirs <- getPackageImportPath - import_dir_contents <- mapM getDirectoryContents import_dirs - pkg_import_dir_contents <- mapM getDirectoryContents pkg_import_dirs + import_dir_contents <- mapM softGetDirectoryContents import_dirs + pkg_import_dir_contents <- mapM softGetDirectoryContents pkg_import_dirs writeIORef v_Dep_dir_contents (zip import_dirs import_dir_contents ++ zip pkg_import_dirs pkg_import_dir_contents) @@ -199,4 +199,3 @@ findDependency is_source src imp = do -- in search dir_contents - diff --git a/ghc/compiler/main/DriverUtil.hs b/ghc/compiler/main/DriverUtil.hs index 9c282f6..fd0bcaf 100644 --- a/ghc/compiler/main/DriverUtil.hs +++ b/ghc/compiler/main/DriverUtil.hs @@ -1,5 +1,5 @@ ----------------------------------------------------------------------------- --- $Id: DriverUtil.hs,v 1.19 2001/03/08 09:50:18 simonmar Exp $ +-- $Id: DriverUtil.hs,v 1.20 2001/04/26 14:33:44 simonmar Exp $ -- -- Utils for the driver -- @@ -20,6 +20,7 @@ import Exception import Dynamic import RegexString +import Directory ( getDirectoryContents ) import IO import System import List @@ -66,6 +67,17 @@ getOptionsFromSource file optionRegex = mkRegex "\\{-#[ \t]+OPTIONS[ \t]+(.*)#-\\}" -- -} ----------------------------------------------------------------------------- +-- A version of getDirectoryContents that is non-fatal if the +-- directory doesn't exist. + +softGetDirectoryContents d + = IO.catch (getDirectoryContents d) + (\_ -> do hPutStr stderr + ("WARNING: error while reading directory " ++ d) + return [] + ) + +----------------------------------------------------------------------------- -- Utils unknownFlagErr :: String -> a diff --git a/ghc/compiler/main/Finder.lhs b/ghc/compiler/main/Finder.lhs index 028d056..c9ce6a1 100644 --- a/ghc/compiler/main/Finder.lhs +++ b/ghc/compiler/main/Finder.lhs @@ -81,7 +81,7 @@ maybeHomeModule mod_name = do -- to ["."]). home_imports <- readIORef v_Import_paths let extendFM fm path = do - contents <- getDirectoryContents' path + contents <- softGetDirectoryContents path let clean_contents = filter isUsefulFile contents return (addListToFM fm (zip clean_contents (repeat path))) home_map <- foldM extendFM emptyFM home_imports @@ -160,7 +160,7 @@ newPkgCache pkgs = do let dirs = import_dirs pkg pkg_name = _PK_ (name pkg) let addDir fm dir = do - contents <- getDirectoryContents' dir + contents <- softGetDirectoryContents dir return (addListToFM fm (zip contents (repeat (pkg_name,dir)))) foldM addDir fm dirs @@ -198,12 +198,4 @@ maybePackageModule mod_name = do isUsefulFile fn = let suffix = (reverse . takeWhile (/= '.') . reverse) fn in suffix `elem` ["hi", "hs", "lhs", "hi-boot", "hi-boot-5"] - -getDirectoryContents' d - = IO.catch (getDirectoryContents d) - (\_ -> do hPutStr stderr - ("WARNING: error while reading directory " ++ d) - return [] - ) - \end{code} -- 1.7.10.4