@@ -35,12 +35,15 @@ module Distribution.Client.Setup
35
35
, defaultConfigExFlags
36
36
, buildCommand
37
37
, BuildFlags (.. )
38
+ , filterBuildFlags
38
39
, filterTestFlags
39
40
, replCommand
41
+ , filterReplFlags
40
42
, testCommand
41
43
, benchmarkCommand
42
44
, testOptions
43
45
, benchmarkOptions
46
+ , filterBenchmarkFlags
44
47
, configureExOptions
45
48
, reconfigureCommand
46
49
, installCommand
@@ -87,7 +90,9 @@ module Distribution.Client.Setup
87
90
, haddockCommand
88
91
, cleanCommand
89
92
, copyCommand
93
+ , filterCopyFlags
90
94
, registerCommand
95
+ , filterRegisterFlags
91
96
, liftOptions
92
97
, yesNoOpt
93
98
) where
@@ -183,7 +188,7 @@ import Distribution.Simple.InstallDirs
183
188
)
184
189
import Distribution.Simple.Program (ProgramDb , defaultProgramDb )
185
190
import Distribution.Simple.Setup
186
- ( BenchmarkFlags
191
+ ( BenchmarkFlags ( benchmarkCommonFlags )
187
192
, BooleanFlag (.. )
188
193
, BuildFlags (.. )
189
194
, CleanFlags (.. )
@@ -192,7 +197,7 @@ import Distribution.Simple.Setup
192
197
, CopyFlags (.. )
193
198
, HaddockFlags (.. )
194
199
, RegisterFlags (.. )
195
- , ReplFlags
200
+ , ReplFlags ( .. )
196
201
, TestFlags
197
202
, boolOpt
198
203
, boolOpt'
@@ -1144,6 +1149,21 @@ buildCommand =
1144
1149
where
1145
1150
parent = Cabal. buildCommand defaultProgramDb
1146
1151
1152
+ -- | Given some 'BuildFlags' for the version of @Cabal@ that
1153
+ -- @cabal-install@ was built with, and a target older 'Version' of
1154
+ -- @Cabal@ that we want to pass these flags to, convert the
1155
+ -- flags into a form that will be accepted by the older
1156
+ -- @Setup@ script. Generally speaking, this just means filtering
1157
+ -- out flags that the old @Cabal@ library doesn't understand, but
1158
+ -- in some cases it may also mean "emulating" a feature using
1159
+ -- some more legacy flags.
1160
+ filterBuildFlags :: BuildFlags -> Version -> BuildFlags
1161
+ filterBuildFlags flags cabalLibVersion =
1162
+ flags
1163
+ { buildCommonFlags =
1164
+ filterCommonFlags (buildCommonFlags flags) cabalLibVersion
1165
+ }
1166
+
1147
1167
-- ------------------------------------------------------------
1148
1168
1149
1169
-- * Test flags
@@ -1236,6 +1256,21 @@ replCommand =
1236
1256
where
1237
1257
parent = Cabal. replCommand defaultProgramDb
1238
1258
1259
+ -- | Given some 'ReplFlags' for the version of @Cabal@ that
1260
+ -- @cabal-install@ was built with, and a target older 'Version' of
1261
+ -- @Cabal@ that we want to pass these flags to, convert the
1262
+ -- flags into a form that will be accepted by the older
1263
+ -- @Setup@ script. Generally speaking, this just means filtering
1264
+ -- out flags that the old @Cabal@ library doesn't understand, but
1265
+ -- in some cases it may also mean "emulating" a feature using
1266
+ -- some more legacy flags.
1267
+ filterReplFlags :: ReplFlags -> Version -> ReplFlags
1268
+ filterReplFlags flags cabalLibVersion =
1269
+ flags
1270
+ { replCommonFlags =
1271
+ filterCommonFlags (replCommonFlags flags) cabalLibVersion
1272
+ }
1273
+
1239
1274
-- ------------------------------------------------------------
1240
1275
1241
1276
-- * Test command
@@ -1331,6 +1366,21 @@ benchmarkCommand =
1331
1366
parent = Cabal. benchmarkCommand
1332
1367
progDb = defaultProgramDb
1333
1368
1369
+ -- | Given some 'BenchmarkFlags' for the version of @Cabal@ that
1370
+ -- @cabal-install@ was built with, and a target older 'Version' of
1371
+ -- @Cabal@ that we want to pass these flags to, convert the
1372
+ -- flags into a form that will be accepted by the older
1373
+ -- @Setup@ script. Generally speaking, this just means filtering
1374
+ -- out flags that the old @Cabal@ library doesn't understand, but
1375
+ -- in some cases it may also mean "emulating" a feature using
1376
+ -- some more legacy flags.
1377
+ filterBenchmarkFlags :: BenchmarkFlags -> Version -> BenchmarkFlags
1378
+ filterBenchmarkFlags flags cabalLibVersion =
1379
+ flags
1380
+ { benchmarkCommonFlags =
1381
+ filterCommonFlags (benchmarkCommonFlags flags) cabalLibVersion
1382
+ }
1383
+
1334
1384
-- ------------------------------------------------------------
1335
1385
1336
1386
-- * Fetch command
@@ -2404,21 +2454,25 @@ filterHaddockArgs args cabalLibVersion
2404
2454
-- Cabal < 2.3 doesn't know about per-component haddock
2405
2455
args_2_3_0 = []
2406
2456
2457
+ -- | Given some 'HaddockFlags' for the version of @Cabal@ that
2458
+ -- @cabal-install@ was built with, and a target older 'Version' of
2459
+ -- @Cabal@ that we want to pass these flags to, convert the
2460
+ -- flags into a form that will be accepted by the older
2461
+ -- @Setup@ script. Generally speaking, this just means filtering
2462
+ -- out flags that the old @Cabal@ library doesn't understand, but
2463
+ -- in some cases it may also mean "emulating" a feature using
2464
+ -- some more legacy flags.
2407
2465
filterHaddockFlags :: HaddockFlags -> Version -> HaddockFlags
2408
- filterHaddockFlags flags cabalLibVersion =
2409
- let flags' = filterHaddockFlags' flags cabalLibVersion
2410
- in flags'
2411
- { haddockCommonFlags =
2412
- filterCommonFlags (haddockCommonFlags flags') cabalLibVersion
2413
- }
2414
-
2415
- filterHaddockFlags' :: HaddockFlags -> Version -> HaddockFlags
2416
- filterHaddockFlags' flags cabalLibVersion
2466
+ filterHaddockFlags flags cabalLibVersion
2417
2467
| cabalLibVersion >= mkVersion [2 , 3 , 0 ] = flags_latest
2418
2468
| cabalLibVersion < mkVersion [2 , 3 , 0 ] = flags_2_3_0
2419
2469
| otherwise = flags_latest
2420
2470
where
2421
- flags_latest = flags
2471
+ flags_latest =
2472
+ flags
2473
+ { haddockCommonFlags =
2474
+ filterCommonFlags (haddockCommonFlags flags) cabalLibVersion
2475
+ }
2422
2476
2423
2477
flags_2_3_0 =
2424
2478
flags_latest
@@ -2490,6 +2544,9 @@ testOptions showOrParseArgs =
2490
2544
| " test-" `isPrefixOf` name = name
2491
2545
| otherwise = " test-" ++ name
2492
2546
2547
+ -- | Options for the @bench@ command.
2548
+ --
2549
+ -- Not to be confused with the @benchmarkOptions@ field of the `BenchmarkFlags` record!
2493
2550
benchmarkOptions :: ShowOrParseArgs -> [OptionField BenchmarkFlags ]
2494
2551
benchmarkOptions showOrParseArgs =
2495
2552
[ opt
@@ -3317,6 +3374,35 @@ registerCommand =
3317
3374
{ commandUsage = \ pname -> " Usage: " ++ pname ++ " v1-register [FLAGS]\n "
3318
3375
}
3319
3376
3377
+ -- | Given some 'RegisterFlags' for the version of @Cabal@ that
3378
+ -- @cabal-install@ was built with, and a target older 'Version' of
3379
+ -- @Cabal@ that we want to pass these flags to, convert the
3380
+ -- flags into a form that will be accepted by the older
3381
+ -- @Setup@ script. Generally speaking, this just means filtering
3382
+ -- out flags that the old @Cabal@ library doesn't understand, but
3383
+ -- in some cases it may also mean "emulating" a feature using
3384
+ -- some more legacy flags.
3385
+ filterRegisterFlags :: RegisterFlags -> Version -> RegisterFlags
3386
+ filterRegisterFlags flags cabalLibVersion =
3387
+ flags
3388
+ { registerCommonFlags =
3389
+ filterCommonFlags (registerCommonFlags flags) cabalLibVersion
3390
+ }
3391
+
3392
+ -- | Given some 'CopyFlags' for the version of @Cabal@ that
3393
+ -- @cabal-install@ was built with, and a target older 'Version' of
3394
+ -- @Cabal@ that we want to pass these flags to, convert the
3395
+ -- flags into a form that will be accepted by the older
3396
+ -- @Setup@ script. Generally speaking, this just means filtering
3397
+ -- out flags that the old @Cabal@ library doesn't understand, but
3398
+ -- in some cases it may also mean "emulating" a feature using
3399
+ -- some more legacy flags.
3400
+ filterCopyFlags :: CopyFlags -> Version -> CopyFlags
3401
+ filterCopyFlags flags cabalLibVersion =
3402
+ flags
3403
+ { copyCommonFlags = filterCommonFlags (copyCommonFlags flags) cabalLibVersion
3404
+ }
3405
+
3320
3406
-- ------------------------------------------------------------
3321
3407
3322
3408
-- * ActAsSetup flags
0 commit comments