@@ -111,6 +111,13 @@ data StackBuildException
111111 [String ] -- cabal arguments
112112 (Maybe (Path Abs File )) -- logfiles location
113113 [Text ] -- log contents
114+ | SetupHsBuildFailure
115+ ExitCode
116+ (Maybe PackageIdentifier ) -- which package's custom setup, is simple setup if Nothing
117+ (Path Abs File ) -- ghc Executable
118+ [String ] -- ghc arguments
119+ (Maybe (Path Abs File )) -- logfiles location
120+ [Text ] -- log contents
114121 | ExecutionFailure [SomeException ]
115122 | LocalPackageDoesn'tMatchTarget
116123 PackageName
@@ -220,23 +227,9 @@ instance Show StackBuildException where
220227 " Unsupported test suite type: " <> show interface
221228 -- Supressing duplicate output
222229 show (CabalExitedUnsuccessfully exitCode taskProvides' execName fullArgs logFiles bss) =
223- let fullCmd = unwords
224- $ dropQuotes (toFilePath execName)
225- : map (T. unpack . showProcessArgDebug) fullArgs
226- logLocations = maybe " " (\ fp -> " \n Logs have been written to: " ++ toFilePath fp) logFiles
227- in " \n -- While building package " ++ dropQuotes (show taskProvides') ++ " using:\n " ++
228- " " ++ fullCmd ++ " \n " ++
229- " Process exited with code: " ++ show exitCode ++
230- (if exitCode == ExitFailure (- 9 )
231- then " (THIS MAY INDICATE OUT OF MEMORY)"
232- else " " ) ++
233- logLocations ++
234- (if null bss
235- then " "
236- else " \n\n " ++ doubleIndent (map T. unpack bss))
237- where
238- doubleIndent = dropWhileEnd isSpace . unlines . fmap (\ line -> " " ++ line)
239- dropQuotes = filter (' \" ' /= )
230+ showBuildError False exitCode (Just taskProvides') execName fullArgs logFiles bss
231+ show (SetupHsBuildFailure exitCode mtaskProvides execName fullArgs logFiles bss) =
232+ showBuildError True exitCode mtaskProvides execName fullArgs logFiles bss
240233 show (ExecutionFailure es) = intercalate " \n\n " $ map show es
241234 show (LocalPackageDoesn'tMatchTarget name localV requestedV) = concat
242235 [ " Version for local package "
@@ -338,6 +331,40 @@ missingExeError isSimpleBuildType msg =
338331 then []
339332 else [" The Setup.hs file is changing the installation target dir." ]
340333
334+ showBuildError
335+ :: Bool
336+ -> ExitCode
337+ -> Maybe PackageIdentifier
338+ -> Path Abs File
339+ -> [String ]
340+ -> Maybe (Path Abs File )
341+ -> [Text ]
342+ -> String
343+ showBuildError isBuildingSetup exitCode mtaskProvides execName fullArgs logFiles bss =
344+ let fullCmd = unwords
345+ $ dropQuotes (toFilePath execName)
346+ : map (T. unpack . showProcessArgDebug) fullArgs
347+ logLocations = maybe " " (\ fp -> " \n Logs have been written to: " ++ toFilePath fp) logFiles
348+ in " \n -- While building " ++
349+ (case (isBuildingSetup, mtaskProvides) of
350+ (False , Nothing ) -> error " Invariant violated: unexpected case in showBuildError"
351+ (False , Just taskProvides') -> " package " ++ dropQuotes (show taskProvides')
352+ (True , Nothing ) -> " simple Setup.hs"
353+ (True , Just taskProvides') -> " custom Setup.hs for package " ++ dropQuotes (show taskProvides')
354+ ) ++
355+ " using:\n " ++ fullCmd ++ " \n " ++
356+ " Process exited with code: " ++ show exitCode ++
357+ (if exitCode == ExitFailure (- 9 )
358+ then " (THIS MAY INDICATE OUT OF MEMORY)"
359+ else " " ) ++
360+ logLocations ++
361+ (if null bss
362+ then " "
363+ else " \n\n " ++ doubleIndent (map T. unpack bss))
364+ where
365+ doubleIndent = dropWhileEnd isSpace . unlines . fmap (\ line -> " " ++ line)
366+ dropQuotes = filter (' \" ' /= )
367+
341368instance Exception StackBuildException
342369
343370----------------------------------------------
0 commit comments