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 authored and ulysses4ever committed Jul 5, 2023
1 parent 1b89c1b commit 2c597e8
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions cabal-install/src/Distribution/Client/CmdHaddockProject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ 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 @@ -218,6 +221,17 @@ 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 @@ -237,8 +251,8 @@ haddockProjectAction flags _extraArgs globalFlags = do
| 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 @@ -283,7 +297,12 @@ haddockProjectAction flags _extraArgs globalFlags = do
, Visible
)
]
False -> return []
False -> do
warn verbosity
("haddocks of "
++ show unitId
++ " not found in the store")
return []
False
| not localStyle ->
return []
Expand Down Expand Up @@ -314,7 +333,12 @@ haddockProjectAction flags _extraArgs globalFlags = do
, 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 2c597e8

Please sign in to comment.