about summary refs log tree commit diff
path: root/pkgs/development/libraries/re2
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2022-10-15 13:51:41 +0300
committerAzat Bahawi <azat@bahawi.net>2022-10-16 19:27:49 +0300
commitd4ca1b8a899d6614ef06eea5bd18b734987c209e (patch)
tree367aad33187b2d928333c00f97fa9d7cf45f2294 /pkgs/development/libraries/re2
parentb286501a5eadad160362299c15941a642c427317 (diff)
re2: switch to CMake
Diffstat (limited to 'pkgs/development/libraries/re2')
-rw-r--r--pkgs/development/libraries/re2/default.nix79
1 files changed, 41 insertions, 38 deletions
diff --git a/pkgs/development/libraries/re2/default.nix b/pkgs/development/libraries/re2/default.nix
index 2e163a79d596b..857da102bb8c0 100644
--- a/pkgs/development/libraries/re2/default.nix
+++ b/pkgs/development/libraries/re2/default.nix
@@ -1,16 +1,13 @@
 { lib
 , stdenv
 , fetchFromGitHub
-, nix-update-script
-
-# for passthru.tests
-, bazel
+, cmake
+, ninja
 , chromium
 , grpc
 , haskellPackages
 , mercurial
-, ninja
-, python3
+, python3Packages
 }:
 
 stdenv.mkDerivation rec {
@@ -21,48 +18,54 @@ stdenv.mkDerivation rec {
     owner = "google";
     repo = "re2";
     rev = version;
-    sha256 = "sha256-UontAjOXpnPcOgoFHjf+1WSbCR7h58/U7nn4meT200Y=";
+    hash = "sha256-UontAjOXpnPcOgoFHjf+1WSbCR7h58/U7nn4meT200Y=";
   };
 
-  preConfigure = ''
-    substituteInPlace Makefile --replace "/usr/local" "$out"
-    # we're using gnu sed, even on darwin
-    substituteInPlace Makefile  --replace "SED_INPLACE=sed -i '''" "SED_INPLACE=sed -i"
-  '';
+  outputs = [ "out" "dev" ];
 
-  buildFlags = lib.optionals stdenv.hostPlatform.isStatic [ "static" ];
+  nativeBuildInputs = [ cmake ninja ];
 
-  enableParallelBuilding = true;
+  postPatch = ''
+    substituteInPlace re2Config.cmake.in \
+      --replace "\''${PACKAGE_PREFIX_DIR}/" ""
+  '';
 
-  preCheck = "patchShebangs runtests";
-  doCheck = true;
-  checkTarget = if stdenv.hostPlatform.isStatic then "static-test" else "test";
+  # Needed for case-insensitive filesystems (i.e. MacOS) because a file named
+  # BUILD already exists.
+  cmakeBuildDir = "build_dir";
+
+  cmakeFlags = lib.optional (!stdenv.hostPlatform.isStatic) "-DBUILD_SHARED_LIBS:BOOL=ON";
 
-  installTargets = lib.optionals stdenv.hostPlatform.isStatic [ "static-install" ];
+  # This installs a pkg-config definition.
+  postInstall = ''
+    pushd "$src"
+    make common-install prefix="$dev" SED_INPLACE="sed -i"
+    popd
+  '';
 
-  doInstallCheck = true;
-  installCheckTarget = if stdenv.hostPlatform.isStatic then "static-testinstall" else "testinstall";
+  doCheck = true;
 
-  passthru = {
-    updateScript = nix-update-script {
-      attrPath = pname;
-    };
-    tests = {
-      inherit
-        chromium
-        grpc
-        mercurial;
-      inherit (python3.pkgs)
-        fb-re2
-        google-re2;
-      haskellPackages-re2 = haskellPackages.re2;
-    };
+  passthru.tests = {
+    inherit
+      chromium
+      grpc
+      mercurial;
+    inherit (python3Packages)
+      fb-re2
+      google-re2;
+    haskell-re2 = haskellPackages.re2;
   };
 
-  meta = {
+  meta = with lib; {
+    description = "A regular expression library";
+    longDescription = ''
+      RE2 is a fast, safe, thread-friendly alternative to backtracking regular
+      expression engines like those used in PCRE, Perl, and Python. It is a C++
+      library.
+    '';
+    license = licenses.bsd3;
     homepage = "https://github.com/google/re2";
-    description = "An efficient, principled regular expression library";
-    license = lib.licenses.bsd3;
-    platforms = with lib.platforms; all;
+    maintainers = with maintainers; [ azahi ];
+    platforms = platforms.all;
   };
 }