Skip to content

Commit 929a52f

Browse files
committed
Hi Haddock: don't try to copy artifacts that don't exist
1 parent ffaa46b commit 929a52f

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

Cabal/src/Distribution/Simple/Haddock.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,13 @@ reusingGHCCompilationArtifacts verbosity tmpFileOpts mbWorkDir lbi bi clbi versi
10711071
let
10721072
vanillaOpts = componentGhcOptions normal lbi bi clbi (buildDir lbi)
10731073
i = interpretSymbolicPath mbWorkDir
1074-
copyDir ghcDir tmpDir = copyDirectoryRecursive verbosity (i $ fromFlag $ ghcDir vanillaOpts) (i tmpDir)
1074+
copyDir getGhcDir tmpDir = do
1075+
let ghcDir = i $ fromFlag $ getGhcDir vanillaOpts
1076+
ghcDirExists <- doesDirectoryExist ghcDir
1077+
-- Don't try to copy artifacts if they don't exist, e.g. if
1078+
-- we have not yet run the 'build' command.
1079+
when ghcDirExists $
1080+
copyDirectoryRecursive verbosity ghcDir (i tmpDir)
10751081
copyDir ghcOptObjDir tmpObjDir
10761082
copyDir ghcOptHiDir tmpHiDir
10771083
-- copyDir ghcOptStubDir tmpStubDir -- (see W.1 in Note [Hi Haddock Recompilation Avoidance])
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
9+
hs-source-dirs: src
10+
default-language: Haskell2010
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Test.Cabal.Prelude
2+
3+
import System.Directory
4+
import System.FilePath
5+
6+
main = setupTest . recordMode DoNotRecord $ do
7+
workDir <- fmap testWorkDir getTestEnv
8+
setup "configure" []
9+
setup "build" []
10+
liftIO $ removeDirectoryRecursive $ workDir </> "work" </> "dist" </> "build"
11+
setup "haddock" []
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module MyLib where
2+
3+
-- | Some docs
4+
foo :: Int
5+
foo = 3
6+
7+
-- | More docs
8+
data A = A Int -- ^ field

changelog.d/pr-10992.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
synopsis: "Haddock: don't try to copy build dir if it doesn't exist"
3+
packages: [Cabal]
4+
prs: 10992
5+
issues: [11001]
6+
---
7+
8+
This small patch fixes a little oversight in 'reusingGHCCompilationArtifacts',
9+
which would unconditionally attempt to copy over the GHC build artifacts to be
10+
re-used by Haddock, even when those artifacts did not exist (which caused
11+
an error).

0 commit comments

Comments
 (0)