Skip to content

Commit dcdeb64

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

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/cover-project.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ in pkgs.runCommand "project-coverage-report"
6767
LOCALE_ARCHIVE = "${pkgs.buildPackages.glibcLocales}/lib/locale/locale-archive";
6868
})
6969
''
70+
local hpc=${pkgs.targetPackages.haskellPackages.ghc}/bin/hpc
71+
7072
function markup() {
7173
local -n srcDs=$1
7274
local -n mixDs=$2
7375
local -n includedModules=$3
7476
local destDir=$4
7577
local tixFile=$5
7678
77-
local hpcMarkupCmd=("hpc" "markup" "--destdir=$destDir")
79+
local hpcMarkupCmd=("$hpc" "markup" "--destdir=$destDir")
7880
for srcDir in "''${srcDs[@]}"; do
7981
hpcMarkupCmd+=("--srcdir=$srcDir")
8082
done
@@ -130,7 +132,7 @@ in pkgs.runCommand "project-coverage-report"
130132
if [ ''${#tixFiles[@]} -ne 0 ]; then
131133
# Create tix file with test run information for all packages
132134
tixFile="$out/share/hpc/vanilla/tix/all/all.tix"
133-
hpcSumCmd=("hpc" "sum" "--union" "--output=$tixFile")
135+
hpcSumCmd=("$hpc" "sum" "--union" "--output=$tixFile")
134136
hpcSumCmd+=("''${tixFiles[@]}")
135137
echo "''${hpcSumCmd[@]}"
136138
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.targetPackages.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)