Skip to content

Commit

Permalink
Warn instead of failing when an unbuildable target is encountered
Browse files Browse the repository at this point in the history
  • Loading branch information
rnjtranjan authored and adithyaov committed Aug 12, 2022
1 parent e65809b commit cee357f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions bench-report.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ common compile-options
-Wno-all-missed-specialisations
default-extensions: TemplateHaskell
, QuasiQuotes
, ScopedTypeVariables
default-language: Haskell2010

library
Expand Down
5 changes: 3 additions & 2 deletions lib/BenchRunner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 19 additions & 7 deletions lib/BuildLib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
5 changes: 3 additions & 2 deletions lib/TestRunner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cee357f

Please sign in to comment.