Commit 38aeca27 authored by ian@well-typed.com's avatar ian@well-typed.com

Make "ghc-pkg check" check for prof and dyn ways, as well as vanilla

In particular, this fixes it if we are using dynamic libraries by
default and don't build the vanilla way.
parent b54318d3
...@@ -1471,32 +1471,38 @@ checkDuplicateDepends deps ...@@ -1471,32 +1471,38 @@ checkDuplicateDepends deps
checkHSLib :: Verbosity -> [String] -> Bool -> String -> Validate () checkHSLib :: Verbosity -> [String] -> Bool -> String -> Validate ()
checkHSLib verbosity dirs auto_ghci_libs lib = do checkHSLib verbosity dirs auto_ghci_libs lib = do
let batch_lib_file = "lib" ++ lib ++ ".a" let batch_lib_file = "lib" ++ lib ++ ".a"
m <- liftIO $ doesFileExistOnPath batch_lib_file dirs filenames = ["lib" ++ lib ++ ".a",
"lib" ++ lib ++ ".p_a",
"lib" ++ lib ++ "-ghc" ++ Version.version ++ ".so",
"lib" ++ lib ++ "-ghc" ++ Version.version ++ ".dylib",
lib ++ "-ghc" ++ Version.version ++ ".dll"]
m <- liftIO $ doesFileExistOnPath filenames dirs
case m of case m of
Nothing -> verror ForceFiles ("cannot find " ++ batch_lib_file ++ Nothing -> verror ForceFiles ("cannot find any of " ++ show filenames ++
" on library path") " on library path")
Just dir -> liftIO $ checkGHCiLib verbosity dir batch_lib_file lib auto_ghci_libs Just dir -> liftIO $ checkGHCiLib verbosity dir batch_lib_file lib auto_ghci_libs
doesFileExistOnPath :: String -> [FilePath] -> IO (Maybe FilePath) doesFileExistOnPath :: [FilePath] -> [FilePath] -> IO (Maybe FilePath)
doesFileExistOnPath file path = go path doesFileExistOnPath filenames paths = go fullFilenames
where go [] = return Nothing where fullFilenames = [ (path, path </> filename)
go (p:ps) = do b <- doesFileExistIn file p | filename <- filenames
if b then return (Just p) else go ps , path <- paths ]
go [] = return Nothing
doesFileExistIn :: String -> String -> IO Bool go ((p, fp) : xs) = do b <- doesFileExist fp
doesFileExistIn lib d = doesFileExist (d </> lib) if b then return (Just p) else go xs
checkModules :: InstalledPackageInfo -> Validate () checkModules :: InstalledPackageInfo -> Validate ()
checkModules pkg = do checkModules pkg = do
mapM_ findModule (exposedModules pkg ++ hiddenModules pkg) mapM_ findModule (exposedModules pkg ++ hiddenModules pkg)
where where
findModule modl = do findModule modl =
-- there's no .hi file for GHC.Prim -- there's no interface file for GHC.Prim
if modl == fromString "GHC.Prim" then return () else do unless (modl == fromString "GHC.Prim") $ do
let file = toFilePath modl <.> "hi" let files = [ toFilePath modl <.> extension
m <- liftIO $ doesFileExistOnPath file (importDirs pkg) | extension <- ["hi", "p_hi", "dyn_hi" ] ]
m <- liftIO $ doesFileExistOnPath files (importDirs pkg)
when (isNothing m) $ when (isNothing m) $
verror ForceFiles ("file " ++ file ++ " is missing") verror ForceFiles ("cannot find any of " ++ show files)
checkGHCiLib :: Verbosity -> String -> String -> String -> Bool -> IO () checkGHCiLib :: Verbosity -> String -> String -> String -> Bool -> IO ()
checkGHCiLib verbosity batch_lib_dir batch_lib_file lib auto_build checkGHCiLib verbosity batch_lib_dir batch_lib_file lib auto_build
......
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