Skip to content

Commit

Permalink
Add a flag to optionally depend on Chart and friends
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyaov committed Jan 30, 2022
1 parent 975d5f9 commit b27451f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
13 changes: 13 additions & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ import Options.Applicative.Simple (addCommand, simpleOptions, simpleVersion)
import Paths_bench_show (version)

import Options.Applicative

#ifndef NO_CHARTS
import BenchShow
#else
import BenchShow.Internal.Common
import BenchShow.Internal.Report
#endif

-- The command line interface provides subcommands for each task. There are
-- some common options that apply to all subcommands. Subcommands may have
Expand Down Expand Up @@ -143,6 +149,8 @@ cmdReport ReportOpts{..} cfg = report reportInput reportOutput cfg
-- "graph" subcommand
-------------------------------------------------------------------------------

#ifndef NO_CHARTS

data GraphOpts = GraphOpts
{ graphInput :: FilePath
, graphOutput :: FilePath
Expand All @@ -159,6 +167,8 @@ pGraphOpts = GraphOpts
cmdGraph :: GraphOpts -> Config -> IO ()
cmdGraph GraphOpts{..} cfg = graph graphInput graphOutput cfg

#endif

-------------------------------------------------------------------------------
-- Build and run a subcommand parser
-------------------------------------------------------------------------------
Expand All @@ -177,10 +187,13 @@ cmdLineParser p = do
"Generate a text report"
cmdReport
pReportOpts

#ifndef NO_CHARTS
addCommand "graph"
"Generate a graphical report"
cmdGraph
pGraphOpts
#endif

main :: IO ()
main = cmdLineParser pConfig
26 changes: 20 additions & 6 deletions bench-show.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ source-repository head
type: git
location: https://github.com/composewell/bench-show

flag no-charts
description: Don't build the modules that provide charting functionality
manual: True
default: False

library
hs-source-dirs: lib
exposed-modules: BenchShow
, BenchShow.Tutorial
, BenchShow.Internal.Analysis
exposed-modules: BenchShow.Internal.Analysis
, BenchShow.Internal.Common
, BenchShow.Internal.Graph
, BenchShow.Internal.Report
default-language: Haskell2010
default-extensions:
Expand All @@ -111,8 +113,6 @@ library
ghc-options: -Wall
build-depends:
base >= 4.8 && < 5
, Chart >= 1.6 && < 2
, Chart-diagrams >= 1.6 && < 2
, csv >= 0.1 && < 0.2
, filepath >= 1.3 && < 1.5
, mwc-random >= 0.13 && < 0.16
Expand All @@ -122,6 +122,13 @@ library
, split >= 0.2 && < 0.3
, statistics >= 0.15 && < 0.17
, vector >= 0.10 && < 0.13
if !flag(no-charts)
exposed-modules: BenchShow
BenchShow.Tutorial
BenchShow.Internal.Graph
build-depends:
Chart >= 1.6 && < 2
, Chart-diagrams >= 1.6 && < 2

executable bench-show
default-language: Haskell2010
Expand All @@ -134,8 +141,13 @@ executable bench-show
, optparse-applicative >= 0.14.2 && < 0.17
, optparse-simple >= 0.1.0 && < 0.2
, bench-show
if flag(no-charts)
cpp-options: -DNO_CHARTS


test-suite test
if flag(no-charts)
buildable: False
type: exitcode-stdio-1.0
default-language: Haskell2010
default-extensions:
Expand All @@ -153,6 +165,8 @@ test-suite test
-- , typed-process >= 0.1.0.0 && < 0.3

test-suite doc
if flag(no-charts)
buildable: False
type: exitcode-stdio-1.0
default-language: Haskell2010
default-extensions:
Expand Down

0 comments on commit b27451f

Please sign in to comment.