2 % (c) The University of Glasgow, 2000
4 \section[CmStaticInfo]{Session-static info for the Compilation Manager}
7 module CmStaticInfo ( Path, ModName, PkgName,
8 Package(..), PCI(..), mkPCI )
11 #include "HsVersions.h"
14 import Char ( isUpper )
15 import Directory ( getDirectoryContents )
25 raw_package_info :: [Package], -- contents of packages.conf
26 module_table :: [(ModName, PkgName, Path)]
27 -- maps each available module to pkg and path
30 -- copied from the driver
34 import_dirs :: [String],
35 library_dirs :: [String],
36 hs_libraries :: [String],
37 extra_libraries :: [String],
38 include_dirs :: [String],
39 c_includes :: [String],
40 package_deps :: [String],
41 extra_ghc_opts :: [String],
42 extra_cc_opts :: [String],
43 extra_ld_opts :: [String]
47 mkPCI :: [Package] -> IO PCI
48 mkPCI raw_package_info
49 = do mtab <- mk_module_table raw_package_info
50 return (PCI { raw_package_info = raw_package_info,
51 module_table = mtab })
53 mk_module_table :: [Package] -> IO [(ModName,PkgName,Path)]
54 mk_module_table raw_info
56 -- the list of directories where package interfaces are
57 let p_i_dirs :: [(PkgName,Path)]
58 p_i_dirs = concatMap nm_and_paths raw_info
60 -- interface names in each directory
61 ifacess <- mapM ifaces_in_dir p_i_dirs
62 let iface_table :: [(ModName,PkgName,Path)]
63 iface_table = concat ifacess
65 -- ToDo: allow a range of home package directories
68 nm_and_paths :: Package -> [(PkgName,Path)]
70 = [(name package, path) | path <- nub (import_dirs package)]
72 ifaces_in_dir :: (PkgName,Path) -> IO [(ModName,PkgName,Path)]
73 ifaces_in_dir (pkgname,path)
74 = getDirectoryContents path >>= \ entries ->
75 return [(zap_hi if_nm, pkgname, path)
76 | if_nm <- entries, looks_like_iface_name if_nm]
77 looks_like_iface_name e
78 = not (null e) && isUpper (head e)
79 && take 3 (reverse e) == "ih."
81 = reverse . drop 3 . reverse