summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/db/dbus-cpp/package.nix
blob: 7ca68e35d4d747c5409b9a049aeadfaa6f1374e3 (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
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
118
119
120
121
122
123
124
125
{
  stdenv,
  lib,
  fetchFromGitLab,
  gitUpdater,
  testers,
  boost,
  cmake,
  ctestCheckHook,
  dbus,
  doxygen,
  graphviz,
  gtest,
  libxml2,
  lomiri,
  pkg-config,
  process-cpp,
  properties-cpp,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "dbus-cpp";
  version = "5.0.6";

  src = fetchFromGitLab {
    owner = "ubports";
    repo = "development/core/lib-cpp/dbus-cpp";
    tag = finalAttrs.version;
    hash = "sha256-ehP+QW/tTR6tLHEiWGDbiYT9oAqlS346UaVTkJC5bSE=";
  };

  outputs = [
    "out"
    "dev"
    "doc"
    "examples"
  ];

  postPatch = ''
    substituteInPlace doc/CMakeLists.txt \
      --replace-fail 'DESTINATION share/''${CMAKE_PROJECT_NAME}/doc' 'DESTINATION ''${CMAKE_INSTALL_DOCDIR}'

    # Warning on aarch64-linux breaks build due to -Werror
    substituteInPlace CMakeLists.txt \
      --replace-fail '-Werror' ""

    # pkg-config output patching hook expects prefix variable here
    substituteInPlace data/dbus-cpp.pc.in \
      --replace-fail 'includedir=''${exec_prefix}' 'includedir=''${prefix}'
  ''
  + lib.optionalString (!finalAttrs.finalPackage.doCheck) ''
    substituteInPlace CMakeLists.txt \
      --replace-fail 'add_subdirectory(tests)' '# add_subdirectory(tests)'
  '';

  strictDeps = true;

  nativeBuildInputs = [
    cmake
    doxygen
    graphviz
    pkg-config
  ];

  buildInputs = [
    boost
    lomiri.cmake-extras
    dbus
    libxml2
    process-cpp
    properties-cpp
  ];

  nativeCheckInputs = [
    ctestCheckHook
    dbus
  ];

  checkInputs = [
    gtest
  ];

  cmakeFlags = [
    (lib.cmakeBool "DBUS_CPP_ENABLE_DOC_GENERATION" true)
  ];

  doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;

  # DBus, parallelism messes with communication
  enableParallelChecking = false;

  disabledTests = [
    # Flaky flaky flaky. Spams D-Bus with hundreds of requests, and if any is dropped, the test fails.
    "async_execution_load_test"

    # Possible memory corruption in Executor.TimeoutsAreHandledCorrectly
    # https://gitlab.com/ubports/development/core/lib-cpp/dbus-cpp/-/issues/10
    "executor_test"
  ];

  preFixup = ''
    moveToOutput libexec/examples $examples
  '';

  passthru = {
    tests.pkg-config = testers.hasPkgConfigModules {
      package = finalAttrs.finalPackage;
      versionCheck = true;
    };
    updateScript = gitUpdater { };
  };

  meta = {
    description = "Dbus-binding leveraging C++-11";
    homepage = "https://gitlab.com/ubports/development/core/lib-cpp/dbus-cpp";
    changelog = "https://gitlab.com/ubports/development/core/lib-cpp/dbus-cpp/-/blob/${finalAttrs.version}/ChangeLog";
    license = lib.licenses.lgpl3Only;
    maintainers = with lib.maintainers; [ OPNA2608 ];
    mainProgram = "dbus-cppc";
    platforms = lib.platforms.linux;
    pkgConfigModules = [
      "dbus-cpp"
    ];
  };
})