2 % (c) The University of Glasgow, 2006
8 -- The above warning supression flag is a temporary kludge.
9 -- While working on this module you are encouraged to remove it and fix
10 -- any warnings in the module. See
11 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
17 -- * The PackageConfigMap
18 PackageConfigMap, emptyPackageConfigMap, lookupPackage,
19 extendPackageConfigMap, dumpPackages,
21 -- * Reading the package config, and processing cmdline args
25 lookupModuleInAllPackages,
27 -- * Inspecting the set of packages in scope
28 getPackageIncludePath,
30 getPackageLibraryPath,
32 getPackageExtraCcOpts,
33 getPackageFrameworkPath,
35 getPreloadPackagesAnd,
42 #include "HsVersions.h"
45 import ParsePkgConf ( loadPackageConfig )
46 import DynFlags ( dopt, DynFlag(..), DynFlags(..), PackageFlag(..) )
47 import StaticFlags ( opt_Static )
48 import Config ( cProjectVersion )
49 import Name ( Name, nameModule_maybe )
53 import Maybes ( expectJust, MaybeErr(..) )
57 #if __GLASGOW_HASKELL__ < 603
58 import Compat.Directory ( getAppUserDataDirectory )
61 import System.Environment ( getEnv )
62 import Distribution.InstalledPackageInfo
63 import Distribution.Package
64 import Distribution.Version
66 import ErrUtils ( debugTraceMsg, putMsg, Message )
68 import System.Directory
69 import System.FilePath
73 import Control.Exception ( throwDyn )
75 -- ---------------------------------------------------------------------------
78 -- Package state is all stored in DynFlags, including the details of
79 -- all packages, which packages are exposed, and which modules they
82 -- The package state is computed by initPackages, and kept in DynFlags.
84 -- * -package <pkg> causes <pkg> to become exposed, and all other packages
85 -- with the same name to become hidden.
87 -- * -hide-package <pkg> causes <pkg> to become hidden.
89 -- * Let exposedPackages be the set of packages thus exposed.
90 -- Let depExposedPackages be the transitive closure from exposedPackages of
91 -- their dependencies.
93 -- * When searching for a module from an preload import declaration,
94 -- only the exposed modules in exposedPackages are valid.
96 -- * When searching for a module from an implicit import, all modules
97 -- from depExposedPackages are valid.
99 -- * When linking in a comp manager mode, we link in packages the
100 -- program depends on (the compiler knows this list by the
101 -- time it gets to the link step). Also, we link in all packages
102 -- which were mentioned with preload -package flags on the command-line,
103 -- or are a transitive dependency of same, or are "base"/"rts".
104 -- The reason for (b) is that we might need packages which don't
105 -- contain any Haskell modules, and therefore won't be discovered
106 -- by the normal mechanism of dependency tracking.
110 -- When compiling module A, which imports module B, we need to
111 -- know whether B will be in the same DLL as A.
112 -- If it's in the same DLL, we refer to B_f_closure
113 -- If it isn't, we refer to _imp__B_f_closure
114 -- When compiling A, we record in B's Module value whether it's
115 -- in a different DLL, by setting the DLL flag.
117 data PackageState = PackageState {
118 pkgIdMap :: PackageConfigMap, -- PackageId -> PackageConfig
119 -- The exposed flags are adjusted according to -package and
120 -- -hide-package flags, and -ignore-package removes packages.
122 preloadPackages :: [PackageId],
123 -- The packages we're going to link in eagerly. This list
124 -- should be in reverse dependency order; that is, a package
125 -- is always mentioned before the packages it depends on.
127 moduleToPkgConfAll :: UniqFM [(PackageConfig,Bool)] -- ModuleEnv mapping
128 -- Derived from pkgIdMap.
129 -- Maps Module to (pkgconf,exposed), where pkgconf is the
130 -- PackageConfig for the package containing the module, and
131 -- exposed is True if the package exposes that module.
134 -- A PackageConfigMap maps a PackageId to a PackageConfig
135 type PackageConfigMap = UniqFM PackageConfig
137 emptyPackageConfigMap :: PackageConfigMap
138 emptyPackageConfigMap = emptyUFM
140 lookupPackage :: PackageConfigMap -> PackageId -> Maybe PackageConfig
141 lookupPackage = lookupUFM
143 extendPackageConfigMap
144 :: PackageConfigMap -> [PackageConfig] -> PackageConfigMap
145 extendPackageConfigMap pkg_map new_pkgs
146 = foldl add pkg_map new_pkgs
147 where add pkg_map p = addToUFM pkg_map (packageConfigId p) p
149 getPackageDetails :: PackageState -> PackageId -> PackageConfig
150 getPackageDetails dflags ps = expectJust "getPackageDetails" (lookupPackage (pkgIdMap dflags) ps)
152 -- ----------------------------------------------------------------------------
153 -- Loading the package config files and building up the package state
155 -- | Call this after 'DynFlags.parseDynFlags'. It reads the package
156 -- configuration files, and sets up various internal tables of package
157 -- information, according to the package-related flags on the
158 -- command-line (@-package@, @-hide-package@ etc.)
160 -- Returns a list of packages to link in if we're doing dynamic linking.
161 -- This list contains the packages that the user explicitly mentioned with
164 -- 'initPackages' can be called again subsequently after updating the
165 -- 'packageFlags' field of the 'DynFlags', and it will update the
166 -- 'packageState' in 'DynFlags' and return a list of packages to
168 initPackages :: DynFlags -> IO (DynFlags, [PackageId])
169 initPackages dflags = do
170 pkg_db <- case pkgDatabase dflags of
171 Nothing -> readPackageConfigs dflags
173 (pkg_state, preload, this_pkg)
174 <- mkPackageState dflags pkg_db [] (thisPackage dflags)
175 return (dflags{ pkgDatabase = Just pkg_db,
176 pkgState = pkg_state,
177 thisPackage = this_pkg },
180 -- -----------------------------------------------------------------------------
181 -- Reading the package database(s)
183 readPackageConfigs :: DynFlags -> IO PackageConfigMap
184 readPackageConfigs dflags = do
185 e_pkg_path <- try (getEnv "GHC_PACKAGE_PATH")
186 system_pkgconfs <- getSystemPackageConfigs dflags
188 let pkgconfs = case e_pkg_path of
189 Left _ -> system_pkgconfs
191 | last cs == "" -> init cs ++ system_pkgconfs
193 where cs = parseSearchPath path
194 -- if the path ends in a separator (eg. "/foo/bar:")
195 -- the we tack on the system paths.
197 -- Read all the ones mentioned in -package-conf flags
198 pkg_map <- foldM (readPackageConfig dflags) emptyPackageConfigMap
199 (reverse pkgconfs ++ extraPkgConfs dflags)
204 getSystemPackageConfigs :: DynFlags -> IO [FilePath]
205 getSystemPackageConfigs dflags = do
206 -- System one always comes first
207 let system_pkgconf = systemPackageConfig dflags
209 -- allow package.conf.d to contain a bunch of .conf files
210 -- containing package specifications. This is an easier way
211 -- to maintain the package database on systems with a package
212 -- management system, or systems that don't want to run ghc-pkg
213 -- to register or unregister packages. Undocumented feature for now.
214 let system_pkgconf_dir = system_pkgconf <.> "d"
215 system_pkgconf_dir_exists <- doesDirectoryExist system_pkgconf_dir
217 if system_pkgconf_dir_exists
218 then do files <- getDirectoryContents system_pkgconf_dir
219 return [ system_pkgconf_dir </> file
221 , takeExtension file == ".conf" ]
224 -- Read user's package conf (eg. ~/.ghc/i386-linux-6.3/package.conf)
225 -- unless the -no-user-package-conf flag was given.
226 -- We only do this when getAppUserDataDirectory is available
228 user_pkgconf <- handle (\_ -> return []) $ do
229 appdir <- getAppUserDataDirectory "ghc"
232 </> (TARGET_ARCH ++ '-':TARGET_OS ++ '-':cProjectVersion)
234 flg <- doesFileExist pkgconf
235 if (flg && dopt Opt_ReadUserPackageConf dflags)
236 then return [pkgconf]
239 return (user_pkgconf ++ system_pkgconfs ++ [system_pkgconf])
243 :: DynFlags -> PackageConfigMap -> FilePath -> IO PackageConfigMap
244 readPackageConfig dflags pkg_map conf_file = do
245 debugTraceMsg dflags 2 (text "Using package config file:" <+> text conf_file)
246 proto_pkg_configs <- loadPackageConfig conf_file
247 let top_dir = topDir dflags
248 pkg_configs1 = mungePackagePaths top_dir proto_pkg_configs
249 pkg_configs2 = maybeHidePackages dflags pkg_configs1
250 return (extendPackageConfigMap pkg_map pkg_configs2)
252 maybeHidePackages :: DynFlags -> [PackageConfig] -> [PackageConfig]
253 maybeHidePackages dflags pkgs
254 | dopt Opt_HideAllPackages dflags = map hide pkgs
257 hide pkg = pkg{ exposed = False }
259 mungePackagePaths :: String -> [PackageConfig] -> [PackageConfig]
260 -- Replace the string "$topdir" at the beginning of a path
261 -- with the current topdir (obtained from the -B option).
262 mungePackagePaths top_dir ps = map munge_pkg ps
264 munge_pkg p = p{ importDirs = munge_paths (importDirs p),
265 includeDirs = munge_paths (includeDirs p),
266 libraryDirs = munge_paths (libraryDirs p),
267 frameworkDirs = munge_paths (frameworkDirs p) }
269 munge_paths = map munge_path
272 | Just p' <- maybePrefixMatch "$topdir" p = top_dir ++ p'
273 | Just p' <- maybePrefixMatch "$httptopdir" p = toHttpPath top_dir ++ p'
276 toHttpPath p = "file:///" ++ p
279 -- -----------------------------------------------------------------------------
280 -- Modify our copy of the package database based on a package flag
281 -- (-package, -hide-package, -ignore-package).
284 :: [PackageConfig] -- Initial database
285 -> PackageFlag -- flag to apply
286 -> IO [PackageConfig] -- new database
288 applyPackageFlag pkgs flag =
291 case matchingPackages str pkgs of
292 Nothing -> missingPackageErr str
293 Just (p:ps,qs) -> return (p':ps')
294 where p' = p {exposed=True}
295 ps' = hideAll (pkgName (package p)) (ps++qs)
298 case matchingPackages str pkgs of
299 Nothing -> missingPackageErr str
300 Just (ps,qs) -> return (map hide ps ++ qs)
301 where hide p = p {exposed=False}
304 case matchingPackages str pkgs of
305 Nothing -> return pkgs
306 Just (ps,qs) -> return qs
307 -- missing package is not an error for -ignore-package,
308 -- because a common usage is to -ignore-package P as
309 -- a preventative measure just in case P exists.
311 -- When a package is requested to be exposed, we hide all other
312 -- packages with the same name.
313 hideAll name ps = map maybe_hide ps
314 where maybe_hide p | pkgName (package p) == name = p {exposed=False}
318 matchingPackages :: String -> [PackageConfig]
319 -> Maybe ([PackageConfig], [PackageConfig])
320 matchingPackages str pkgs
321 = case partition (matches str) pkgs of
323 (ps,rest) -> Just (sortByVersion ps, rest)
325 -- A package named on the command line can either include the
326 -- version, or just the name if it is unambiguous.
328 = str == showPackageId (package p)
329 || str == pkgName (package p)
332 pickPackages pkgs strs =
333 [ p | p <- strs, Just (p:ps,_) <- [matchingPackages p pkgs] ]
335 sortByVersion = sortBy (flip (comparing (pkgVersion.package)))
336 comparing f a b = f a `compare` f b
338 -- -----------------------------------------------------------------------------
339 -- Hide old versions of packages
342 -- hide all packages for which there is also a later version
343 -- that is already exposed. This just makes it non-fatal to have two
344 -- versions of a package exposed, which can happen if you install a
345 -- later version of a package in the user database, for example.
347 hideOldPackages :: DynFlags -> [PackageConfig] -> IO [PackageConfig]
348 hideOldPackages dflags pkgs = mapM maybe_hide pkgs
350 | not (exposed p) = return p
351 | (p' : _) <- later_versions = do
352 debugTraceMsg dflags 2 $
353 (ptext SLIT("hiding package") <+>
354 text (showPackageId (package p)) <+>
355 ptext SLIT("to avoid conflict with later version") <+>
356 text (showPackageId (package p')))
357 return (p {exposed=False})
358 | otherwise = return p
359 where myname = pkgName (package p)
360 myversion = pkgVersion (package p)
361 later_versions = [ p | p <- pkgs, exposed p,
363 pkgName pkg == myname,
364 pkgVersion pkg > myversion ]
366 -- -----------------------------------------------------------------------------
371 -> [PackageConfig] -- database
372 -> [PackageIdentifier] -- preload packages
373 -> PackageId -- this package
374 -> IO ([PackageConfig],
378 findWiredInPackages dflags pkgs preload this_package = do
380 -- Now we must find our wired-in packages, and rename them to
381 -- their canonical names (eg. base-1.0 ==> base).
384 wired_in_pkgids = [ basePackageId,
390 wired_in_names = map packageIdString wired_in_pkgids
392 -- find which package corresponds to each wired-in package
393 -- delete any other packages with the same name
394 -- update the package and any dependencies to point to the new
397 -- When choosing which package to map to a wired-in package
398 -- name, we prefer exposed packages, and pick the latest
399 -- version. To override the default choice, -hide-package
400 -- could be used to hide newer versions.
402 findWiredInPackage :: [PackageConfig] -> String
403 -> IO (Maybe PackageIdentifier)
404 findWiredInPackage pkgs wired_pkg =
405 let all_ps = [ p | p <- pkgs, pkgName (package p) == wired_pkg ] in
406 case filter exposed all_ps of
409 many -> pick (head (sortByVersion many))
410 many -> pick (head (sortByVersion many))
413 debugTraceMsg dflags 2 $
414 ptext SLIT("wired-in package ")
416 <> ptext SLIT(" not found.")
419 debugTraceMsg dflags 2 $
420 ptext SLIT("wired-in package ")
422 <> ptext SLIT(" mapped to ")
423 <> text (showPackageId (package pkg))
424 return (Just (package pkg))
427 mb_wired_in_ids <- mapM (findWiredInPackage pkgs) wired_in_names
429 wired_in_ids = catMaybes mb_wired_in_ids
431 deleteOtherWiredInPackages pkgs = filter ok pkgs
432 where ok p = pkgName (package p) `notElem` wired_in_names
433 || package p `elem` wired_in_ids
435 updateWiredInDependencies pkgs = map upd_pkg pkgs
436 where upd_pkg p = p{ package = upd_pid (package p),
437 depends = map upd_pid (depends p) }
439 upd_pid pid = case filter (== pid) wired_in_ids of
441 (x:_) -> x{ pkgVersion = Version [] [] }
443 pkgs1 = deleteOtherWiredInPackages pkgs
445 pkgs2 = updateWiredInDependencies pkgs1
447 preload1 = map upd_pid preload
449 -- we must return an updated thisPackage, just in case we
450 -- are actually compiling one of the wired-in packages
451 Just old_this_pkg = unpackPackageId this_package
452 new_this_pkg = mkPackageId (upd_pid old_this_pkg)
454 return (pkgs2, preload1, new_this_pkg)
456 -- -----------------------------------------------------------------------------
458 -- Eliminate any packages which have dangling dependencies (
459 -- because the dependency was removed by -ignore-package).
464 -> [PackageId] -- ignored packages
465 -> IO [PackageConfig]
467 elimDanglingDeps dflags pkgs ignored =
468 case partition (not.null.snd) (map (getDanglingDeps pkgs ignored) pkgs) of
469 ([],ps) -> return (map fst ps)
472 elimDanglingDeps dflags (map fst qs)
473 (ignored ++ map packageConfigId (map fst ps))
475 reportElim (p, deps) =
476 debugTraceMsg dflags 2 $
477 (ptext SLIT("package") <+> pprPkg p <+>
478 ptext SLIT("will be ignored due to missing dependencies:") $$
479 nest 2 (hsep (map (text.showPackageId) deps)))
481 getDanglingDeps pkgs ignored p = (p, filter dangling (depends p))
482 where dangling pid = mkPackageId pid `elem` ignored
484 -- -----------------------------------------------------------------------------
485 -- When all the command-line options are in, we can process our package
486 -- settings and populate the package state.
490 -> PackageConfigMap -- initial database
491 -> [PackageId] -- preloaded packages
492 -> PackageId -- this package
494 [PackageId], -- new packages to preload
495 PackageId) -- this package, might be modified if the current
497 -- package is a wired-in package.
499 mkPackageState dflags orig_pkg_db preload0 this_package = do
501 -- Modify the package database according to the command-line flags
502 -- (-package, -hide-package, -ignore-package, -hide-all-packages).
504 let flags = reverse (packageFlags dflags)
505 let pkgs0 = eltsUFM orig_pkg_db
506 pkgs1 <- foldM applyPackageFlag pkgs0 flags
508 -- Here we build up a set of the packages mentioned in -package
509 -- flags on the command line; these are called the "preload"
510 -- packages. we link these packages in eagerly. The preload set
511 -- should contain at least rts & base, which is why we pretend that
512 -- the command line contains -package rts & -package base.
514 let new_preload_packages =
515 map package (pickPackages pkgs0 [ p | ExposePackage p <- flags ])
517 -- hide packages that are subsumed by later versions
518 pkgs2 <- hideOldPackages dflags pkgs1
520 -- sort out which packages are wired in
521 (pkgs3, preload1, new_this_pkg)
522 <- findWiredInPackages dflags pkgs2 new_preload_packages this_package
524 let ignored = map packageConfigId $
525 pickPackages pkgs0 [ p | IgnorePackage p <- flags ]
526 pkgs <- elimDanglingDeps dflags pkgs3 ignored
528 let pkg_db = extendPackageConfigMap emptyPackageConfigMap pkgs
529 pkgids = map packageConfigId pkgs
531 -- add base & rts to the preload packages
532 basicLinkedPackages = filter (flip elemUFM pkg_db)
533 [basePackageId,rtsPackageId]
534 -- but in any case remove the current package from the set of
535 -- preloaded packages so that base/rts does not end up in the
536 -- set up preloaded package when we are just building it
537 preload2 = nub (filter (/= new_this_pkg)
538 (basicLinkedPackages ++ map mkPackageId preload1))
540 -- Close the preload packages with their dependencies
541 dep_preload <- closeDeps pkg_db (zip preload2 (repeat Nothing))
542 let new_dep_preload = filter (`notElem` preload0) dep_preload
544 let pstate = PackageState{ preloadPackages = dep_preload,
546 moduleToPkgConfAll = mkModuleMap pkg_db
549 return (pstate, new_dep_preload, new_this_pkg)
552 -- -----------------------------------------------------------------------------
553 -- Make the mapping from module to package info
557 -> UniqFM [(PackageConfig, Bool)]
558 mkModuleMap pkg_db = foldr extend_modmap emptyUFM pkgids
560 pkgids = map packageConfigId (eltsUFM pkg_db)
562 extend_modmap pkgid modmap =
563 addListToUFM_C (++) modmap
564 ([(m, [(pkg, True)]) | m <- exposed_mods] ++
565 [(m, [(pkg, False)]) | m <- hidden_mods])
567 pkg = expectJust "mkModuleMap" (lookupPackage pkg_db pkgid)
568 exposed_mods = exposedModules pkg
569 hidden_mods = hiddenModules pkg
571 pprPkg :: PackageConfig -> SDoc
572 pprPkg p = text (showPackageId (package p))
574 -- -----------------------------------------------------------------------------
575 -- Extracting information from the packages in scope
577 -- Many of these functions take a list of packages: in those cases,
578 -- the list is expected to contain the "dependent packages",
579 -- i.e. those packages that were found to be depended on by the
580 -- current module/program. These can be auto or non-auto packages, it
581 -- doesn't really matter. The list is always combined with the list
582 -- of preload (command-line) packages to determine which packages to
585 getPackageIncludePath :: DynFlags -> [PackageId] -> IO [String]
586 getPackageIncludePath dflags pkgs = do
587 ps <- getPreloadPackagesAnd dflags pkgs
588 return (nub (filter notNull (concatMap includeDirs ps)))
590 -- includes are in reverse dependency order (i.e. rts first)
591 getPackageCIncludes :: [PackageConfig] -> IO [String]
592 getPackageCIncludes pkg_configs = do
593 return (reverse (nub (filter notNull (concatMap includes pkg_configs))))
595 getPackageLibraryPath :: DynFlags -> [PackageId] -> IO [String]
596 getPackageLibraryPath dflags pkgs = do
597 ps <- getPreloadPackagesAnd dflags pkgs
598 return (nub (filter notNull (concatMap libraryDirs ps)))
600 getPackageLinkOpts :: DynFlags -> [PackageId] -> IO [String]
601 getPackageLinkOpts dflags pkgs = do
602 ps <- getPreloadPackagesAnd dflags pkgs
603 let tag = buildTag dflags
604 rts_tag = rtsBuildTag dflags
606 mkDynName | opt_Static = id
607 | otherwise = (++ ("-ghc" ++ cProjectVersion))
608 libs p = map (mkDynName . addSuffix) (hsLibraries p)
610 all_opts p = map ("-l" ++) (libs p) ++ ldOptions p
612 addSuffix rts@"HSrts" = rts ++ (expandTag rts_tag)
613 addSuffix other_lib = other_lib ++ (expandTag tag)
615 expandTag t | null t = ""
618 return (concat (map all_opts ps))
620 getPackageExtraCcOpts :: DynFlags -> [PackageId] -> IO [String]
621 getPackageExtraCcOpts dflags pkgs = do
622 ps <- getPreloadPackagesAnd dflags pkgs
623 return (concatMap ccOptions ps)
625 getPackageFrameworkPath :: DynFlags -> [PackageId] -> IO [String]
626 getPackageFrameworkPath dflags pkgs = do
627 ps <- getPreloadPackagesAnd dflags pkgs
628 return (nub (filter notNull (concatMap frameworkDirs ps)))
630 getPackageFrameworks :: DynFlags -> [PackageId] -> IO [String]
631 getPackageFrameworks dflags pkgs = do
632 ps <- getPreloadPackagesAnd dflags pkgs
633 return (concatMap frameworks ps)
635 -- -----------------------------------------------------------------------------
638 -- | Takes a Module, and if the module is in a package returns
639 -- @(pkgconf,exposed)@ where pkgconf is the PackageConfig for that package,
640 -- and exposed is True if the package exposes the module.
641 lookupModuleInAllPackages :: DynFlags -> ModuleName -> [(PackageConfig,Bool)]
642 lookupModuleInAllPackages dflags m =
643 case lookupUFM (moduleToPkgConfAll (pkgState dflags)) m of
647 getPreloadPackagesAnd :: DynFlags -> [PackageId] -> IO [PackageConfig]
648 getPreloadPackagesAnd dflags pkgids =
650 state = pkgState dflags
651 pkg_map = pkgIdMap state
652 preload = preloadPackages state
653 pairs = zip pkgids (repeat Nothing)
655 all_pkgs <- throwErr (foldM (add_package pkg_map) preload pairs)
656 return (map (getPackageDetails state) all_pkgs)
658 -- Takes a list of packages, and returns the list with dependencies included,
659 -- in reverse dependency order (a package appears before those it depends on).
660 closeDeps :: PackageConfigMap -> [(PackageId, Maybe PackageId)]
662 closeDeps pkg_map ps = throwErr (closeDepsErr pkg_map ps)
664 throwErr :: MaybeErr Message a -> IO a
665 throwErr m = case m of
666 Failed e -> throwDyn (CmdLineError (showSDoc e))
667 Succeeded r -> return r
669 closeDepsErr :: PackageConfigMap -> [(PackageId,Maybe PackageId)]
670 -> MaybeErr Message [PackageId]
671 closeDepsErr pkg_map ps = foldM (add_package pkg_map) [] ps
674 add_package :: PackageConfigMap -> [PackageId] -> (PackageId,Maybe PackageId)
675 -> MaybeErr Message [PackageId]
676 add_package pkg_db ps (p, mb_parent)
677 | p `elem` ps = return ps -- Check if we've already added this package
679 case lookupPackage pkg_db p of
680 Nothing -> Failed (missingPackageMsg (packageIdString p) <>
681 missingDependencyMsg mb_parent)
683 -- Add the package's dependents also
684 let deps = map mkPackageId (depends pkg)
685 ps' <- foldM (add_package pkg_db) ps (zip deps (repeat (Just p)))
688 missingPackageErr p = throwDyn (CmdLineError (showSDoc (missingPackageMsg p)))
689 missingPackageMsg p = ptext SLIT("unknown package:") <+> text p
691 missingDependencyMsg Nothing = empty
692 missingDependencyMsg (Just parent)
693 = space <> parens (ptext SLIT("dependency of") <+> ftext (packageIdFS parent))
695 -- -----------------------------------------------------------------------------
697 isDllName :: PackageId -> Name -> Bool
698 isDllName this_pkg name
700 | Just mod <- nameModule_maybe name = modulePackageId mod /= this_pkg
701 | otherwise = False -- no, it is not even an external name
703 -- -----------------------------------------------------------------------------
704 -- Displaying packages
706 dumpPackages :: DynFlags -> IO ()
707 -- Show package info on console, if verbosity is >= 3
709 = do let pkg_map = pkgIdMap (pkgState dflags)
711 vcat (map (text.showInstalledPackageInfo.to_ipi) (eltsUFM pkg_map))
713 to_ipi pkgconf@InstalledPackageInfo_{ exposedModules = e,
714 hiddenModules = h } =
715 pkgconf{ exposedModules = map moduleNameString e,
716 hiddenModules = map moduleNameString h }