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..4565db3 100644 --- a/lib/BuildLib.hs +++ b/lib/BuildLib.hs @@ -27,14 +27,17 @@ module BuildLib -- Imports -------------------------------------------------------------------------------- +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) 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 +261,20 @@ 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 + throwM $ ProcessFailure 2 + --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