diff --git a/bench-report.cabal b/bench-report.cabal index a389abb..103472c 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 1e202ec..9d8babf 100644 --- a/lib/BenchRunner.hs +++ b/lib/BenchRunner.hs @@ -398,9 +398,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 cdf8df4..477f1ee 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