@@ -54,6 +54,7 @@ let self =
54
54
55
55
# Coverage
56
56
, doCoverage ? component . doCoverage
57
+ , doCoverageNoRecurse ? false
57
58
58
59
# Data
59
60
, enableSeparateDataOutput ? component . enableSeparateDataOutput
76
77
77
78
needsProfiling = enableExecutableProfiling || enableLibraryProfiling ;
78
79
80
+ needsCoverage = doCoverage || doCoverageNoRecurse ;
81
+
79
82
configFiles = makeConfigFiles {
80
83
inherit ( package ) identifier ;
81
- inherit component fullName flags needsProfiling ;
84
+ inherit component fullName flags needsProfiling needsCoverage ;
82
85
} ;
83
86
84
87
enableFeature = enable : feature :
122
125
( enableFeature enableExecutableProfiling "executable-profiling" )
123
126
( enableFeature enableStatic "static" )
124
127
( enableFeature enableShared "shared" )
125
- ( enableFeature doCoverage "coverage" )
128
+ ( enableFeature ( doCoverage || doCoverageNoRecurse ) "coverage" )
126
129
] ++ lib . optionals ( stdenv . hostPlatform . isMusl && ( haskellLib . isExecutableType componentId ) ) [
127
130
# These flags will make sure the resulting executable is statically linked.
128
131
# If it uses other libraries it may be necessary for to add more
209
212
componentDrv = drv ;
210
213
} ;
211
214
215
+ isComponentLibrary = d : ( d . identifier == package . identifier ) ;
216
+
217
+ fx = d :
218
+ if ( doCoverage && isComponentLibrary d )
219
+ then ( d . components . library . coveredNoRecurse or d )
220
+ else ( d . components . library or d ) ;
221
+
212
222
drv = stdenv . mkDerivation ( commonAttrs // {
213
223
pname = nameOnly ;
214
224
inherit ( package . identifier ) version ;
225
235
env = shellWrappers ;
226
236
profiled = self ( drvArgs // { enableLibraryProfiling = true ; } ) ;
227
237
covered = self ( drvArgs // { doCoverage = true ; } ) ;
238
+ coveredNoRecurse = self ( drvArgs // { doCoverageNoRecurse = true ; } ) ;
239
+ debugArgs = drvArgs ;
240
+ inherit finalConfigureFlags ;
228
241
} // lib . optionalAttrs ( haskellLib . isLibrary componentId ) ( {
229
242
inherit haddock ;
230
243
inherit ( haddock ) haddockDir ; # This is null if `doHaddock = false`
250
263
# Not sure why pkgconfig needs to be propagatedBuildInputs but
251
264
# for gi-gtk-hs it seems to help.
252
265
++ builtins . concatLists pkgconfig ;
253
-
266
+
254
267
buildInputs = component . libs
255
- ++ map ( d : d . components . library or d ) component . depends ;
268
+ ++ map fx component . depends ;
256
269
257
270
nativeBuildInputs =
258
271
[ shellWrappers buildPackages . removeReferencesTo ]
360
373
fi
361
374
done
362
375
'' )
363
- + ( lib . optionalString doCoverage ''
376
+ + ( lib . optionalString ( doCoverage || doCoverageNoRecurse ) ''
364
377
mkdir -p $out/share
365
378
cp -r dist/hpc $out/share
366
379
'' )
0 commit comments