Skip to content

Commit

Permalink
Build dependencies with haddock-project
Browse files Browse the repository at this point in the history
`haddock-project` command need to build the project so that haddocks of
the dependencies are available in the store.

Fixes #8958.
  • Loading branch information
coot committed Aug 27, 2023
1 parent fa8e8dc commit e0f6a5f
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions cabal-install/src/Distribution/Client/CmdHaddockProject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module Distribution.Client.CmdHaddockProject
) where

import Prelude ()
import Data.Bool (bool)
import Distribution.Client.Compat.Prelude hiding (get)

import qualified Distribution.Client.CmdBuild as CmdBuild
Expand Down Expand Up @@ -54,8 +53,6 @@ import Distribution.Simple.Compiler
( Compiler (..) )
import Distribution.Simple.Flag
( Flag(..)
, flagElim
, flagToList
, fromFlag
, fromFlagOrDefault
)
Expand Down Expand Up @@ -132,7 +129,7 @@ haddockProjectAction flags _extraArgs globalFlags = do
-- we need.
--

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

--
-- Build project; we need to build dependencies.
-- Issue #8958.
--

when localStyle $
CmdBuild.buildAction
(commandDefaultFlags CmdBuild.buildCommand)
["all"]
globalFlags
--
-- Build haddocks of each components
--

Expand All @@ -200,8 +207,8 @@ haddockProjectAction flags _extraArgs globalFlags = do
Left _ | not localStyle ->
return []
Left package -> do
-- TODO: this might not work for public packages with sublibraries
-- (which will be visible if one is using `--local` switch).
-- TODO: this might not work for public packages with sublibraries.
-- Issue #9026.
let packageName = unPackageName (pkgName $ sourcePackageId package)
destDir = outputDir </> packageName
fmap catMaybes $ for (haddockInterfaces package) $ \interfacePath -> do
Expand Down Expand Up @@ -235,7 +242,12 @@ haddockProjectAction flags _extraArgs globalFlags = do
, interfacePath
, Visible
)]
False -> return []
False -> do
warn verbosity
("haddocks of "
++ show unitId
++ " not found in the store")
return []
False | not localStyle ->
return []
False -> do
Expand All @@ -257,7 +269,12 @@ haddockProjectAction flags _extraArgs globalFlags = do
, interfacePath
, Hidden
)]
False -> return []
False -> do
warn verbosity
("haddocks of "
++ show unitId
++ " not found in the store")
return []

--
-- generate index, content, etc.
Expand Down

0 comments on commit e0f6a5f

Please sign in to comment.