1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 pkg-config,
7 libdwarf,
8 gtest,
9 callPackage,
10 zstd,
11 nix-update-script,
12 static ? stdenv.hostPlatform.isStatic,
13}:
14
15stdenv.mkDerivation (finalAttrs: {
16 pname = "cpptrace";
17 version = "1.0.3";
18
19 src = fetchFromGitHub {
20 owner = "jeremy-rifkin";
21 repo = "cpptrace";
22 tag = "v${finalAttrs.version}";
23 hash = "sha256-8H1eJQYQn1DsVsJ0OpJAOJSWD/0iSn1SQLzg1elyEmM=";
24 };
25
26 patches = [
27 ./0001-Use-libdwarf-2-as-the-base-include-path.patch
28 ];
29
30 nativeBuildInputs = [
31 cmake
32 pkg-config
33 ];
34
35 buildInputs = [ (lib.getDev libdwarf) ];
36
37 propagatedBuildInputs = [ zstd ] ++ (lib.optionals static [ libdwarf ]);
38
39 cmakeFlags = [
40 (lib.cmakeBool "CPPTRACE_USE_EXTERNAL_LIBDWARF" true)
41 (lib.cmakeBool "CPPTRACE_FIND_LIBDWARF_WITH_PKGCONFIG" true)
42 (lib.cmakeBool "BUILD_SHARED_LIBS" (!static))
43 (lib.cmakeBool "BUILD_TESTING" finalAttrs.finalPackage.doCheck)
44 (lib.cmakeBool "CPPTRACE_USE_EXTERNAL_GTEST" true)
45 ];
46
47 checkInputs = [ gtest ];
48
49 doCheck = true;
50
51 passthru = {
52 updateScript = nix-update-script { };
53 tests =
54 let
55 mkIntegrationTest =
56 { static }:
57 callPackage ./findpackage-integration.nix {
58 src = "${finalAttrs.src}/test/findpackage-integration";
59 checkOutput = finalAttrs.finalPackage.doCheck;
60 inherit static;
61 };
62 in
63 {
64 findpackage-integration-shared = mkIntegrationTest { static = false; };
65 findpackage-integration-static = mkIntegrationTest { static = true; };
66 };
67 };
68
69 meta = {
70 changelog = "https://github.com/jeremy-rifkin/cpptrace/releases/tag/v${finalAttrs.version}";
71 description = "Simple, portable, and self-contained stacktrace library for C++11 and newer";
72 homepage = "https://github.com/jeremy-rifkin/cpptrace";
73 license = lib.licenses.mit;
74 maintainers = with lib.maintainers; [ xokdvium ];
75 platforms = lib.platforms.all;
76 };
77})