Skip to content

Commit 8948fb8

Browse files
committed
Fix hpc on cross builds
1 parent 526c5eb commit 8948fb8

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

lib/cover-project.nix

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ let
4343
</html>
4444
'';
4545

46-
ghc =
47-
if (builtins.length coverageReports) > 0
48-
then (builtins.head coverageReports).library.project.pkg-set.config.ghc.package or pkgs.ghc
49-
else pkgs.ghc;
50-
5146
libs = map (r: r.library) coverageReports;
5247

5348
projectLibs = map (pkg: pkg.components.library) (lib.attrValues (haskellLib.selectProjectPackages ((lib.head libs).project.hsPkgs)));
@@ -60,21 +55,22 @@ let
6055
srcDirs = map (l: l.src.outPath) (projectLibs);
6156

6257
in pkgs.runCommand "project-coverage-report"
63-
({ buildInputs = [ghc];
64-
LANG = "en_US.UTF-8";
58+
({ LANG = "en_US.UTF-8";
6559
LC_ALL = "en_US.UTF-8";
6660
} // lib.optionalAttrs (stdenv.buildPlatform.libc == "glibc") {
6761
LOCALE_ARCHIVE = "${pkgs.buildPackages.glibcLocales}/lib/locale/locale-archive";
6862
})
6963
''
64+
local hpc=${pkgs.buildPackages.haskellPackages.ghc}/bin/hpc
65+
7066
function markup() {
7167
local -n srcDs=$1
7268
local -n mixDs=$2
7369
local -n includedModules=$3
7470
local destDir=$4
7571
local tixFile=$5
7672
77-
local hpcMarkupCmd=("hpc" "markup" "--destdir=$destDir")
73+
local hpcMarkupCmd=("$hpc" "markup" "--destdir=$destDir")
7874
for srcDir in "''${srcDs[@]}"; do
7975
hpcMarkupCmd+=("--srcdir=$srcDir")
8076
done
@@ -130,7 +126,7 @@ in pkgs.runCommand "project-coverage-report"
130126
if [ ''${#tixFiles[@]} -ne 0 ]; then
131127
# Create tix file with test run information for all packages
132128
tixFile="$out/share/hpc/vanilla/tix/all/all.tix"
133-
hpcSumCmd=("hpc" "sum" "--union" "--output=$tixFile")
129+
hpcSumCmd=("$hpc" "sum" "--union" "--output=$tixFile")
134130
hpcSumCmd+=("''${tixFiles[@]}")
135131
echo "''${hpcSumCmd[@]}"
136132
eval "''${hpcSumCmd[@]}"

lib/cover.nix

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
# argument. Use a larger list of libraries if you would like the tests
1212
# of one local package to generate coverage for another.
1313
, mixLibraries ? [library]
14-
# hack for project-less projects
15-
, ghc ? library.project.pkg-set.config.ghc.package
1614
}:
1715

1816
let
@@ -24,8 +22,7 @@ let
2422
srcDirs = map (l: l.src.outPath) mixLibraries;
2523

2624
in pkgs.runCommand (name + "-coverage-report")
27-
({ buildInputs = [ ghc ];
28-
passthru = {
25+
({ passthru = {
2926
inherit name library checks;
3027
};
3128
# HPC will fail if the Haskell file contains non-ASCII characters,
@@ -39,14 +36,16 @@ in pkgs.runCommand (name + "-coverage-report")
3936
LOCALE_ARCHIVE = "${pkgs.buildPackages.glibcLocales}/lib/locale/locale-archive";
4037
})
4138
''
39+
local hpc=${pkgs.buildPackages.haskellPackages.ghc}/bin/hpc
40+
4241
function markup() {
4342
local -n srcDs=$1
4443
local -n mixDs=$2
4544
local -n includedModules=$3
4645
local destDir=$4
4746
local tixFile=$5
4847
49-
local hpcMarkupCmd=("hpc" "markup" "--destdir=$destDir")
48+
local hpcMarkupCmd=("$hpc" "markup" "--destdir=$destDir")
5049
for srcDir in "''${srcDs[@]}"; do
5150
hpcMarkupCmd+=("--srcdir=$srcDir")
5251
done
@@ -70,7 +69,7 @@ in pkgs.runCommand (name + "-coverage-report")
7069
local -n tixFs=$2
7170
local outFile="$3"
7271
73-
local hpcSumCmd=("hpc" "sum" "--union" "--output=$outFile")
72+
local hpcSumCmd=("$hpc" "sum" "--union" "--output=$outFile")
7473
7574
for module in "''${includedModules[@]}"; do
7675
hpcSumCmd+=("--include=$module")

0 commit comments

Comments
 (0)