2 {-# LANGUAGE DeriveDataTypeable #-}
3 {-# LANGUAGE DeriveGeneric #-}
4 {-# LANGUAGE FlexibleContexts #-}
5 {-# LANGUAGE RankNTypes #-}
7 -----------------------------------------------------------------------------
10 -- Module : Distribution.Simple.Benchmark
11 -- Copyright : Isaac Jones 2003-2004
15 -- Maintainer : cabal-devel@haskell.org
16 -- Portability : portable
18 -- Definition of the benchmarking command-line options.
19 -- See: @Distribution.Simple.Setup@
20 module Distribution
.Simple
.Setup
.Benchmark
23 , defaultBenchmarkFlags
28 import Distribution
.Compat
.Prelude
hiding (get
)
31 import Distribution
.Simple
.Command
hiding (boolOpt
, boolOpt
')
32 import Distribution
.Simple
.Flag
33 import Distribution
.Simple
.InstallDirs
34 import Distribution
.Simple
.Utils
35 import Distribution
.Verbosity
37 import Distribution
.Simple
.Setup
.Common
39 -- ------------------------------------------------------------
43 -- ------------------------------------------------------------
45 data BenchmarkFlags
= BenchmarkFlags
46 { benchmarkDistPref
:: Flag
FilePath
47 , benchmarkVerbosity
:: Flag Verbosity
48 , benchmarkOptions
:: [PathTemplate
]
50 deriving (Show, Generic
, Typeable
)
52 instance Binary BenchmarkFlags
53 instance Structured BenchmarkFlags
55 defaultBenchmarkFlags
:: BenchmarkFlags
56 defaultBenchmarkFlags
=
58 { benchmarkDistPref
= NoFlag
59 , benchmarkVerbosity
= Flag normal
60 , benchmarkOptions
= []
63 benchmarkCommand
:: CommandUI BenchmarkFlags
66 { commandName
= "bench"
68 "Run all/specific benchmarks."
69 , commandDescription
= Just
$ \_pname
->
71 testOrBenchmarkHelpText
"benchmark"
72 , commandNotes
= Nothing
77 , "BENCHCOMPONENTS [FLAGS]"
79 , commandDefaultFlags
= defaultBenchmarkFlags
80 , commandOptions
= benchmarkOptions
'
83 benchmarkOptions
' :: ShowOrParseArgs
-> [OptionField BenchmarkFlags
]
84 benchmarkOptions
' showOrParseArgs
=
87 (\v flags
-> flags
{benchmarkVerbosity
= v
})
90 (\d flags
-> flags
{benchmarkDistPref
= d
})
95 ( "give extra options to benchmark executables "
96 ++ "(name templates can use $pkgid, $compiler, "
97 ++ "$os, $arch, $benchmark)"
100 (\v flags
-> flags
{benchmarkOptions
= v
})
103 (map toPathTemplate
. splitArgs
)
109 ( "give extra option to benchmark executables "
110 ++ "(no need to quote options containing spaces, "
111 ++ "name template can use $pkgid, $compiler, "
112 ++ "$os, $arch, $benchmark)"
115 (\v flags
-> flags
{benchmarkOptions
= v
})
118 (\x
-> [toPathTemplate x
])
119 (map fromPathTemplate
)
123 emptyBenchmarkFlags
:: BenchmarkFlags
124 emptyBenchmarkFlags
= mempty
126 instance Monoid BenchmarkFlags
where
130 instance Semigroup BenchmarkFlags
where