forked from mirrors/nixpkgs
59528d9f0e
When using scan-build, you're often going to want to use it in the context of a Nix expression with buildInputs, and the default wrapper scripts will put things like include locations for those inputs $NIX_CFLAGS_COMPILE. Thus, scan-build also needs to pass them to the analyzer - while the link flags aren't relevant, the include flags are. This is because the analyzer executable that gets run by scan-build is *not* clang-wrapper, but the actual clang executable, so it doesn't implicitly add such arguments. The build is two-stage - it runs the real clang wrapper once, and then the analyzer once. Signed-off-by: Austin Seipp <aseipp@pobox.com>
36 lines
1.2 KiB
Nix
36 lines
1.2 KiB
Nix
{ stdenv, fetchurl, clang, llvmPackages, perl, makeWrapper }:
|
|
|
|
stdenv.mkDerivation rec {
|
|
name = "clang-analyzer-${version}";
|
|
version = "3.4";
|
|
|
|
src = fetchurl {
|
|
url = "http://llvm.org/releases/${version}/clang-${version}.src.tar.gz";
|
|
sha256 = "06rb4j1ifbznl3gfhl98s7ilj0ns01p7y7zap4p7ynmqnc6pia92";
|
|
};
|
|
|
|
patches = [ ./0001-Fix-scan-build-to-use-NIX_CFLAGS_COMPILE.patch ];
|
|
buildInputs = [ clang llvmPackages.clang perl makeWrapper ];
|
|
buildPhase = "true";
|
|
|
|
installPhase = ''
|
|
mkdir -p $out/bin $out/libexec
|
|
cp -R tools/scan-view $out/libexec
|
|
cp -R tools/scan-build $out/libexec
|
|
|
|
makeWrapper $out/libexec/scan-view/scan-view $out/bin/scan-view
|
|
makeWrapper $out/libexec/scan-build/scan-build $out/bin/scan-build \
|
|
--add-flags "--use-cc=${clang}/bin/clang" \
|
|
--add-flags "--use-c++=${clang}/bin/clang++" \
|
|
--add-flags "--use-analyzer='${llvmPackages.clang}/bin/clang'"
|
|
'';
|
|
|
|
meta = {
|
|
description = "Clang Static Analyzer";
|
|
homepage = "http://clang-analyzer.llvm.org";
|
|
license = stdenv.lib.licenses.bsd3;
|
|
platforms = stdenv.lib.platforms.unix;
|
|
maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
|
|
};
|
|
}
|