Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haskell: support Haskell Program Coverage (HPC) #22797

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pkgs/development/haskell-modules/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
, jailbreak ? false
, license
, maintainers ? []
, doCoverage ? false
# TODO Do we care about haddock when cross-compiling?
, doHaddock ? !isCross && (!stdenv.isDarwin || stdenv.lib.versionAtLeast ghc.version "7.8")
, passthru ? {}
Expand Down Expand Up @@ -59,7 +60,7 @@ assert enableSplitObjs == null;

let

inherit (stdenv.lib) optional optionals optionalString versionOlder
inherit (stdenv.lib) optional optionals optionalString versionOlder versionAtLeast
concatStringsSep enableFeature optionalAttrs toUpper;

isGhcjs = ghc.isGhcjs or false;
Expand Down Expand Up @@ -111,10 +112,11 @@ let
(optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
(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")
(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 enableExecutableProfiling (if versionOlder ghc.version "8" then "executable-profiling" else "profiling"))
(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.4" ghc.version) (enableFeature enableSharedExecutables "executable-dynamic"))
(optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature doCheck "tests"))
Expand Down Expand Up @@ -286,7 +288,7 @@ stdenv.mkDerivation ({
local pkgId=$( ${gnused}/bin/sed -n -e 's|^id: ||p' $packageConfFile )
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") ''
for exe in "$out/bin/"* ; do
install_name_tool -add_rpath "$out/lib/ghc-${ghc.version}/${pname}-${version}" "$exe"
Expand Down
3 changes: 3 additions & 0 deletions pkgs/development/haskell-modules/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ rec {
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; });
dontHaddock = drv: overrideCabal drv (drv: { doHaddock = false; });

Expand Down