about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/build-managers/bear/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/tools/build-managers/bear/default.nix')
-rw-r--r--nixpkgs/pkgs/development/tools/build-managers/bear/default.nix41
1 files changed, 36 insertions, 5 deletions
diff --git a/nixpkgs/pkgs/development/tools/build-managers/bear/default.nix b/nixpkgs/pkgs/development/tools/build-managers/bear/default.nix
index 880184880db1..431f7b1773f6 100644
--- a/nixpkgs/pkgs/development/tools/build-managers/bear/default.nix
+++ b/nixpkgs/pkgs/development/tools/build-managers/bear/default.nix
@@ -2,6 +2,7 @@
 , fetchFromGitHub
 , fetchpatch
 , cmake
+, ninja
 , pkg-config
 , grpc
 , protobuf
@@ -13,6 +14,9 @@
 , zlib
 , sqlite
 , re2
+, lit
+, python3
+, coreutils
 }:
 
 stdenv.mkDerivation rec {
@@ -26,7 +30,15 @@ stdenv.mkDerivation rec {
     hash = "sha256-1nZPzgLWcmaRkOUXdm16IW2Nw/p1w8GBGEfZX/v+En0=";
   };
 
-  nativeBuildInputs = [ cmake pkg-config ];
+  nativeBuildInputs = [
+    cmake
+    ninja
+    pkg-config
+
+    # Used for functional tests, which run during buildPhase.
+    lit
+    python3
+  ];
 
   buildInputs = [
     grpc
@@ -41,13 +53,32 @@ stdenv.mkDerivation rec {
     re2
   ];
 
+  cmakeFlags = [
+    # Build system and generated files concatenate install prefix and
+    # CMAKE_INSTALL_{BIN,LIB}DIR, which breaks if these are absolute paths.
+    "-DCMAKE_INSTALL_BINDIR=bin"
+    "-DCMAKE_INSTALL_LIBDIR=lib"
+    (lib.cmakeBool "ENABLE_UNIT_TESTS" false)
+    (lib.cmakeBool "ENABLE_FUNC_TESTS" false)
+  ];
+
   patches = [
-    # Default libexec would be set to /nix/store/*-bear//nix/store/*-bear/libexec/...
-    ./no-double-relative.patch
+    # Fix toolchain environment variable handling and the Darwin SIP check.
+    ./fix-functional-tests.patch
   ];
 
+  postPatch = ''
+    patchShebangs test/bin
+
+    # /usr/bin/env is used in test commands and embedded scripts.
+    find test -name '*.sh' \
+      -exec sed -ie 's|/usr/bin/env|${coreutils}/bin/env|g' {} +
+  '';
+
+  # Functional tests use loopback networking.
+  __darwinAllowLocalNetworking = true;
+
   meta = with lib; {
-    broken = stdenv.isDarwin;
     description = "Tool that generates a compilation database for clang tooling";
     longDescription = ''
       Note: the bear command is very useful to generate compilation commands
@@ -57,6 +88,6 @@ stdenv.mkDerivation rec {
     homepage = "https://github.com/rizsotto/Bear";
     license = licenses.gpl3Plus;
     platforms = platforms.unix;
-    maintainers = with maintainers; [ babariviere qyliss ];
+    maintainers = with maintainers; [ babariviere ];
   };
 }