From 446975f8ba02f18f6dbde653b2f98f6db8f54722 Mon Sep 17 00:00:00 2001
From: Marcin Szamotulski <coot@coot.me>
Date: Tue, 18 Jun 2024 09:59:47 +0200
Subject: [PATCH] haddock-project: copy extra-doc-files to the right directory

When running haddock-project `extra-doc-files` should be copied to
a subdirectories of the `argOutputDir` corresponding to the component.
This doesn't affect `haddock` command.
---
 Cabal/src/Distribution/Simple/Haddock.hs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Cabal/src/Distribution/Simple/Haddock.hs b/Cabal/src/Distribution/Simple/Haddock.hs
index ab3c3fd1d8..f7d47676e5 100644
--- a/Cabal/src/Distribution/Simple/Haddock.hs
+++ b/Cabal/src/Distribution/Simple/Haddock.hs
@@ -485,8 +485,9 @@ haddock_setupHooks
 
     for_ (extraDocFiles pkg_descr) $ \fpath -> do
       files <- matchDirFileGlob verbosity (specVersion pkg_descr) mbWorkDir fpath
+      let targetDir = Dir $ unDir' (argOutputDir commonArgs) </> haddockDirName haddockTarget pkg_descr
       for_ files $
-        copyFileToCwd verbosity mbWorkDir (unDir $ argOutputDir commonArgs)
+        copyFileToCwd verbosity mbWorkDir (unDir targetDir)
 
 -- | Execute 'Haddock' configured with 'HaddocksFlags'.  It is used to build
 -- index and contents for documentation of multiple packages.
-- 
GitLab