haskell: add support for Haskell Program Coverage (HPC) to the generic builder
A function is added to enable the generation of a HPC report. For example: pkgs.haskell.lib.doCoverage drv will create a HPC report of the Haskell package drv in the directory: $out/share/hpc Closes https://github.com/NixOS/nixpkgs/pull/22797/files.
This commit is contained in:
parent
35b2159671
commit
8a928708b4
@ -32,6 +32,7 @@
|
|||||||
, jailbreak ? false
|
, jailbreak ? false
|
||||||
, license
|
, license
|
||||||
, maintainers ? []
|
, maintainers ? []
|
||||||
|
, doCoverage ? false
|
||||||
# TODO Do we care about haddock when cross-compiling?
|
# TODO Do we care about haddock when cross-compiling?
|
||||||
, doHaddock ? !isCross && (!stdenv.isDarwin || stdenv.lib.versionAtLeast ghc.version "7.8")
|
, doHaddock ? !isCross && (!stdenv.isDarwin || stdenv.lib.versionAtLeast ghc.version "7.8")
|
||||||
, passthru ? {}
|
, passthru ? {}
|
||||||
@ -59,7 +60,7 @@ assert enableSplitObjs == null;
|
|||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
inherit (stdenv.lib) optional optionals optionalString versionOlder
|
inherit (stdenv.lib) optional optionals optionalString versionOlder versionAtLeast
|
||||||
concatStringsSep enableFeature optionalAttrs toUpper;
|
concatStringsSep enableFeature optionalAttrs toUpper;
|
||||||
|
|
||||||
isGhcjs = ghc.isGhcjs or false;
|
isGhcjs = ghc.isGhcjs or false;
|
||||||
@ -111,10 +112,11 @@ let
|
|||||||
(optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
|
(optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
|
||||||
(optionalString enableParallelBuilding "--ghc-option=-j$NIX_BUILD_CORES")
|
(optionalString enableParallelBuilding "--ghc-option=-j$NIX_BUILD_CORES")
|
||||||
(optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp")
|
(optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp")
|
||||||
(enableFeature (enableDeadCodeElimination && (stdenv.lib.versionAtLeast "8.0.1" ghc.version)) "split-objs")
|
(enableFeature (enableDeadCodeElimination && (versionAtLeast "8.0.1" ghc.version)) "split-objs")
|
||||||
(enableFeature enableLibraryProfiling "library-profiling")
|
(enableFeature enableLibraryProfiling "library-profiling")
|
||||||
(enableFeature enableExecutableProfiling (if versionOlder ghc.version "8" then "executable-profiling" else "profiling"))
|
(enableFeature enableExecutableProfiling (if versionOlder ghc.version "8" then "executable-profiling" else "profiling"))
|
||||||
(enableFeature enableSharedLibraries "shared")
|
(enableFeature enableSharedLibraries "shared")
|
||||||
|
(optionalString (versionAtLeast ghc.version "7.10") (enableFeature doCoverage "coverage"))
|
||||||
(optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature enableStaticLibraries "library-vanilla"))
|
(optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature enableStaticLibraries "library-vanilla"))
|
||||||
(optionalString (isGhcjs || versionOlder "7.4" ghc.version) (enableFeature enableSharedExecutables "executable-dynamic"))
|
(optionalString (isGhcjs || versionOlder "7.4" ghc.version) (enableFeature enableSharedExecutables "executable-dynamic"))
|
||||||
(optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature doCheck "tests"))
|
(optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature doCheck "tests"))
|
||||||
@ -286,7 +288,7 @@ stdenv.mkDerivation ({
|
|||||||
local pkgId=$( ${gnused}/bin/sed -n -e 's|^id: ||p' $packageConfFile )
|
local pkgId=$( ${gnused}/bin/sed -n -e 's|^id: ||p' $packageConfFile )
|
||||||
mv $packageConfFile $packageConfDir/$pkgId.conf
|
mv $packageConfFile $packageConfDir/$pkgId.conf
|
||||||
''}
|
''}
|
||||||
|
${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"}
|
||||||
${optionalString (enableSharedExecutables && isExecutable && !isGhcjs && stdenv.isDarwin && stdenv.lib.versionOlder ghc.version "7.10") ''
|
${optionalString (enableSharedExecutables && isExecutable && !isGhcjs && stdenv.isDarwin && stdenv.lib.versionOlder ghc.version "7.10") ''
|
||||||
for exe in "$out/bin/"* ; do
|
for exe in "$out/bin/"* ; do
|
||||||
install_name_tool -add_rpath "$out/lib/ghc-${ghc.version}/${pname}-${version}" "$exe"
|
install_name_tool -add_rpath "$out/lib/ghc-${ghc.version}/${pname}-${version}" "$exe"
|
||||||
|
@ -8,6 +8,9 @@ rec {
|
|||||||
overrideScope = scope: overrideCabal (drv.overrideScope scope) f;
|
overrideScope = scope: overrideCabal (drv.overrideScope scope) f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
doCoverage = drv: overrideCabal drv (drv: { doCoverage = true; });
|
||||||
|
dontCoverage = drv: overrideCabal drv (drv: { doCoverage = false; });
|
||||||
|
|
||||||
doHaddock = drv: overrideCabal drv (drv: { doHaddock = true; });
|
doHaddock = drv: overrideCabal drv (drv: { doHaddock = true; });
|
||||||
dontHaddock = drv: overrideCabal drv (drv: { doHaddock = false; });
|
dontHaddock = drv: overrideCabal drv (drv: { doHaddock = false; });
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user