2008-11-24 18:10:06 +03:00
|
|
|
# This function builds and tests an Autoconf-style source tarball.
|
|
|
|
# The result can be installed normally in an environment (e.g., after
|
|
|
|
# making it available through a channel). If `doCoverageAnalysis' is
|
|
|
|
# true, it does an ordinary build from a source tarball, except that
|
|
|
|
# it turns on GCC's coverage analysis feature. It then runs `make
|
|
|
|
# check' and produces a coverage analysis report using `lcov'.
|
|
|
|
|
2010-09-10 16:39:57 +04:00
|
|
|
{ buildOutOfSourceTree ? false
|
|
|
|
, preConfigure ? null
|
|
|
|
, doCoverageAnalysis ? false
|
2008-12-04 18:32:30 +03:00
|
|
|
, lcovFilter ? []
|
2010-05-12 16:22:44 +04:00
|
|
|
, lcovExtraTraceFiles ? []
|
2008-12-04 18:32:30 +03:00
|
|
|
, src, stdenv
|
2009-03-02 16:45:48 +03:00
|
|
|
, name ? if doCoverageAnalysis then "nix-coverage" else "nix-build"
|
2012-02-28 21:10:50 +04:00
|
|
|
, failureHook ? null
|
2012-03-19 07:45:36 +04:00
|
|
|
, prePhases ? []
|
2012-03-19 06:45:52 +04:00
|
|
|
, postPhases ? []
|
2008-12-04 18:32:30 +03:00
|
|
|
, ... } @ args:
|
2008-11-24 18:10:06 +03:00
|
|
|
|
|
|
|
stdenv.mkDerivation (
|
|
|
|
|
|
|
|
{
|
|
|
|
# Also run a `make check'.
|
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
# When doing coverage analysis, we don't care about the result.
|
|
|
|
dontInstall = doCoverageAnalysis;
|
2012-03-19 20:05:29 +04:00
|
|
|
useTempPrefix = doCoverageAnalysis;
|
2008-11-24 18:10:06 +03:00
|
|
|
|
|
|
|
showBuildStats = true;
|
|
|
|
|
2009-06-17 11:02:59 +04:00
|
|
|
finalPhase =
|
|
|
|
''
|
|
|
|
# Propagate the release name of the source tarball. This is
|
|
|
|
# to get nice package names in channels.
|
|
|
|
if test -e $origSrc/nix-support/hydra-release-name; then
|
|
|
|
cp $origSrc/nix-support/hydra-release-name $out/nix-support/hydra-release-name
|
|
|
|
fi
|
|
|
|
'';
|
2010-12-22 17:57:18 +03:00
|
|
|
|
2012-02-28 21:10:50 +04:00
|
|
|
failureHook = (stdenv.lib.optionalString (failureHook != null) failureHook) +
|
|
|
|
''
|
2010-12-22 17:57:18 +03:00
|
|
|
if test -n "$succeedOnFailure"; then
|
|
|
|
if test -n "$keepBuildDirectory"; then
|
|
|
|
KEEPBUILDDIR="$out/`basename $TMPDIR`"
|
|
|
|
header "Copying build directory to $KEEPBUILDDIR"
|
2012-01-19 00:16:00 +04:00
|
|
|
mkdir -p $KEEPBUILDDIR
|
2013-04-18 14:18:39 +04:00
|
|
|
cp -R "$TMPDIR/"* $KEEPBUILDDIR
|
2013-02-13 16:53:41 +04:00
|
|
|
stopNest
|
2010-12-22 17:57:18 +03:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
'';
|
2008-11-24 18:10:06 +03:00
|
|
|
}
|
|
|
|
|
2013-02-13 16:53:41 +04:00
|
|
|
// args //
|
2008-11-24 18:10:06 +03:00
|
|
|
|
|
|
|
{
|
2009-03-02 17:33:33 +03:00
|
|
|
name = name + (if src ? version then "-" + src.version else "");
|
2013-02-13 16:53:41 +04:00
|
|
|
|
2008-11-24 18:10:06 +03:00
|
|
|
postHook = ''
|
2012-07-13 22:58:39 +04:00
|
|
|
. ${./functions.sh}
|
2009-03-02 16:45:48 +03:00
|
|
|
origSrc=$src
|
2012-07-13 22:58:39 +04:00
|
|
|
src=$(findTarballs $src | head -1)
|
2008-11-24 18:10:06 +03:00
|
|
|
|
|
|
|
# Set GCC flags for coverage analysis, if desired.
|
|
|
|
if test -n "${toString doCoverageAnalysis}"; then
|
2009-08-31 19:02:27 +04:00
|
|
|
export NIX_CFLAGS_COMPILE="-O0 --coverage $NIX_CFLAGS_COMPILE"
|
2008-11-24 18:10:06 +03:00
|
|
|
export CFLAGS="-O0"
|
|
|
|
export CXXFLAGS="-O0"
|
|
|
|
fi
|
2013-04-18 14:18:39 +04:00
|
|
|
'';
|
2008-11-24 18:10:06 +03:00
|
|
|
|
2012-03-19 07:45:36 +04:00
|
|
|
initPhase = ''
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
echo "$system" > $out/nix-support/system
|
|
|
|
|
2012-03-19 20:05:29 +04:00
|
|
|
if [ -z "${toString doCoverageAnalysis}" ]; then
|
2013-02-13 16:53:41 +04:00
|
|
|
for i in $outputs; do
|
|
|
|
if [ "$i" = out ]; then j=none; else j="$i"; fi
|
2013-02-13 19:30:15 +04:00
|
|
|
mkdir -p ''${!i}/nix-support
|
|
|
|
echo "nix-build $j ''${!i}" >> ''${!i}/nix-support/hydra-build-products
|
2013-02-13 16:53:41 +04:00
|
|
|
done
|
2012-03-19 07:45:36 +04:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
prePhases = ["initPhase"] ++ prePhases;
|
2008-11-24 18:10:06 +03:00
|
|
|
|
|
|
|
# In the report phase, create a coverage analysis report.
|
|
|
|
coverageReportPhase = if doCoverageAnalysis then ''
|
|
|
|
${args.lcov}/bin/lcov --directory . --capture --output-file app.info
|
|
|
|
set -o noglob
|
|
|
|
${args.lcov}/bin/lcov --remove app.info $lcovFilter > app2.info
|
|
|
|
set +o noglob
|
|
|
|
mv app2.info app.info
|
2010-05-12 16:22:44 +04:00
|
|
|
|
2008-11-24 18:10:06 +03:00
|
|
|
mkdir $out/coverage
|
2010-05-12 16:22:44 +04:00
|
|
|
${args.lcov}/bin/genhtml app.info $lcovExtraTraceFiles -o $out/coverage > log
|
2008-11-24 18:10:06 +03:00
|
|
|
|
|
|
|
# Grab the overall coverage percentage for use in release overviews.
|
|
|
|
grep "Overall coverage rate" log | sed 's/^.*(\(.*\)%).*$/\1/' > $out/nix-support/coverage-rate
|
|
|
|
|
|
|
|
echo "report coverage $out/coverage" >> $out/nix-support/hydra-build-products
|
|
|
|
'' else "";
|
|
|
|
|
|
|
|
|
2008-12-04 18:32:30 +03:00
|
|
|
lcovFilter = ["/nix/store/*"] ++ lcovFilter;
|
2009-03-02 16:45:48 +03:00
|
|
|
|
2010-05-12 16:22:44 +04:00
|
|
|
inherit lcovExtraTraceFiles;
|
2009-03-02 16:45:48 +03:00
|
|
|
|
2012-03-19 06:45:52 +04:00
|
|
|
postPhases = postPhases ++
|
|
|
|
(stdenv.lib.optional doCoverageAnalysis "coverageReportPhase") ++ ["finalPhase"];
|
|
|
|
|
2008-11-26 17:34:29 +03:00
|
|
|
meta = (if args ? meta then args.meta else {}) // {
|
2013-03-01 15:50:29 +04:00
|
|
|
description = if doCoverageAnalysis then "Coverage analysis" else "Nix package for ${stdenv.system}";
|
2008-11-24 18:10:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2010-09-10 16:39:57 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
(if buildOutOfSourceTree
|
|
|
|
then {
|
|
|
|
preConfigure =
|
|
|
|
# Build out of source tree and make the source tree read-only. This
|
|
|
|
# helps catch violations of the GNU Coding Standards (info
|
|
|
|
# "(standards) Configuration"), like `make distcheck' does.
|
|
|
|
'' mkdir "../build"
|
|
|
|
cd "../build"
|
|
|
|
configureScript="../$sourceRoot/configure"
|
|
|
|
chmod -R a-w "../$sourceRoot"
|
|
|
|
|
|
|
|
echo "building out of source tree, from \`$PWD'..."
|
|
|
|
|
|
|
|
${if preConfigure != null then preConfigure else ""}
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
else {})
|
2008-11-24 18:10:06 +03:00
|
|
|
)
|