about summary refs log tree commit diff
path: root/pkgs/development/tools/analysis/cppcheck/default.nix
blob: ccd50c5454eceb009dd3fca0b82c973584497485 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ lib
, stdenv
, fetchFromGitHub
, installShellFiles
, pcre
, python3
, libxslt
, docbook_xsl
, docbook_xml_dtd_45
, which
}:

stdenv.mkDerivation rec {
  pname = "cppcheck";
  version = "2.10.1";

  src = fetchFromGitHub {
    owner = "danmar";
    repo = "cppcheck";
    rev = version;
    hash = "sha256-tN7MYMRBakdL++ZeY2u9s2B2wyAU7iaOB/hsv2GXI6s=";
  };

  buildInputs = [ pcre (python3.withPackages (ps: [ps.pygments])) ];
  nativeBuildInputs = [ installShellFiles libxslt docbook_xsl docbook_xml_dtd_45 which ];

  makeFlags = [ "PREFIX=$(out)" "MATCHCOMPILER=yes" "FILESDIR=$(out)/share/cppcheck" "HAVE_RULES=yes" ];

  outputs = [ "out" "man" ];

  enableParallelBuilding = true;

  postBuild = ''
    make DB2MAN=${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl man
  '';

  doCheck = true;

  postInstall = ''
    installManPage cppcheck.1
  '';

  doInstallCheck = true;
  installCheckPhase = ''
    runHook preInstallCheck

    echo 'int main() {}' > ./installcheck.cpp
    $out/bin/cppcheck ./installcheck.cpp > /dev/null

    runHook postInstallCheck
  '';

  meta = with lib; {
    description = "A static analysis tool for C/C++ code";
    longDescription = ''
      Check C/C++ code for memory leaks, mismatching allocation-deallocation,
      buffer overruns and more.
    '';
    homepage = "http://cppcheck.sourceforge.net/";
    license = licenses.gpl3Plus;
    platforms = platforms.unix;
    maintainers = with maintainers; [ joachifm ];
  };
}