[Git][ghc/ghc][wip/t23273] hadrian: Pass haddock file arguments in a response file

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Wed Apr 19 11:01:37 UTC 2023



Matthew Pickering pushed to branch wip/t23273 at Glasgow Haskell Compiler / GHC


Commits:
c6469c70 by Matthew Pickering at 2023-04-19T12:01:15+01:00
hadrian: Pass haddock file arguments in a response file

In !10119 CI was failing on windows because the command line was too
long. We can mitigate this by passing the file arguments to haddock in a
response file.

We can't easily pass all the arguments in a response file because the
`+RTS` arguments can't be placed in the response file.

Fixes #23273

- - - - -


2 changed files:

- hadrian/src/Builder.hs
- hadrian/src/Settings/Builders/Haddock.hs


Changes:

=====================================
hadrian/src/Builder.hs
=====================================
@@ -41,6 +41,7 @@ import Packages
 import GHC.IO.Encoding (getFileSystemEncoding)
 import qualified Data.ByteString as BS
 import qualified GHC.Foreign as GHC
+import GHC.ResponseFile
 
 -- | C compiler can be used in two different modes:
 -- * Compile or preprocess a source file.
@@ -353,6 +354,8 @@ instance H.Builder Builder where
                     Exit _ <- cmd' [path] (buildArgs ++ [input])
                     return ()
 
+                Haddock {} -> runHaddock path buildArgs buildInputs
+
                 HsCpp    -> captureStdout
 
                 Make dir -> cmd' path ["-C", dir] buildArgs
@@ -385,6 +388,16 @@ instance H.Builder Builder where
 
                 _  -> cmd' [path] buildArgs
 
+-- | Invoke @haddock@ given a path to it and a list of arguments. The arguments
+-- are passed in a response file.
+runHaddock :: FilePath    -- ^ path to @haddock@
+      -> [String]
+      -> [FilePath]  -- ^ input file paths
+      -> Action ()
+runHaddock haddockPath flagArgs fileInputs = withTempFile $ \tmp -> do
+    writeFile' tmp $ escapeArgs fileInputs
+    cmd [haddockPath] flagArgs ('@' : tmp)
+
 -- TODO: Some builders are required only on certain platforms. For example,
 -- 'Objdump' is only required on OpenBSD and AIX. Add support for platform
 -- specific optional builders as soon as we can reliably test this feature.


=====================================
hadrian/src/Settings/Builders/Haddock.hs
=====================================
@@ -68,7 +68,6 @@ haddockBuilderArgs = mconcat
                      ++ "," ++ baseUrl p ++ "/src/%{MODULE}.html#%{NAME},"
                      ++ haddock | (p, haddock) <- haddocks_with_versions ]
             , pure [ "--optghc=" ++ opt | opt <- ghcOpts, not ("--package-db" `isInfixOf` opt) ]
-            , getInputs
             , arg "+RTS"
             , arg $ "-t" ++ (statsDir -/- pkgName pkg ++ ".t")
             , arg "--machine-readable"



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6469c703e7603b4229788c3beb2c79b43b6812f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c6469c703e7603b4229788c3beb2c79b43b6812f
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230419/638c06c6/attachment-0001.html>


More information about the ghc-commits mailing list