| ... |
... |
@@ -110,6 +110,7 @@ data Flag |
|
110
|
110
|
= FlagHaddockPath FilePath
|
|
111
|
111
|
| FlagHaddockOptions String
|
|
112
|
112
|
| FlagGhcPath FilePath
|
|
|
113
|
+ | FlagGhcPkgPath FilePath
|
|
113
|
114
|
| FlagDiffTool FilePath
|
|
114
|
115
|
| FlagNoDiff
|
|
115
|
116
|
| FlagAccept
|
| ... |
... |
@@ -123,6 +124,9 @@ flagsHaddockPath flags = mlast [ path | FlagHaddockPath path <- flags ] |
|
123
|
124
|
flagsGhcPath :: [Flag] -> Maybe FilePath
|
|
124
|
125
|
flagsGhcPath flags = mlast [ path | FlagGhcPath path <- flags ]
|
|
125
|
126
|
|
|
|
127
|
+flagsGhcPkgPath :: [Flag] -> Maybe FilePath
|
|
|
128
|
+flagsGhcPkgPath flags = mlast [ path | FlagGhcPkgPath path <- flags ]
|
|
|
129
|
+
|
|
126
|
130
|
flagsHaddockOptions :: [Flag] -> [String]
|
|
127
|
131
|
flagsHaddockOptions flags = concat
|
|
128
|
132
|
[ words opts | FlagHaddockOptions opts <- flags ]
|
| ... |
... |
@@ -140,6 +144,8 @@ options = |
|
140
|
144
|
"additional options to run Haddock with"
|
|
141
|
145
|
, Option [] ["ghc-path"] (ReqArg FlagGhcPath "FILE")
|
|
142
|
146
|
"path ghc executable"
|
|
|
147
|
+ , Option [] ["ghc-pkg-path"] (ReqArg FlagGhcPkgPath "FILE")
|
|
|
148
|
+ "path to ghc-pkg executable"
|
|
143
|
149
|
, Option [] ["diff-tool"] (ReqArg FlagDiffTool "PATH")
|
|
144
|
150
|
"diff tool to use when printing failed cases"
|
|
145
|
151
|
, Option ['a'] ["accept"] (NoArg FlagAccept)
|
| ... |
... |
@@ -217,7 +223,7 @@ loadConfig ccfg dcfg flags files = do |
|
217
|
223
|
, pure ["--optghc=-w"]
|
|
218
|
224
|
, pure ["--optghc=-hide-all-packages"]
|
|
219
|
225
|
, pure $ flagsHaddockOptions flags
|
|
220
|
|
- , baseDependencies cfgGhcPath
|
|
|
226
|
+ , baseDependencies cfgGhcPath (flagsGhcPkgPath flags)
|
|
221
|
227
|
]
|
|
222
|
228
|
|
|
223
|
229
|
cfgDiffTool <- if FlagNoDiff `elem` flags
|
| ... |
... |
@@ -248,14 +254,14 @@ printVersions env haddockPath = do |
|
248
|
254
|
void $ waitForSuccess "Failed to run `haddock --ghc-version`" stderr handleGhc
|
|
249
|
255
|
|
|
250
|
256
|
|
|
251
|
|
-baseDependencies :: FilePath -> IO [String]
|
|
252
|
|
-baseDependencies ghcPath = do
|
|
|
257
|
+baseDependencies :: FilePath -> Maybe FilePath -> IO [String]
|
|
|
258
|
+baseDependencies ghcPath ghcPkgPath = do
|
|
253
|
259
|
-- The 'getInstalledPackages' crashes if used when "GHC_PACKAGE_PATH" is
|
|
254
|
260
|
-- set to some value. I am not sure why is that happening and what are the
|
|
255
|
261
|
-- consequences of unsetting it - but looks like it works (for now).
|
|
256
|
262
|
unsetEnv "GHC_PACKAGE_PATH"
|
|
257
|
263
|
|
|
258
|
|
- (comp, _, cfg) <- configure normal (Just ghcPath) Nothing
|
|
|
264
|
+ (comp, _, cfg) <- configure normal (Just ghcPath) ghcPkgPath
|
|
259
|
265
|
defaultProgramDb
|
|
260
|
266
|
pkgIndex <- getInstalledPackages normal comp Nothing [GlobalPackageDB] cfg
|
|
261
|
267
|
let
|