pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / by-name / be / bear / package.nix
blob01d7560b930275eeb6e1521082de13d436497c31
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   cmake,
6   ninja,
7   pkg-config,
8   grpc,
9   protobuf,
10   openssl,
11   nlohmann_json,
12   gtest,
13   spdlog,
14   c-ares,
15   zlib,
16   sqlite,
17   re2,
18   lit,
19   python3,
20   coreutils,
23 stdenv.mkDerivation (finalAttrs: {
24   pname = "bear";
25   version = "3.1.5";
27   src = fetchFromGitHub {
28     owner = "rizsotto";
29     repo = "bear";
30     rev = finalAttrs.version;
31     hash = "sha256-pwdjytP+kmTwozRl1Gd0jUqRs3wfvcYPqiQvVwa6s9c=";
32   };
34   nativeBuildInputs = [
35     cmake
36     ninja
37     pkg-config
38   ];
40   buildInputs = [
41     grpc
42     protobuf
43     openssl
44     nlohmann_json
45     spdlog
46     c-ares
47     zlib
48     sqlite
49     re2
50   ];
52   patches = [
53     # This patch is necessary to run tests in a separate phase. By default
54     # test targets are run with ALL, which is not what we want. This patch creates
55     # separate 'test' step targets for each cmake ExternalProject:
56     # - BearTest-test (functional lit tests)
57     # - BearSource-test (unit tests via gtest)
58     ./0001-exclude-tests-from-all.patch
59   ];
61   nativeCheckInputs = [
62     lit
63     python3
64   ];
66   checkInputs = [
67     gtest
68   ];
70   cmakeFlags = [
71     # Build system and generated files concatenate install prefix and
72     # CMAKE_INSTALL_{BIN,LIB}DIR, which breaks if these are absolute paths.
73     "-DCMAKE_INSTALL_BINDIR=bin"
74     "-DCMAKE_INSTALL_LIBDIR=lib"
75     (lib.cmakeBool "ENABLE_UNIT_TESTS" finalAttrs.doCheck)
76     (lib.cmakeBool "ENABLE_FUNC_TESTS" finalAttrs.doCheck)
77   ];
79   checkTarget = lib.concatStringsSep " " [
80     "BearTest-test"
81     "BearSource-test"
82   ];
84   doCheck = true;
86   env = {
87     # Disable failing tests. The cause is not immediately clear.
88     LIT_FILTER_OUT = lib.concatStringsSep "|" [
89       "cases/compilation/output/config/filter_compilers.sh"
90       "cases/intercept/preload/posix/execvpe/success_to_resolve.c"
91       "cases/intercept/preload/posix/popen/success.c"
92       "cases/intercept/preload/posix/posix_spawnp/success_to_resolve.c"
93       "cases/intercept/preload/posix/system/success.c"
94       "cases/intercept/preload/shell_commands_intercepted_without_shebang.sh"
95     ];
96   };
98   postPatch = ''
99     patchShebangs test/bin
101     # /usr/bin/env is used in test commands and embedded scripts.
102     find test -name '*.sh' \
103       -exec sed -ie 's|/usr/bin/env|${coreutils}/bin/env|g' {} +
104   '';
106   # Functional tests use loopback networking.
107   __darwinAllowLocalNetworking = true;
109   meta = with lib; {
110     description = "Tool that generates a compilation database for clang tooling";
111     mainProgram = "bear";
112     longDescription = ''
113       Note: the bear command is very useful to generate compilation commands
114       e.g. for YouCompleteMe.  You just enter your development nix-shell
115       and run `bear make`.  It's not perfect, but it gets a long way.
116     '';
117     homepage = "https://github.com/rizsotto/Bear";
118     license = licenses.gpl3Plus;
119     platforms = platforms.unix;
120     maintainers = with maintainers; [ DieracDelta ];
121   };