[project @ 2000-07-05 17:01:59 by simonmar]
[ghc-hetmet.git] / ghc / driver / Package.hs
1 module Package where
2
3 import Pretty
4
5 data Package = Package {
6                 import_dirs    :: [String],
7                 library_dirs   :: [String],
8                 libraries      :: [String],
9                 include_dir    :: String,
10                 c_include      :: String,
11                 package_deps   :: [String],
12                 extra_ghc_opts :: String,
13                 extra_cc_opts  :: String,
14                 extra_ld_opts  :: String
15                 }
16   deriving (Read, Show)
17
18 listPkgs :: [(String,Package)] -> String
19 listPkgs pkgs = render (fsep (punctuate comma (map (text . fst) pkgs)))
20
21 dumpPackages :: [(String,Package)] -> String
22 dumpPackages pkgs = 
23    render (brackets (vcat (punctuate comma (map dumpPkg pkgs))))
24
25 dumpPkg (name, pkg) = parens (hang (text (show name) <> comma) 
26                                 2 (dumpPkgGuts pkg))
27
28 dumpPkgGuts (Package
29         { import_dirs    = import_dirs    
30         , library_dirs   = library_dirs   
31         , libraries      = libraries      
32         , include_dir    = include_dir    
33         , c_include      = c_include      
34         , package_deps   = package_deps   
35         , extra_ghc_opts = extra_ghc_opts 
36         , extra_cc_opts  = extra_cc_opts  
37         , extra_ld_opts  = extra_ld_opts   })
38    = text "Package" $$ nest 3 (braces (
39         sep (punctuate comma [
40            hang (text "import_dirs ="     ) 2 (pprStrs import_dirs),
41            hang (text "library_dirs = "   ) 2 (pprStrs library_dirs),
42            hang (text "libraries = "      ) 2 (pprStrs libraries),
43            hang (text "include_dir = "    ) 2 (text (show include_dir)),
44            hang (text "c_include = "      ) 2 (text (show c_include)),
45            hang (text "package_deps = "   ) 2 (pprStrs package_deps),
46            hang (text "extra_ghc_opts = " ) 2 (text (show extra_ghc_opts)),
47            hang (text "extra_cc_opts = "  ) 2 (text (show extra_cc_opts)),
48            hang (text "extra_ld_opts = "  ) 2 (text (show extra_ld_opts))
49         ])))
50
51 pprStrs strs = brackets (sep (punctuate comma (map (text . show) strs)))