Commit 0f8c45b1 authored by cheecheeo's avatar cheecheeo
Browse files

Treat -O2 in ghc-options as a cabal check "warning"

parent cb3e1045
...@@ -108,6 +108,10 @@ data PackageCheck = ...@@ -108,6 +108,10 @@ data PackageCheck =
-- ban them entirely. -- ban them entirely.
| PackageDistSuspicious { explanation :: String } | PackageDistSuspicious { explanation :: String }
-- | Like PackageDistSuspicious but will only display warnings
-- rather than causing abnormal exit.
| PackageDistSuspiciousWarn { explanation :: String }
-- | An issue that is OK in the author's environment but is almost -- | An issue that is OK in the author's environment but is almost
-- certain to be a portability problem for other environments. We can -- certain to be a portability problem for other environments. We can
-- quite legitimately refuse to publicly distribute packages with these -- quite legitimately refuse to publicly distribute packages with these
...@@ -664,7 +668,7 @@ checkGhcOptions pkg = ...@@ -664,7 +668,7 @@ checkGhcOptions pkg =
++ "Setting it yourself interferes with the --disable-optimization flag." ++ "Setting it yourself interferes with the --disable-optimization flag."
, checkFlags ["-O2"] $ , checkFlags ["-O2"] $
PackageDistSuspicious $ PackageDistSuspiciousWarn $
"'ghc-options: -O2' is rarely needed. " "'ghc-options: -O2' is rarely needed. "
++ "Check that it is giving a real benefit " ++ "Check that it is giving a real benefit "
++ "and not just imposing longer compile times on your users." ++ "and not just imposing longer compile times on your users."
......
...@@ -455,8 +455,9 @@ printPackageProblems :: Verbosity -> PackageDescription -> IO () ...@@ -455,8 +455,9 @@ printPackageProblems :: Verbosity -> PackageDescription -> IO ()
printPackageProblems verbosity pkg_descr = do printPackageProblems verbosity pkg_descr = do
ioChecks <- checkPackageFiles pkg_descr "." ioChecks <- checkPackageFiles pkg_descr "."
let pureChecks = checkConfiguredPackage pkg_descr let pureChecks = checkConfiguredPackage pkg_descr
isDistError (PackageDistSuspicious _) = False isDistError (PackageDistSuspicious _) = False
isDistError _ = True isDistError (PackageDistSuspiciousWarn _) = False
isDistError _ = True
(errors, warnings) = partition isDistError (pureChecks ++ ioChecks) (errors, warnings) = partition isDistError (pureChecks ++ ioChecks)
unless (null errors) $ unless (null errors) $
notice verbosity $ "Distribution quality errors:\n" notice verbosity $ "Distribution quality errors:\n"
......
...@@ -50,6 +50,7 @@ check verbosity = do ...@@ -50,6 +50,7 @@ check verbosity = do
buildImpossible = [ x | x@PackageBuildImpossible {} <- packageChecks ] buildImpossible = [ x | x@PackageBuildImpossible {} <- packageChecks ]
buildWarning = [ x | x@PackageBuildWarning {} <- packageChecks ] buildWarning = [ x | x@PackageBuildWarning {} <- packageChecks ]
distSuspicious = [ x | x@PackageDistSuspicious {} <- packageChecks ] distSuspicious = [ x | x@PackageDistSuspicious {} <- packageChecks ]
++ [ x | x@PackageDistSuspiciousWarn {} <- packageChecks ]
distInexusable = [ x | x@PackageDistInexcusable {} <- packageChecks ] distInexusable = [ x | x@PackageDistInexcusable {} <- packageChecks ]
unless (null buildImpossible) $ do unless (null buildImpossible) $ do
...@@ -68,8 +69,11 @@ check verbosity = do ...@@ -68,8 +69,11 @@ check verbosity = do
putStrLn "The following errors will cause portability problems on other environments:" putStrLn "The following errors will cause portability problems on other environments:"
printCheckMessages distInexusable printCheckMessages distInexusable
let isDistError (PackageDistSuspicious {}) = False let isDistError (PackageDistSuspicious {}) = False
isDistError _ = True isDistError (PackageDistSuspiciousWarn {}) = False
isDistError _ = True
isCheckError (PackageDistSuspiciousWarn {}) = False
isCheckError _ = True
errors = filter isDistError packageChecks errors = filter isDistError packageChecks
unless (null errors) $ unless (null errors) $
...@@ -78,7 +82,7 @@ check verbosity = do ...@@ -78,7 +82,7 @@ check verbosity = do
when (null packageChecks) $ when (null packageChecks) $
putStrLn "No errors or warnings could be found in the package." putStrLn "No errors or warnings could be found in the package."
return (null packageChecks) return (null . filter isCheckError $ packageChecks)
where where
printCheckMessages = mapM_ (putStrLn . format . explanation) printCheckMessages = mapM_ (putStrLn . format . explanation)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment