@@ -84,7 +84,7 @@ import qualified System.Directory as D
8484import System.Environment (getExecutablePath )
8585import System.Exit (ExitCode (ExitSuccess ))
8686import qualified System.FilePath as FP
87- import System.IO
87+ import System.IO ( hClose , hPutStr , hFlush , stderr , stdout )
8888import System.PosixCompat.Files (createLink )
8989import System.Process.Log (showProcessArgDebug , withProcessTimeLog )
9090import System.Process.Read
@@ -428,8 +428,8 @@ withExecuteEnv menv bopts boptsCli baseConfigOpts locals globalPackages snapshot
428428
429429 dumpLogIfWarning :: (Path Abs Dir , Path Abs File ) -> RIO env ()
430430 dumpLogIfWarning (pkgDir, filepath) = do
431- firstWarning <- runResourceT
432- $ transPipe liftResourceT ( CB. sourceFile (toFilePath filepath))
431+ firstWarning <- withBinaryFile (toFilePath filepath) ReadMode $ \ h ->
432+ CB. sourceHandle h
433433 $$ CT. decodeUtf8Lenient
434434 =$ CT. lines
435435 =$ CL. map stripCR
@@ -445,8 +445,8 @@ withExecuteEnv menv bopts boptsCli baseConfigOpts locals globalPackages snapshot
445445 dumpLog msgSuffix (pkgDir, filepath) = do
446446 logInfo $ T. pack $ concat [" \n -- Dumping log file" , msgSuffix, " : " , toFilePath filepath, " \n " ]
447447 compilerVer <- view actualCompilerVersionL
448- runResourceT
449- $ transPipe liftResourceT ( CB. sourceFile (toFilePath filepath))
448+ withBinaryFile (toFilePath filepath) ReadMode $ \ h ->
449+ CB. sourceHandle h
450450 $$ CT. decodeUtf8Lenient
451451 =$ mungeBuildOutput ExcludeTHLoading ConvertPathsToAbsolute pkgDir compilerVer
452452 =$ CL. mapM_ logInfo
@@ -935,10 +935,7 @@ withSingleContext runInBase ActionContext {..} ExecuteEnv {..} task@Task {..} md
935935 liftIO $ atomically $ writeTChan eeLogFiles (pkgDir, logPath)
936936 _ -> return ()
937937
938- bracket
939- (liftIO $ openBinaryFile fp WriteMode )
940- (liftIO . hClose)
941- $ \ h -> inner (Just (logPath, h))
938+ withBinaryFile fp WriteMode $ \ h -> inner (Just (logPath, h))
942939
943940 withCabal
944941 :: Package
@@ -1094,11 +1091,12 @@ withSingleContext runInBase ActionContext {..} ExecuteEnv {..} task@Task {..} md
10941091 Nothing -> return []
10951092 Just (logFile, h) -> do
10961093 liftIO $ hClose h
1097- runResourceT
1098- $ transPipe liftResourceT (CB. sourceFile (toFilePath logFile))
1099- =$= CT. decodeUtf8Lenient
1100- $$ mungeBuildOutput stripTHLoading makeAbsolute pkgDir compilerVer
1101- =$ CL. consume
1094+ withBinaryFile (toFilePath logFile) WriteMode $ \ h' ->
1095+ runConduit
1096+ $ CB. sourceHandle h'
1097+ .| CT. decodeUtf8Lenient
1098+ .| mungeBuildOutput stripTHLoading makeAbsolute pkgDir compilerVer
1099+ .| CL. consume
11021100 throwM $ SetupHsBuildFailure
11031101 ec
11041102 (Just taskProvides)
0 commit comments