2 module ParsePkgConf( loadPackageConfig ) where
4 #include "HsVersions.h"
6 import Packages ( PackageConfig(..), defaultPackageConfig )
12 import Panic ( GhcException(..) )
13 import EXCEPTION ( throwDyn )
26 STRING { ITstring $$ }
28 %monad { P } { thenP } { returnP }
29 %lexer { lexer } { ITeof }
34 pkgconf :: { [ PackageConfig ] }
36 | '[' pkgs ']' { reverse $2 }
38 pkgs :: { [ PackageConfig ] }
40 | pkgs ',' pkg { $3 : $1 }
42 pkg :: { PackageConfig }
43 : CONID '{' fields '}' { $3 defaultPackageConfig }
45 fields :: { PackageConfig -> PackageConfig }
46 : field { \p -> $1 p }
47 | fields ',' field { \p -> $1 ($3 p) }
49 field :: { PackageConfig -> PackageConfig }
51 {% case unpackFS $1 of {
52 "name" -> returnP (\ p -> p{name = unpackFS $3});
56 {\p -> case unpackFS $1 of {
57 "auto" -> p{auto = $3};
61 {\p -> case unpackFS $1 of
62 "import_dirs" -> p{import_dirs = $3}
63 "library_dirs" -> p{library_dirs = $3}
64 "hs_libraries" -> p{hs_libraries = $3}
65 "extra_libraries" -> p{extra_libraries = $3}
66 "include_dirs" -> p{include_dirs = $3}
67 "c_includes" -> p{c_includes = $3}
68 "package_deps" -> p{package_deps = $3}
69 "extra_ghc_opts" -> p{extra_ghc_opts = $3}
70 "extra_cc_opts" -> p{extra_cc_opts = $3}
71 "extra_ld_opts" -> p{extra_ld_opts = $3}
72 "framework_dirs" -> p{framework_dirs = $3}
73 "extra_frameworks"-> p{extra_frameworks= $3}
77 strlist :: { [String] }
79 | '[' strs ']' { reverse $2 }
82 : STRING { [ unpackFS $1 ] }
83 | strs ',' STRING { unpackFS $3 : $1 }
86 : CONID {% case unpackFS $1 of {
87 "True" -> returnP True;
88 "False" -> returnP False;
93 happyError buf PState{ loc = loc } = PFailed (srcParseErr buf loc)
95 loadPackageConfig :: FilePath -> IO [PackageConfig]
96 loadPackageConfig conf_filename = do
97 buf <- hGetStringBuffer conf_filename
98 let loc = mkSrcLoc (mkFastString conf_filename) 1
99 exts = ExtFlags {glasgowExtsEF = False,
104 case parse buf (mkPState loc exts) of
107 throwDyn (InstallationError (showSDoc err))
109 POk _ pkg_details -> do