about summary refs log tree commit diff
path: root/pkgs/by-name/cr/criterion/package.nix
blob: efa1459dc72d5065ca9b4d6bc3a8d29b61146e44 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
{
  lib,
  stdenv,
  fetchFromGitHub,
  boxfort,
  meson,
  libcsptr,
  pkg-config,
  gettext,
  cmake,
  ninja,
  protobuf,
  libffi,
  libgit2,
  dyncall,
  nanomsg,
  nanopbMalloc,
  python3Packages,
  testers,
  criterion,
  callPackage
}:

let
  # follow revisions defined in .wrap files
  debugbreak = fetchFromGitHub {
    owner = "MrAnno";
    repo = "debugbreak";
    rev = "83bf7e933311b88613cbaadeced9c2e2c811054a";
    hash = "sha256-OPrPGBUZN73Nl5NMEf/nME843yTolt913yjut3rAos0=";
  };

  klib = fetchFromGitHub {
    owner = "attractivechaos";
    repo = "klib";
    rev = "cdb7e9236dc47abf8da7ebd702cc6f7f21f0c502";
    hash = "sha256-+GaI5nXz4jYI0rO17xDhNtFpLlGL2WzeSVLMfB6Cl6E=";
  };
in
stdenv.mkDerivation rec {
  pname = "criterion";
  version = "2.4.2";

  src = fetchFromGitHub {
    owner = "Snaipe";
    repo = "Criterion";
    rev = "v${version}";
    fetchSubmodules = true;
    hash = "sha256-5GH7AYjrnBnqiSmp28BoaM1Xmy8sPs1atfqJkGy3Yf0=";
  };

  nativeBuildInputs = [
    meson
    ninja
    cmake
    pkg-config
    protobuf
  ];

  buildInputs = [
    (lib.getDev boxfort)
    dyncall
    gettext
    libcsptr
    nanomsg
    nanopbMalloc
    libgit2
    libffi
  ];

  nativeCheckInputs = with python3Packages; [ cram ];

  doCheck = true;

  prePatch = ''
    cp -r ${debugbreak} subprojects/debugbreak
    cp -r ${klib} subprojects/klib

    for dep in "debugbreak" "klib"; do
      local meson="$dep/meson.build"

      chmod +w subprojects/$dep
      cp subprojects/packagefiles/$meson subprojects/$meson
    done
  '';

  postPatch = ''
    patchShebangs ci/isdir.py src/protocol/gen-pb.py
  '';

  outputs = [
    "out"
    "dev"
  ];

  passthru.tests.version =
    let
      tester = callPackage ./tests/001-version.nix {};
    in
    testers.testVersion {
      package = criterion;
      command = "${lib.getExe tester} --version";
      version = "v${version}";
    };

  meta = {
    description = "A cross-platform C and C++ unit testing framework for the 21th century";
    homepage = "https://github.com/Snaipe/Criterion";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [
      thesola10
      Yumasi
      sigmanificient
    ];
    platforms = lib.platforms.unix;
  };
}