Skip to content

Commit 43cf168

Browse files
committed
Build dependencies with haddock-project
`haddock-project` command need to build the project so that haddocks of the dependencies are available in the store. Fixes #8958.
1 parent b88a414 commit 43cf168

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

cabal-install/src/Distribution/Client/CmdHaddockProject.hs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ module Distribution.Client.CmdHaddockProject
44
) where
55

66
import Prelude ()
7-
import Data.Bool (bool)
87
import Distribution.Client.Compat.Prelude hiding (get)
98

109
import qualified Distribution.Client.CmdBuild as CmdBuild
@@ -54,8 +53,6 @@ import Distribution.Simple.Compiler
5453
( Compiler (..) )
5554
import Distribution.Simple.Flag
5655
( Flag(..)
57-
, flagElim
58-
, flagToList
5956
, fromFlag
6057
, fromFlagOrDefault
6158
)
@@ -132,7 +129,7 @@ haddockProjectAction flags _extraArgs globalFlags = do
132129
-- we need.
133130
--
134131

135-
withContextAndSelectors RejectNoTargets Nothing nixFlags ["all"] globalFlags HaddockCommand $ \targetCtx ctx targetSelectors -> do
132+
withContextAndSelectors RejectNoTargets Nothing (commandDefaultFlags CmdBuild.buildCommand) ["all"] globalFlags HaddockCommand $ \targetCtx ctx targetSelectors -> do
136133
baseCtx <- case targetCtx of
137134
ProjectContext -> return ctx
138135
GlobalContext -> return ctx
@@ -183,6 +180,16 @@ haddockProjectAction flags _extraArgs globalFlags = do
183180
(orLaterVersion (mkVersion [2,26,1])) progs
184181

185182
--
183+
-- Build project; we need to build dependencies.
184+
-- Issue #8958.
185+
--
186+
187+
when localStyle $
188+
CmdBuild.buildAction
189+
(commandDefaultFlags CmdBuild.buildCommand)
190+
["all"]
191+
globalFlags
192+
--
186193
-- Build haddocks of each components
187194
--
188195

@@ -200,8 +207,8 @@ haddockProjectAction flags _extraArgs globalFlags = do
200207
Left _ | not localStyle ->
201208
return []
202209
Left package -> do
203-
-- TODO: this might not work for public packages with sublibraries
204-
-- (which will be visible if one is using `--local` switch).
210+
-- TODO: this might not work for public packages with sublibraries.
211+
-- Issue #9026.
205212
let packageName = unPackageName (pkgName $ sourcePackageId package)
206213
destDir = outputDir </> packageName
207214
fmap catMaybes $ for (haddockInterfaces package) $ \interfacePath -> do
@@ -235,7 +242,12 @@ haddockProjectAction flags _extraArgs globalFlags = do
235242
, interfacePath
236243
, Visible
237244
)]
238-
False -> return []
245+
False -> do
246+
warn verbosity
247+
("haddocks of "
248+
++ show unitId
249+
++ " not found in the store")
250+
return []
239251
False | not localStyle ->
240252
return []
241253
False -> do
@@ -257,7 +269,12 @@ haddockProjectAction flags _extraArgs globalFlags = do
257269
, interfacePath
258270
, Hidden
259271
)]
260-
False -> return []
272+
False -> do
273+
warn verbosity
274+
("haddocks of "
275+
++ show unitId
276+
++ " not found in the store")
277+
return []
261278

262279
--
263280
-- generate index, content, etc.

0 commit comments

Comments
 (0)