diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index 3cb0d8033e8..5cb04eaf56b 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -258,7 +258,7 @@ sanityCheckElaboratedConfiguredPackage -> a -> a sanityCheckElaboratedConfiguredPackage - _sharedConfig + sharedConfig elab@ElaboratedConfiguredPackage{..} = ( case elabPkgOrComp of ElabPackage pkg -> sanityCheckElaboratedPackage elab pkg @@ -273,10 +273,12 @@ sanityCheckElaboratedConfiguredPackage -- 'installedPackageId' we assigned is consistent with -- the 'hashedInstalledPackageId' we would compute from -- the elaborated configured package - -- . assert (isInplaceBuildStyle elabBuildStyle || - -- elabComponentId == hashedInstalledPackageId - -- (packageHashInputs sharedConfig elab)) - + . assert + ( isInplaceBuildStyle elabBuildStyle + || elabComponentId + == hashedInstalledPackageId + (packageHashInputs sharedConfig elab) + ) -- the stanzas explicitly disabled should not be available . assert ( optStanzaSetNull $ @@ -3293,9 +3295,7 @@ pruneInstallPlanPass1 pkgs prune :: ElaboratedConfiguredPackage -> PrunedPackage prune elab = PrunedPackage elab' (pruneOptionalDependencies elab') where - elab' = - setDocumentation $ - addOptionalStanzas elab + elab' = addOptionalStanzas elab graph = Graph.fromDistinctList pkgs' @@ -3444,24 +3444,6 @@ pruneInstallPlanPass1 pkgs <> optionalStanzasWithDepsAvailable availablePkgs elab pkg addOptionalStanzas elab = elab - setDocumentation :: ElaboratedConfiguredPackage -> ElaboratedConfiguredPackage - setDocumentation elab@ElaboratedConfiguredPackage{elabPkgOrComp = ElabComponent comp} = - elab - { elabBuildHaddocks = - elabBuildHaddocks elab && documentationEnabled (compSolverName comp) elab - } - where - documentationEnabled c = - case c of - CD.ComponentLib -> const True - CD.ComponentSubLib _ -> elabHaddockInternal - CD.ComponentFLib _ -> elabHaddockForeignLibs - CD.ComponentExe _ -> elabHaddockExecutables - CD.ComponentTest _ -> elabHaddockTestSuites - CD.ComponentBench _ -> elabHaddockBenchmarks - CD.ComponentSetup -> const False - setDocumentation elab = elab - -- Calculate package dependencies but cut out those needed only by -- optional stanzas that we've determined we will not enable. -- These pruned deps are not persisted in this pass since they're based on diff --git a/cabal-testsuite/PackageTests/HaddockBuildDepends/a.cabal b/cabal-testsuite/PackageTests/HaddockBuildDepends/a.cabal new file mode 100644 index 00000000000..552ef337ea6 --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockBuildDepends/a.cabal @@ -0,0 +1,10 @@ +name: a +version: 0.1.0.0 +build-type: Simple +cabal-version: >= 1.10 + +library + exposed-modules: MyLib + build-depends: base, lib + hs-source-dirs: src + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/HaddockBuildDepends/cabal.project b/cabal-testsuite/PackageTests/HaddockBuildDepends/cabal.project new file mode 100644 index 00000000000..e6fdbadb439 --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockBuildDepends/cabal.project @@ -0,0 +1 @@ +packages: . diff --git a/cabal-testsuite/PackageTests/HaddockBuildDepends/cabal.test.hs b/cabal-testsuite/PackageTests/HaddockBuildDepends/cabal.test.hs new file mode 100644 index 00000000000..28821c5e858 --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockBuildDepends/cabal.test.hs @@ -0,0 +1,22 @@ +import Test.Cabal.Prelude + + +main = cabalTest . withRepo "repo" $ do + cabal "build" ["--enable-documentation"] + + env <- getTestEnv + let storeDir = testCabalDir env "store" + + -- Check properties of executable component + libDir <- liftIO $ findDependencyInStore storeDir "exe" + -- Documentation is enabled.. + assertFileDoesContain (libDir "cabal-hash.txt") "documentation: True" + -- But not built + shouldDirectoryNotExist ( libDir "share" "doc" ) + + -- Check properties of library + libDir <- liftIO $ findDependencyInStore storeDir "lib" + -- Documentation is enabled.. + assertFileDoesContain (libDir "cabal-hash.txt") "documentation: True" + -- and has been built + shouldDirectoryExist ( libDir "share" "doc" ) diff --git a/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/exe-1/Main.hs b/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/exe-1/Main.hs new file mode 100644 index 00000000000..de106fe48f9 --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/exe-1/Main.hs @@ -0,0 +1,3 @@ +module Main where + +main = return () diff --git a/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/exe-1/exe.cabal b/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/exe-1/exe.cabal new file mode 100644 index 00000000000..a5c1b537d7b --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/exe-1/exe.cabal @@ -0,0 +1,12 @@ +name: exe +version: 1 +license: BSD3 +author: Edward Z. Yang +maintainer: ezyang@cs.stanford.edu +build-type: Simple +cabal-version: 2.0 + +executable exe + build-depends: base + main-is: Main.hs + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/lib-1/Lib.hs b/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/lib-1/Lib.hs new file mode 100644 index 00000000000..6d85a26fe10 --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/lib-1/Lib.hs @@ -0,0 +1 @@ +module Lib where diff --git a/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/lib-1/lib.cabal b/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/lib-1/lib.cabal new file mode 100644 index 00000000000..526338f344f --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockBuildDepends/repo/lib-1/lib.cabal @@ -0,0 +1,13 @@ +name: lib +version: 1 +license: BSD3 +author: Edward Z. Yang +maintainer: ezyang@cs.stanford.edu +build-type: Simple +cabal-version: 2.0 + +library + build-depends: base + build-tool-depends: exe:exe + exposed-modules: Lib + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/HaddockBuildDepends/src/MyLib.hs b/cabal-testsuite/PackageTests/HaddockBuildDepends/src/MyLib.hs new file mode 100644 index 00000000000..bbaef0a6d64 --- /dev/null +++ b/cabal-testsuite/PackageTests/HaddockBuildDepends/src/MyLib.hs @@ -0,0 +1,4 @@ +module MyLib (someFunc) where + +someFunc :: IO () +someFunc = return ()