Skip to content
Snippets Groups Projects
Commit e61d8dd2 authored by Randy Polen's avatar Randy Polen
Browse files

Propose code for supporting haddock response files

This change is for adding the ehancement to support haddock
response files.  This is what was used to build HP 7.10.2
for Windows, but it does need a corresponding change in
haddock to utilize it. Hopefully, this and its corresponding
haddock change can make it into the next ghc release and
eliminate much gnashing of teeth, error prone, and time
consuming manual steps in the HP build process.

Modified:

* Cabal/Distribution/Simple/Haddock.hs
  * renderArgs function: I put a couple of things into locals
    since I needed another use for UTF8 support check, plus I
    added another check based on version; the temp file logic
    was just as the prologue case above but I did need to
    repeat the invocation of the 'k' function in order to
    keep the cases separate and allow proper handling of the
    temp file automatic (or not, per --keep-temp-files)
    deletion.  Important: the haddock version being check
    against for response file support, greater than 2.16.1,
    is a placeholder and may or may not be the actual value
    since that will depend on the as-yet-unreleased haddock
    (which looks like it may be >2.16.1 but at this moment is
    not released).
parent c14ba817
No related branches found
No related tags found
No related merge requests found
......@@ -466,15 +466,28 @@ renderArgs :: Verbosity
-> (([String], FilePath) -> IO a)
-> IO a
renderArgs verbosity tmpFileOpts version comp args k = do
let haddockSupportsUTF8 = version >= Version [2,14,4] []
haddockSupportsResponseFiles = version > Version [2,16,1] []
createDirectoryIfMissingVerbose verbosity True outputDir
withTempFileEx tmpFileOpts outputDir "haddock-prologue.txt" $
\prologueFileName h -> do
do
when (version >= Version [2,14,4] []) (hSetEncoding h utf8)
when haddockSupportsUTF8 (hSetEncoding h utf8)
hPutStrLn h $ fromFlag $ argPrologue args
hClose h
let pflag = "--prologue=" ++ prologueFileName
k (pflag : renderPureArgs version comp args, result)
renderedArgs = pflag : renderPureArgs version comp args
if haddockSupportsResponseFiles
then
withTempFileEx tmpFileOpts outputDir "haddock-response.txt" $
\responseFileName hf -> do
when haddockSupportsUTF8 (hSetEncoding hf utf8)
mapM_ (hPutStrLn hf) renderedArgs
hClose hf
let respFile = "@" ++ responseFileName
k ([respFile], result)
else
k (renderedArgs, result)
where
outputDir = (unDir $ argOutputDir args)
result = intercalate ", "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment