2 % (c) The University of Glasgow, 2000
4 \section{Package manipulation}
7 module Packages ( PackageConfig(..),
14 #include "HsVersions.h"
17 import CmdLineOpts ( dynFlag, verbosity )
18 import DriverUtil ( my_prefix_match )
19 import ErrUtils ( dumpIfSet )
20 import Outputable ( docToSDoc, trace )
25 -- Yes, do generate pretty-printing stuff for packages
27 -- There's a blob of code shared with ghc-pkg,
28 -- so we just include it from there
29 #include "../utils/ghc-pkg/Package.hs"
32 %*********************************************************
34 \subsection{Load the config file}
36 %*********************************************************
39 mungePackagePaths :: String -> [PackageConfig] -> [PackageConfig]
40 -- Replace the string "$libdir" at the beginning of a path
41 -- with the current libdir (obtained from the -B option).
42 mungePackagePaths top_dir ps = map munge_pkg ps
44 munge_pkg p = p{ import_dirs = munge_paths (import_dirs p),
45 include_dirs = munge_paths (include_dirs p),
46 library_dirs = munge_paths (library_dirs p) }
48 munge_paths = map munge_path
51 | Just p' <- my_prefix_match "$libdir" p = top_dir ++ p'
56 %*********************************************************
58 \subsection{Display results}
60 %*********************************************************
63 showPackages :: [PackageConfig] -> IO ()
64 -- Show package info on console, if verbosity is >= 3
66 = do { verb <- dynFlag verbosity
67 ; dumpIfSet (verb >= 3) "Packages"
68 (docToSDoc (vcat (map dumpPkgGuts ps)))