2 {-# LANGUAGE DataKinds #-}
3 {-# LANGUAGE DeriveDataTypeable #-}
4 {-# LANGUAGE DeriveGeneric #-}
5 {-# LANGUAGE FlexibleContexts #-}
6 {-# LANGUAGE PatternSynonyms #-}
7 {-# LANGUAGE RankNTypes #-}
8 {-# LANGUAGE ViewPatterns #-}
10 -----------------------------------------------------------------------------
13 -- Module : Distribution.Simple.Benchmark
14 -- Copyright : Isaac Jones 2003-2004
18 -- Maintainer : cabal-devel@haskell.org
19 -- Portability : portable
21 -- Definition of the benchmarking command-line options.
22 -- See: @Distribution.Simple.Setup@
23 module Distribution
.Simple
.Setup
.Benchmark
25 ( BenchmarkCommonFlags
28 , benchmarkCabalFilePath
34 , defaultBenchmarkFlags
39 import Distribution
.Compat
.Prelude
hiding (get
)
42 import Distribution
.Simple
.Command
hiding (boolOpt
, boolOpt
')
43 import Distribution
.Simple
.InstallDirs
44 import Distribution
.Simple
.Setup
.Common
45 import Distribution
.Simple
.Utils
46 import Distribution
.Utils
.Path
47 import Distribution
.Verbosity
49 -- ------------------------------------------------------------
53 -- ------------------------------------------------------------
55 data BenchmarkFlags
= BenchmarkFlags
56 { benchmarkCommonFlags
:: !CommonSetupFlags
57 , benchmarkOptions
:: [PathTemplate
]
59 deriving (Show, Generic
, Typeable
)
61 pattern BenchmarkCommonFlags
63 -> Flag
(SymbolicPath Pkg
(Dir Dist
))
64 -> Flag
(SymbolicPath CWD
(Dir Pkg
))
65 -> Flag
(SymbolicPath Pkg File
)
68 pattern BenchmarkCommonFlags
72 , benchmarkCabalFilePath
75 ( benchmarkCommonFlags
->
77 { setupVerbosity
= benchmarkVerbosity
78 , setupDistPref
= benchmarkDistPref
79 , setupWorkingDir
= benchmarkWorkingDir
80 , setupCabalFilePath
= benchmarkCabalFilePath
81 , setupTargets
= benchmarkTargets
85 instance Binary BenchmarkFlags
86 instance Structured BenchmarkFlags
88 defaultBenchmarkFlags
:: BenchmarkFlags
89 defaultBenchmarkFlags
=
91 { benchmarkCommonFlags
= defaultCommonSetupFlags
92 , benchmarkOptions
= []
95 benchmarkCommand
:: CommandUI BenchmarkFlags
98 { commandName
= "bench"
100 "Run all/specific benchmarks."
101 , commandDescription
= Just
$ \_pname
->
103 testOrBenchmarkHelpText
"benchmark"
104 , commandNotes
= Nothing
109 , "BENCHCOMPONENTS [FLAGS]"
111 , commandDefaultFlags
= defaultBenchmarkFlags
112 , commandOptions
= benchmarkOptions
'
115 benchmarkOptions
' :: ShowOrParseArgs
-> [OptionField BenchmarkFlags
]
116 benchmarkOptions
' showOrParseArgs
=
117 withCommonSetupOptions
119 (\c f
-> f
{benchmarkCommonFlags
= c
})
123 ["benchmark-options"]
124 ( "give extra options to benchmark executables "
125 ++ "(name templates can use $pkgid, $compiler, "
126 ++ "$os, $arch, $benchmark)"
129 (\v flags
-> flags
{benchmarkOptions
= v
})
132 (map toPathTemplate
. splitArgs
)
138 ( "give extra option to benchmark executables "
139 ++ "(no need to quote options containing spaces, "
140 ++ "name template can use $pkgid, $compiler, "
141 ++ "$os, $arch, $benchmark)"
144 (\v flags
-> flags
{benchmarkOptions
= v
})
147 (\x
-> [toPathTemplate x
])
148 (map fromPathTemplate
)
152 emptyBenchmarkFlags
:: BenchmarkFlags
153 emptyBenchmarkFlags
= mempty
155 instance Monoid BenchmarkFlags
where
159 instance Semigroup BenchmarkFlags
where