@@ -43,6 +43,7 @@ import Options.Applicative ( Parser
43
43
, helper
44
44
, info
45
45
, long
46
+ , many
46
47
, metavar
47
48
, optional
48
49
, progDesc
@@ -81,16 +82,19 @@ data Arguments =
81
82
| Build
82
83
{ buildRelease :: Bool
83
84
, buildCompiler :: FilePath
85
+ , buildFlags :: [String ]
84
86
}
85
87
| Run
86
88
{ runRelease :: Bool
87
89
, runCompiler :: FilePath
90
+ , runFlags :: [String ]
88
91
, runTarget :: Maybe String
89
92
, runArgs :: Maybe String
90
93
}
91
94
| Test
92
95
{ testRelease :: Bool
93
96
, testCompiler :: FilePath
97
+ , testFlags :: [String ]
94
98
, testTarget :: Maybe String
95
99
, testArgs :: Maybe String
96
100
}
@@ -384,6 +388,14 @@ buildArguments =
384
388
<> help " specify the compiler to use"
385
389
<> showDefault
386
390
)
391
+ <*> many
392
+ (strOption
393
+ ( long " flag"
394
+ <> metavar " FLAG"
395
+ <> help
396
+ " specify an addional argument to pass to the compiler (can appear multiple times)"
397
+ )
398
+ )
387
399
388
400
runArguments :: Parser Arguments
389
401
runArguments =
@@ -399,6 +411,14 @@ runArguments =
399
411
<> help " specify the compiler to use"
400
412
<> showDefault
401
413
)
414
+ <*> many
415
+ (strOption
416
+ ( long " flag"
417
+ <> metavar " FLAG"
418
+ <> help
419
+ " specify an addional argument to pass to the compiler (can appear multiple times)"
420
+ )
421
+ )
402
422
<*> optional
403
423
(strArgument
404
424
(metavar " TARGET" <> help " Name of the executable to run" )
@@ -420,6 +440,14 @@ testArguments =
420
440
<> help " specify the compiler to use"
421
441
<> showDefault
422
442
)
443
+ <*> many
444
+ (strOption
445
+ ( long " flag"
446
+ <> metavar " FLAG"
447
+ <> help
448
+ " specify an addional argument to pass to the compiler (can appear multiple times)"
449
+ )
450
+ )
423
451
<*> optional
424
452
(strArgument (metavar " TARGET" <> help " Name of the test to run" ))
425
453
<*> optional (strArgument (metavar " ARGS" <> help " Arguments to the test" ))
@@ -531,38 +559,44 @@ toml2AppSettings tomlSettings args = do
531
559
let projectName = tomlSettingsProjectName tomlSettings
532
560
let compiler = case args of
533
561
Build { buildCompiler = c } -> c
534
- Run { runCompiler = c } -> c
535
- Test { testCompiler = c } -> c
562
+ Run { runCompiler = c } -> c
563
+ Test { testCompiler = c } -> c
564
+ let specifiedFlags = case args of
565
+ Build { buildFlags = f } -> f
566
+ Run { runFlags = f } -> f
567
+ Test { testFlags = f } -> f
536
568
librarySettings <- getLibrarySettings $ tomlSettingsLibrary tomlSettings
537
569
executableSettings <- getExecutableSettings
538
570
(tomlSettingsExecutables tomlSettings)
539
571
projectName
540
572
testSettings <- getTestSettings $ tomlSettingsTests tomlSettings
541
573
let flags = if compiler == " gfortran"
542
- then if release
543
- then
544
- [ " -Wall"
545
- , " -Wextra"
546
- , " -Wimplicit-interface"
547
- , " -fPIC"
548
- , " -fmax-errors=1"
549
- , " -O3"
550
- , " -march=native"
551
- , " -ffast-math"
552
- , " -funroll-loops"
553
- ]
554
- else
555
- [ " -Wall"
556
- , " -Wextra"
557
- , " -Wimplicit-interface"
558
- , " -fPIC"
559
- , " -fmax-errors=1"
560
- , " -g"
561
- , " -fbounds-check"
562
- , " -fcheck-array-temporaries"
563
- , " -fbacktrace"
564
- ]
565
- else []
574
+ then case specifiedFlags of
575
+ [] -> if release
576
+ then
577
+ [ " -Wall"
578
+ , " -Wextra"
579
+ , " -Wimplicit-interface"
580
+ , " -fPIC"
581
+ , " -fmax-errors=1"
582
+ , " -O3"
583
+ , " -march=native"
584
+ , " -ffast-math"
585
+ , " -funroll-loops"
586
+ ]
587
+ else
588
+ [ " -Wall"
589
+ , " -Wextra"
590
+ , " -Wimplicit-interface"
591
+ , " -fPIC"
592
+ , " -fmax-errors=1"
593
+ , " -g"
594
+ , " -fbounds-check"
595
+ , " -fcheck-array-temporaries"
596
+ , " -fbacktrace"
597
+ ]
598
+ flags -> flags
599
+ else specifiedFlags
566
600
buildPrefix <- makeBuildPrefix compiler flags
567
601
let dependencies = tomlSettingsDependencies tomlSettings
568
602
let devDependencies = tomlSettingsDevDependencies tomlSettings
0 commit comments