2 % (c) The University of Glasgow, 2000
4 \section{Package manipulation}
7 module Packages ( PackageConfig(..),
14 #include "HsVersions.h"
18 import CmdLineOpts ( dynFlag, verbosity )
19 import DriverUtil ( my_prefix_match )
20 import ErrUtils ( dumpIfSet )
21 import Outputable ( docToSDoc )
26 #define INTERNAL_PRETTY
27 -- Yes, do generate pretty-printing stuff for packages, and use our
28 -- own Pretty library rather than Text.PrettyPrint
30 -- There's a blob of code shared with ghc-pkg,
31 -- so we just include it from there
32 #include "../utils/ghc-pkg/Package.hs"
35 %*********************************************************
37 \subsection{Load the config file}
39 %*********************************************************
42 mungePackagePaths :: String -> [PackageConfig] -> [PackageConfig]
43 -- Replace the string "$libdir" at the beginning of a path
44 -- with the current libdir (obtained from the -B option).
45 mungePackagePaths top_dir ps = map munge_pkg ps
47 munge_pkg p = p{ import_dirs = munge_paths (import_dirs p),
48 include_dirs = munge_paths (include_dirs p),
49 library_dirs = munge_paths (library_dirs p),
50 framework_dirs = munge_paths (framework_dirs p) }
52 munge_paths = map munge_path
55 | Just p' <- my_prefix_match "$libdir" p = top_dir ++ p'
60 %*********************************************************
62 \subsection{Display results}
64 %*********************************************************
67 showPackages :: [PackageConfig] -> IO ()
68 -- Show package info on console, if verbosity is >= 3
70 = do { verb <- dynFlag verbosity
71 ; dumpIfSet (verb >= 3) "Packages"
72 (docToSDoc (vcat (map dumpPkgGuts ps)))