From 2f22bd4573586bf1aee486140db398bf92256b22 Mon Sep 17 00:00:00 2001 From: Ranjeet Kumar Ranjan Date: Wed, 29 Mar 2023 11:00:24 +0530 Subject: [PATCH 1/4] Fix Unknown targets error --- bench-report.cabal | 1 + lib/BenchRunner.hs | 5 +++-- lib/BuildLib.hs | 26 +++++++++++++++++++------- lib/TestRunner.hs | 5 +++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/bench-report.cabal b/bench-report.cabal index 03f361b..f812e13 100644 --- a/bench-report.cabal +++ b/bench-report.cabal @@ -29,6 +29,7 @@ common compile-options -Wno-all-missed-specialisations default-extensions: TemplateHaskell , QuasiQuotes + , ScopedTypeVariables default-language: Haskell2010 library diff --git a/lib/BenchRunner.hs b/lib/BenchRunner.hs index fb03770..d485211 100644 --- a/lib/BenchRunner.hs +++ b/lib/BenchRunner.hs @@ -407,9 +407,10 @@ runMeasurements targets = do if commitCompare then runBenchesComparing targets else do - liftIO $ runBuild buildBench benchPackageName "bench" targets + buildableTargets <- + liftIO $ runBuild buildBench benchPackageName "bench" targets -- XXX What is target_exe_extra_args here? - runBenchTargets benchPackageName "b" targets + runBenchTargets benchPackageName "b" buildableTargets runReports :: [String] -> Context () runReports benchmarks = do diff --git a/lib/BuildLib.hs b/lib/BuildLib.hs index 109e457..fd9b4a1 100644 --- a/lib/BuildLib.hs +++ b/lib/BuildLib.hs @@ -27,14 +27,16 @@ module BuildLib -- Imports -------------------------------------------------------------------------------- +import Control.Exception (catch) import Control.Monad (unless) import Control.Monad.IO.Class (MonadIO(..)) import Control.Monad.Trans.Reader (ReaderT, asks) import Data.List (nub, sort, intercalate, isSuffixOf) import Data.Map (Map) -import Data.Maybe (mapMaybe) +import Data.Maybe (catMaybes, mapMaybe) import Streamly.Coreutils.Which (which) import Streamly.Internal.Unicode.String (str) +import Streamly.System.Process (ProcessFailure) import qualified Data.List as List import qualified Data.Map as Map @@ -258,9 +260,19 @@ getCabalExe = do getGhcVersion :: String -> IO String getGhcVersion ghc = liftIO $ toLastLine [str|#{ghc} --numeric-version|] -runBuild :: String -> String -> String -> [String] -> IO () -runBuild buildProg package componentPrefix components = do - let componentsWithContext = - map (\c -> [str|#{package}:#{componentPrefix}:#{c}|]) components - componentsWithContextStr = unwords componentsWithContext - toStdoutV [str|#{buildProg} #{componentsWithContextStr}|] +runBuild :: String -> String -> String -> [String] -> IO [String] +runBuild buildProg package componentPrefix components = + catMaybes <$> mapM action components + + where + + actionBuildTarget c = do + toStdoutV [str|#{buildProg} #{package}:#{componentPrefix}:#{c}|] + return (Just c) + + actionOnError c = do + print $ "Warning: Target does not exist:" ++ c + return Nothing + + action c = + catch (actionBuildTarget c) (\(_ :: ProcessFailure) -> actionOnError c) diff --git a/lib/TestRunner.hs b/lib/TestRunner.hs index 93e0bb9..2962ade 100644 --- a/lib/TestRunner.hs +++ b/lib/TestRunner.hs @@ -261,13 +261,14 @@ runMeasurements :: [String] -> Context () runMeasurements targets = do buildCmd <- getBuildCommand benchPackageName <- asks bconfig_BENCHMARK_PACKAGE_NAME - liftIO $ runBuild buildCmd benchPackageName "test" targets + buildableTargets <- + liftIO $ runBuild buildCmd benchPackageName "test" targets coverage <- asks bconfig_COVERAGE when coverage $ do buildDir <- asks bconfig_BUILD_DIR liftIO $ toStdout [str|mkdir -p #{buildDir}/hpc|] - runBenchTargets benchPackageName "t" targets + runBenchTargets benchPackageName "t" buildableTargets ------------------------------------------------------------------------------- -- Build and run targets From 33ddff32173f2117f793d8b30efa89f40d55800d Mon Sep 17 00:00:00 2001 From: Ranjeet Kumar Ranjan Date: Wed, 29 Mar 2023 11:28:07 +0530 Subject: [PATCH 2/4] Fixup --- lib/BuildLib.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/BuildLib.hs b/lib/BuildLib.hs index fd9b4a1..1553c7d 100644 --- a/lib/BuildLib.hs +++ b/lib/BuildLib.hs @@ -272,7 +272,8 @@ runBuild buildProg package componentPrefix components = actionOnError c = do print $ "Warning: Target does not exist:" ++ c - return Nothing + error $ "Error: Target does not exist:" ++ c + --return Nothing action c = catch (actionBuildTarget c) (\(_ :: ProcessFailure) -> actionOnError c) From 376a6b1e202e7d90fd8ea5e1293cf226ef36ca62 Mon Sep 17 00:00:00 2001 From: Ranjeet Kumar Ranjan Date: Wed, 29 Mar 2023 11:34:30 +0530 Subject: [PATCH 3/4] Fix up --- lib/BuildLib.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/BuildLib.hs b/lib/BuildLib.hs index 1553c7d..d152c8d 100644 --- a/lib/BuildLib.hs +++ b/lib/BuildLib.hs @@ -28,6 +28,7 @@ module BuildLib -------------------------------------------------------------------------------- import Control.Exception (catch) +import Control.Monad.Catch (throwM) import Control.Monad (unless) import Control.Monad.IO.Class (MonadIO(..)) import Control.Monad.Trans.Reader (ReaderT, asks) @@ -36,7 +37,7 @@ import Data.Map (Map) import Data.Maybe (catMaybes, mapMaybe) import Streamly.Coreutils.Which (which) import Streamly.Internal.Unicode.String (str) -import Streamly.System.Process (ProcessFailure) +import Streamly.System.Process (ProcessFailure(..)) import qualified Data.List as List import qualified Data.Map as Map @@ -273,6 +274,7 @@ runBuild buildProg package componentPrefix components = actionOnError c = do print $ "Warning: Target does not exist:" ++ c error $ "Error: Target does not exist:" ++ c + throwM $ ProcessFailure 2 --return Nothing action c = From e5bc63873e4d44815f86790d196124aa74713fe1 Mon Sep 17 00:00:00 2001 From: Ranjeet Kumar Ranjan Date: Wed, 29 Mar 2023 11:37:56 +0530 Subject: [PATCH 4/4] Fix up --- lib/BuildLib.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/BuildLib.hs b/lib/BuildLib.hs index d152c8d..4565db3 100644 --- a/lib/BuildLib.hs +++ b/lib/BuildLib.hs @@ -272,8 +272,7 @@ runBuild buildProg package componentPrefix components = return (Just c) actionOnError c = do - print $ "Warning: Target does not exist:" ++ c - error $ "Error: Target does not exist:" ++ c + --print $ "Warning: Target does not exist:" ++ c throwM $ ProcessFailure 2 --return Nothing