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 defaultBenchmarkFlags
:: BenchmarkFlags
53 defaultBenchmarkFlags
=
55 { benchmarkDistPref
= NoFlag
56 , benchmarkVerbosity
= Flag normal
57 , benchmarkOptions
= []
60 benchmarkCommand
:: CommandUI BenchmarkFlags
63 { commandName
= "bench"
65 "Run all/specific benchmarks."
66 , commandDescription
= Just
$ \_pname
->
68 testOrBenchmarkHelpText
"benchmark"
69 , commandNotes
= Nothing
74 , "BENCHCOMPONENTS [FLAGS]"
76 , commandDefaultFlags
= defaultBenchmarkFlags
77 , commandOptions
= benchmarkOptions
'
80 benchmarkOptions
' :: ShowOrParseArgs
-> [OptionField BenchmarkFlags
]
81 benchmarkOptions
' showOrParseArgs
=
84 (\v flags
-> flags
{benchmarkVerbosity
= v
})
87 (\d flags
-> flags
{benchmarkDistPref
= d
})
92 ( "give extra options to benchmark executables "
93 ++ "(name templates can use $pkgid, $compiler, "
94 ++ "$os, $arch, $benchmark)"
97 (\v flags
-> flags
{benchmarkOptions
= v
})
100 (map toPathTemplate
. splitArgs
)
106 ( "give extra option to benchmark executables "
107 ++ "(no need to quote options containing spaces, "
108 ++ "name template can use $pkgid, $compiler, "
109 ++ "$os, $arch, $benchmark)"
112 (\v flags
-> flags
{benchmarkOptions
= v
})
115 (\x
-> [toPathTemplate x
])
116 (map fromPathTemplate
)
120 emptyBenchmarkFlags
:: BenchmarkFlags
121 emptyBenchmarkFlags
= mempty
123 instance Monoid BenchmarkFlags
where
127 instance Semigroup BenchmarkFlags
where