Commit d9f56487 authored by simonmar's avatar simonmar
Browse files

[project @ 2001-04-26 14:33:44 by simonmar]

Don't fail during dependency generation if one of the search paths
doesn't exist.
parent 37961614
-----------------------------------------------------------------------------
-- $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
-----------------------------------------------------------------------------
-- $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
......@@ -65,6 +66,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
......
......@@ -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}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment