From 52b0c314d182de512c3293c6ac9b0186efbebc6f Mon Sep 17 00:00:00 2001 From: sterni Date: Tue, 18 Aug 2026 12:45:21 +0200 Subject: [PATCH] Make Setup.hs compatible with Cabal >= 3.18 --- Setup.hs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Setup.hs b/Setup.hs index ab6c51c..c7d2309 100644 --- a/Setup.hs +++ b/Setup.hs @@ -26,11 +26,15 @@ main = defaultMainWithHooks hk compileCheck :: FilePath -> String -> String -> String -> IO Bool compileCheck cc testName message sourceCode = do - withTempDirectory normal "" testName $ \tmpDir -> do - writeFile (tmpDir ++ "/" ++ testName ++ ".c") sourceCode - ec <- myRawSystemExitCode normal cc [tmpDir testName ++ ".c", "-o", tmpDir ++ "/a","-no-hs-main"] - notice normal $ message ++ show (ec == ExitSuccess) - return (ec == ExitSuccess) + withTempDirectory +#if !MIN_VERSION_Cabal(3,18,0) + myNormal +#endif + "" testName $ \tmpDir -> do + writeFile (tmpDir ++ "/" ++ testName ++ ".c") sourceCode + ec <- myRawSystemExitCode myNormal cc [tmpDir testName ++ ".c", "-o", tmpDir ++ "/a","-no-hs-main"] + notice myNormal $ message ++ show (ec == ExitSuccess) + return (ec == ExitSuccess) addOptions :: [String] -> [String] -> LocalBuildInfo -> LocalBuildInfo addOptions cArgs hsArgs lbi = lbi {withPrograms = newWithPrograms } @@ -131,3 +135,10 @@ myRawSystemExitCode verbosity path args = do | verbosity >= verbose = putStrLn $ unwords (path : args) | otherwise = return () #endif + +myNormal :: Verbosity +#if MIN_VERSION_Cabal(3,18,0) +myNormal = mkVerbosity defaultVerbosityHandles normal +#else +myNormal = normal +#endif