summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/cp/cpptrace/package.nix
blob: c64586d884083a74f3292f9c456a181363612bbc (plain)
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
{
  lib,
  stdenv,
  fetchFromGitHub,
  cmake,
  pkg-config,
  libdwarf,
  libunwind,
  gtest,
  callPackage,
  zstd,
  nix-update-script,
  static ? stdenv.hostPlatform.isStatic,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "cpptrace";
  version = "1.0.4";

  src = fetchFromGitHub {
    owner = "jeremy-rifkin";
    repo = "cpptrace";
    tag = "v${finalAttrs.version}";
    hash = "sha256-KmAJEEU1aTKwleGBllSxlrsO4jVSTKnSTQQZyJ50loY=";
  };

  patches = [
    ./0001-Use-libdwarf-2-as-the-base-include-path.patch
  ];

  nativeBuildInputs = [
    cmake
    pkg-config
  ];

  buildInputs = [
    (lib.getDev libdwarf)
    libunwind
  ];

  propagatedBuildInputs = [
    zstd
  ]
  ++ (lib.optionals static [
    libdwarf
    libunwind
  ]);

  cmakeFlags = [
    (lib.cmakeBool "CPPTRACE_USE_EXTERNAL_LIBDWARF" true)
    (lib.cmakeBool "CPPTRACE_FIND_LIBDWARF_WITH_PKGCONFIG" true)
    (lib.cmakeBool "BUILD_SHARED_LIBS" (!static))
    (lib.cmakeBool "BUILD_TESTING" finalAttrs.finalPackage.doCheck)
    (lib.cmakeBool "CPPTRACE_USE_EXTERNAL_GTEST" true)
    (lib.cmakeBool "CPPTRACE_UNWIND_WITH_LIBUNWIND" true)
  ];

  checkInputs = [ gtest ];

  preCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
    dsymutil unittest
  '';

  doCheck = true;

  passthru = {
    updateScript = nix-update-script { };
    tests =
      let
        mkIntegrationTest =
          { static }:
          callPackage ./findpackage-integration.nix {
            src = "${finalAttrs.src}/test/findpackage-integration";
            checkOutput = finalAttrs.finalPackage.doCheck;
            inherit static;
          };
      in
      {
        findpackage-integration-shared = mkIntegrationTest { static = false; };
        findpackage-integration-static = mkIntegrationTest { static = true; };
      };
  };

  meta = {
    changelog = "https://github.com/jeremy-rifkin/cpptrace/releases/tag/v${finalAttrs.version}";
    description = "Simple, portable, and self-contained stacktrace library for C++11 and newer";
    homepage = "https://github.com/jeremy-rifkin/cpptrace";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ xokdvium ];
    platforms = lib.platforms.all;
  };
})