Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Unknown targets error #41

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
Expand Down
28 changes: 21 additions & 7 deletions lib/BuildLib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
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