Skip to content

Commit b3e024a

Browse files
authored
Merge pull request #9446 from mpickering/wip/t6006
Fix assertion failure when combining build-tool-depends and --enable-documentation
2 parents 4d85411 + f82bf6a commit b3e024a

File tree

11 files changed

+104
-27
lines changed

11 files changed

+104
-27
lines changed

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

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ sanityCheckElaboratedConfiguredPackage
258258
-> a
259259
-> a
260260
sanityCheckElaboratedConfiguredPackage
261-
_sharedConfig
261+
sharedConfig
262262
elab@ElaboratedConfiguredPackage{..} =
263263
( case elabPkgOrComp of
264264
ElabPackage pkg -> sanityCheckElaboratedPackage elab pkg
@@ -273,10 +273,12 @@ sanityCheckElaboratedConfiguredPackage
273273
-- 'installedPackageId' we assigned is consistent with
274274
-- the 'hashedInstalledPackageId' we would compute from
275275
-- the elaborated configured package
276-
-- . assert (isInplaceBuildStyle elabBuildStyle ||
277-
-- elabComponentId == hashedInstalledPackageId
278-
-- (packageHashInputs sharedConfig elab))
279-
276+
. assert
277+
( isInplaceBuildStyle elabBuildStyle
278+
|| elabComponentId
279+
== hashedInstalledPackageId
280+
(packageHashInputs sharedConfig elab)
281+
)
280282
-- the stanzas explicitly disabled should not be available
281283
. assert
282284
( optStanzaSetNull $
@@ -3293,9 +3295,7 @@ pruneInstallPlanPass1 pkgs
32933295
prune :: ElaboratedConfiguredPackage -> PrunedPackage
32943296
prune elab = PrunedPackage elab' (pruneOptionalDependencies elab')
32953297
where
3296-
elab' =
3297-
setDocumentation $
3298-
addOptionalStanzas elab
3298+
elab' = addOptionalStanzas elab
32993299

33003300
graph = Graph.fromDistinctList pkgs'
33013301

@@ -3444,24 +3444,6 @@ pruneInstallPlanPass1 pkgs
34443444
<> optionalStanzasWithDepsAvailable availablePkgs elab pkg
34453445
addOptionalStanzas elab = elab
34463446

3447-
setDocumentation :: ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage
3448-
setDocumentation elab@ElaboratedConfiguredPackage{elabPkgOrComp = ElabComponent comp} =
3449-
elab
3450-
{ elabBuildHaddocks =
3451-
elabBuildHaddocks elab && documentationEnabled (compSolverName comp) elab
3452-
}
3453-
where
3454-
documentationEnabled c =
3455-
case c of
3456-
CD.ComponentLib -> const True
3457-
CD.ComponentSubLib _ -> elabHaddockInternal
3458-
CD.ComponentFLib _ -> elabHaddockForeignLibs
3459-
CD.ComponentExe _ -> elabHaddockExecutables
3460-
CD.ComponentTest _ -> elabHaddockTestSuites
3461-
CD.ComponentBench _ -> elabHaddockBenchmarks
3462-
CD.ComponentSetup -> const False
3463-
setDocumentation elab = elab
3464-
34653447
-- Calculate package dependencies but cut out those needed only by
34663448
-- optional stanzas that we've determined we will not enable.
34673449
-- These pruned deps are not persisted in this pass since they're based on
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: a
2+
version: 0.1.0.0
3+
build-type: Simple
4+
cabal-version: >= 1.10
5+
6+
library
7+
exposed-modules: MyLib
8+
build-depends: base, lib
9+
hs-source-dirs: src
10+
default-language: Haskell2010
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# cabal v2-update
2+
Downloading the latest package list from test-local-repo
3+
# cabal build
4+
Resolving dependencies...
5+
Build profile: -w ghc-<GHCVER> -O1
6+
In order, the following will be built:
7+
- exe-1 (exe:exe) (requires build)
8+
- lib-1 (lib) (requires build)
9+
- a-0.1.0.0 (lib) (first run)
10+
Configuring executable 'exe' for exe-1...
11+
Preprocessing executable 'exe' for exe-1...
12+
Building executable 'exe' for exe-1...
13+
Installing executable exe in <PATH>
14+
Warning: The directory <ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>/incoming/new-<RAND><ROOT>/cabal.dist/home/.cabal/store/ghc-<GHCVER>/<PACKAGE>-<HASH>/bin is not in the system search path.
15+
Configuring library for lib-1...
16+
Preprocessing library for lib-1...
17+
Building library for lib-1...
18+
Preprocessing library for lib-1...
19+
Running Haddock on library for lib-1...
20+
Documentation created: dist/doc/html/lib/
21+
Installing library in <PATH>
22+
Configuring library for a-0.1.0.0...
23+
Preprocessing library for a-0.1.0.0...
24+
Building library for a-0.1.0.0...
25+
Preprocessing library for a-0.1.0.0...
26+
Running Haddock on library for a-0.1.0.0...
27+
Documentation created: <ROOT>/cabal.dist/work/dist/build/<ARCH>/ghc-<GHCVER>/a-0.1.0.0/doc/html/a/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Test.Cabal.Prelude
2+
3+
4+
main = cabalTest . withRepo "repo" $ do
5+
cabal "build" ["--enable-documentation"]
6+
7+
env <- getTestEnv
8+
let storeDir = testCabalDir env </> "store"
9+
10+
-- Check properties of executable component
11+
libDir <- liftIO $ findDependencyInStore storeDir "exe"
12+
-- Documentation is enabled..
13+
assertFileDoesContain (libDir </> "cabal-hash.txt") "documentation: True"
14+
-- But not built
15+
shouldDirectoryNotExist ( libDir </> "share" </> "doc" )
16+
17+
-- Check properties of library
18+
libDir <- liftIO $ findDependencyInStore storeDir "lib"
19+
-- Documentation is enabled..
20+
assertFileDoesContain (libDir </> "cabal-hash.txt") "documentation: True"
21+
-- and has been built
22+
shouldDirectoryExist ( libDir </> "share" </> "doc" )
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Main where
2+
3+
main = return ()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: exe
2+
version: 1
3+
license: BSD3
4+
author: Edward Z. Yang
5+
maintainer: [email protected]
6+
build-type: Simple
7+
cabal-version: 2.0
8+
9+
executable exe
10+
build-depends: base
11+
main-is: Main.hs
12+
default-language: Haskell2010
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module Lib where
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: lib
2+
version: 1
3+
license: BSD3
4+
author: Edward Z. Yang
5+
maintainer: [email protected]
6+
build-type: Simple
7+
cabal-version: 2.0
8+
9+
library
10+
build-depends: base
11+
build-tool-depends: exe:exe
12+
exposed-modules: Lib
13+
default-language: Haskell2010
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module MyLib (someFunc) where
2+
3+
someFunc :: IO ()
4+
someFunc = return ()

0 commit comments

Comments
 (0)