Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit f4672fa

Browse files
alexbiehl-gcalexbiehl
authored andcommitted
Add -j[n] CLI param to Haddock executable
It translates to `--ghcopt=-j[n]`
1 parent 01cff98 commit f4672fa

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

haddock-api/src/Haddock.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,17 @@ haddockWithGhc ghc args = handleTopExceptions $ do
152152
sinceQual <- rightOrThrowE (sinceQualification flags)
153153

154154
-- inject dynamic-too into flags before we proceed
155-
flags' <- ghc flags $ do
155+
flags'' <- ghc flags $ do
156156
df <- getDynFlags
157157
case lookup "GHC Dynamic" (compilerInfo df) of
158158
Just "YES" -> return $ Flag_OptGhc "-dynamic-too" : flags
159159
_ -> return flags
160160

161+
flags' <- pure $ case optParCount flags'' of
162+
Nothing -> flags''
163+
Just Nothing -> Flag_OptGhc "-j" : flags''
164+
Just (Just n) -> Flag_OptGhc ("-j" ++ show n) : flags''
165+
161166
-- bypass the interface version check
162167
let noChecks = Flag_BypassInterfaceVersonCheck `elem` flags
163168

haddock-api/src/Haddock/Options.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module Haddock.Options (
2424
optSourceCssFile,
2525
sourceUrls,
2626
wikiUrls,
27+
optParCount,
2728
optDumpInterfaceFile,
2829
optShowInterfaceFile,
2930
optLaTeXStyle,
@@ -110,6 +111,7 @@ data Flag
110111
| Flag_Reexport String
111112
| Flag_SinceQualification String
112113
| Flag_IgnoreLinkSymbol String
114+
| Flag_ParCount (Maybe Int)
113115
deriving (Eq, Show)
114116

115117

@@ -223,7 +225,9 @@ options backwardsCompat =
223225
Option [] ["since-qual"] (ReqArg Flag_SinceQualification "QUAL")
224226
"package qualification of @since, one of\n'always' (default) or 'only-external'",
225227
Option [] ["ignore-link-symbol"] (ReqArg Flag_IgnoreLinkSymbol "SYMBOL")
226-
"name of a symbol which does not trigger a warning in case of link issue"
228+
"name of a symbol which does not trigger a warning in case of link issue",
229+
Option ['j'] [] (OptArg (\count -> Flag_ParCount (fmap read count)) "n")
230+
"load modules in parallel"
227231
]
228232

229233

@@ -306,10 +310,11 @@ optShowInterfaceFile flags = optLast [ str | Flag_ShowInterface str <- flags ]
306310
optLaTeXStyle :: [Flag] -> Maybe String
307311
optLaTeXStyle flags = optLast [ str | Flag_LaTeXStyle str <- flags ]
308312

309-
310313
optMathjax :: [Flag] -> Maybe String
311314
optMathjax flags = optLast [ str | Flag_Mathjax str <- flags ]
312315

316+
optParCount :: [Flag] -> Maybe (Maybe Int)
317+
optParCount flags = optLast [ n | Flag_ParCount n <- flags ]
313318

314319
qualification :: [Flag] -> Either String QualOption
315320
qualification flags =

0 commit comments

Comments
 (0)