@@ -42,6 +42,7 @@ module Distribution.Simple.Configure (configure,
42
42
getPackageDBContents ,
43
43
configCompiler , configCompilerAux ,
44
44
configCompilerEx , configCompilerAuxEx ,
45
+ computeEffectiveProfiling ,
45
46
ccLdOptionsBuildInfo ,
46
47
checkForeignDeps ,
47
48
interpretPackageDbFlags ,
@@ -310,6 +311,29 @@ findDistPrefOrDefault :: Setup.Flag FilePath -- ^ override \"dist\" prefix
310
311
-> IO FilePath
311
312
findDistPrefOrDefault = findDistPref defaultDistPref
312
313
314
+ -- | Compute the effective value of the profiling flags
315
+ -- @--enable-library-profiling@ and @--enable-executable-profiling@
316
+ -- from the specified 'ConfigFlags'. This may be useful for
317
+ -- external Cabal tools which need to interact with Setup in
318
+ -- a backwards-compatible way: the most predictable mechanism
319
+ -- for enabling profiling across many legacy versions is to
320
+ -- NOT use @--enable-profiling@ and use those two flags instead.
321
+ --
322
+ -- Note that @--enable-executable-profiling@ also affects profiling
323
+ -- of benchmarks and (non-detailed) test suites.
324
+ computeEffectiveProfiling :: ConfigFlags -> (Bool {- lib -} , Bool {- exe -} )
325
+ computeEffectiveProfiling cfg =
326
+ -- The --profiling flag sets the default for both libs and exes,
327
+ -- but can be overidden by --library-profiling, or the old deprecated
328
+ -- --executable-profiling flag.
329
+ --
330
+ -- The --profiling-detail and --library-profiling-detail flags behave
331
+ -- similarly
332
+ let profEnabledBoth = fromFlagOrDefault False (configProf cfg)
333
+ profEnabledLib = fromFlagOrDefault profEnabledBoth (configProfLib cfg)
334
+ profEnabledExe = fromFlagOrDefault profEnabledBoth (configProfExe cfg)
335
+ in (profEnabledLib, profEnabledExe)
336
+
313
337
-- | Perform the \"@.\/setup configure@\" action.
314
338
-- Returns the @.setup-config@ file.
315
339
configure :: (GenericPackageDescription , HookedBuildInfo )
@@ -578,16 +602,8 @@ configure (pkg_descr0', pbi) cfg = do
578
602
++ " is not being built. Linking will fail if any executables "
579
603
++ " depend on the library."
580
604
581
- -- The --profiling flag sets the default for both libs and exes,
582
- -- but can be overidden by --library-profiling, or the old deprecated
583
- -- --executable-profiling flag.
584
- let profEnabledLibOnly = configProfLib cfg
585
- profEnabledBoth = fromFlagOrDefault False (configProf cfg)
586
- profEnabledLib = fromFlagOrDefault profEnabledBoth profEnabledLibOnly
587
- profEnabledExe = fromFlagOrDefault profEnabledBoth (configProfExe cfg)
605
+ let (profEnabledLib, profEnabledExe) = computeEffectiveProfiling cfg
588
606
589
- -- The --profiling-detail and --library-profiling-detail flags behave
590
- -- similarly
591
607
profDetailLibOnly <- checkProfDetail (configProfLibDetail cfg)
592
608
profDetailBoth <- liftM (fromFlagOrDefault ProfDetailDefault )
593
609
(checkProfDetail (configProfDetail cfg))
0 commit comments