Skip to content

Commit b129059

Browse files
authored
Fix hpc for cross-compiled builds (#862)
* Add Hydra build products for test coverage reports (HTML links and zip files) * Fix hpc on cross builds
1 parent f91d8c7 commit b129059

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/cover-project.nix

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ let
6060
srcDirs = map (l: l.src.outPath) (projectLibs);
6161

6262
in pkgs.runCommand "project-coverage-report"
63-
({ buildInputs = [ghc];
64-
LANG = "en_US.UTF-8";
65-
LC_ALL = "en_US.UTF-8";
63+
({ nativeBuildInputs = [ (ghc.buildGHC or ghc) pkgs.buildPackages.zip ];
64+
LANG = "en_US.UTF-8";
65+
LC_ALL = "en_US.UTF-8";
6666
} // lib.optionalAttrs (stdenv.buildPlatform.libc == "glibc") {
6767
LOCALE_ARCHIVE = "${pkgs.buildPackages.glibcLocales}/lib/locale/locale-archive";
6868
})
@@ -106,6 +106,7 @@ in pkgs.runCommand "project-coverage-report"
106106
popd
107107
}
108108
109+
mkdir -p $out/nix-support
109110
mkdir -p $out/share/hpc/vanilla/tix/all
110111
mkdir -p $out/share/hpc/vanilla/mix/
111112
mkdir -p $out/share/hpc/vanilla/html/
@@ -136,6 +137,7 @@ in pkgs.runCommand "project-coverage-report"
136137
137138
# Markup a HTML coverage report for the entire project
138139
cp ${projectIndexHtml} $out/share/hpc/vanilla/html/index.html
140+
echo "report coverage-per-package $out/share/hpc/vanilla/html/index.html" >> $out/nix-support/hydra-build-products
139141
140142
local markupOutDir="$out/share/hpc/vanilla/html/all"
141143
local srcDirs=${toBashArray srcDirs}
@@ -146,5 +148,9 @@ in pkgs.runCommand "project-coverage-report"
146148
findModules allMixModules "$out/share/hpc/vanilla/mix/" "*.mix"
147149
148150
markup srcDirs mixDirs allMixModules "$markupOutDir" "$tixFile"
151+
152+
echo "report coverage $markupOutDir/hpc_index.html" >> $out/nix-support/hydra-build-products
153+
( cd $out/share/hpc/vanilla/html ; zip -r $out/share/hpc/vanilla/html.zip . )
154+
echo "file zip $out/share/hpc/vanilla/html.zip" >> $out/nix-support/hydra-build-products
149155
fi
150156
''

lib/cover.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let
2424
srcDirs = map (l: l.src.outPath) mixLibraries;
2525

2626
in pkgs.runCommand (name + "-coverage-report")
27-
({ buildInputs = [ ghc ];
27+
({nativeBuildInputs = [ (ghc.buildGHC or ghc) pkgs.buildPackages.zip ];
2828
passthru = {
2929
inherit name library checks;
3030
};
@@ -99,6 +99,7 @@ in pkgs.runCommand (name + "-coverage-report")
9999
100100
local mixDirs=${toBashArray mixDirs}
101101
102+
mkdir -p $out/nix-support
102103
mkdir -p $out/share/hpc/vanilla/mix/${name}
103104
mkdir -p $out/share/hpc/vanilla/tix/${name}
104105
mkdir -p $out/share/hpc/vanilla/html/${name}
@@ -161,5 +162,10 @@ in pkgs.runCommand (name + "-coverage-report")
161162
162163
# Markup a HTML report, included modules from only this package
163164
markup srcDirs mixDirs pkgMixModules "$markupOutDir" "$sumTixFile"
165+
166+
# Provide a HTML zipfile and Hydra links
167+
( cd "$markupOutDir" ; zip -r $out/share/hpc/vanilla/${name}-html.zip . )
168+
echo "report coverage $markupOutDir/hpc_index.html" >> $out/nix-support/hydra-build-products
169+
echo "file zip $out/share/hpc/vanilla/${name}-html.zip" >> $out/nix-support/hydra-build-products
164170
fi
165171
''

0 commit comments

Comments
 (0)