about summary refs log tree commit diff
path: root/pkgs/build-support/release/default.nix
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2014-05-02 13:26:41 -0500
committerAustin Seipp <aseipp@pobox.com>2014-05-02 14:07:37 -0500
commit76b05b163001a26807f3d2f52434b482777967c1 (patch)
tree50ada937f3ead2bfa27f09738daa7d4987053733 /pkgs/build-support/release/default.nix
parent59528d9f0e7bef27acafe7cb6eaf5273aef2dcfa (diff)
releaseTools: add {clang,coverity}Analysis tools
These two expressions greatly simplify using the clang-analyzer or
Coverity static analyzer on your C/C++ projects. In fact, they are
identical to nixBuild in every way out of the box, and should 'Just
Work' providing your code can be compiled with Clang already.

The trick is that when running 'make', we actually just alias it to the
appropriate scan build tool, and add a post-build hook that will bundle
up the results appropriately and unalias it.

For Clang, we put the results in $out/analysis and add an 'analysis'
report to $out/nix-support/hydra-build-products pointing to the result
HTML - this means that if the analyzer finds any bugs, the HTML results
will automatically show up Hydra for easy viewing.

For Coverity, it's slightly different. Instead we run the build tool and
after we're done, we tar up the results in a format that Coverity Scan's
service understands. We put the tarball in $out/tarballs under the name
'foo-cov-int.xz' and add an entry for the file to hydra-build-products
as well for easy viewing.

Of course for Coverity you must then upload the build. A Hydra plugin to
do this is on the way, and it will automatically pick up the
cov-int.tar.xz for uploading.

Note that coverityAnalysis requires allowUnfree = true;, as well as the
cov-build tools, which you can download from https://scan.coverity.com -
they're not linked to your account or anything, it's just an annoying
registration wall.

Note this is a first draft. In particular, scan-build fixes the C/C++
compiler to be Clang, and it's perfectly reasonable to want to use Clang
for the analyzer but have scan-build invoke GCC instead.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'pkgs/build-support/release/default.nix')
-rw-r--r--pkgs/build-support/release/default.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkgs/build-support/release/default.nix b/pkgs/build-support/release/default.nix
index 6288935ec2a56..d36707dc60f48 100644
--- a/pkgs/build-support/release/default.nix
+++ b/pkgs/build-support/release/default.nix
@@ -31,6 +31,16 @@ rec {
       doCoverageAnalysis = true;
     } // args);
 
+  clangAnalysis = args: nixBuild (
+    { inherit clangAnalyzer;
+      doClangAnalysis = true;
+    } // args);
+
+  coverityAnalysis = args: nixBuild (
+    { inherit cov-build xz;
+      doCoverityAnalysis = true;
+    } // args);
+
   gcovReport = args: import ./gcov-report.nix (
     { inherit runCommand lcov rsync;
     } // args);