From d4ca1b8a899d6614ef06eea5bd18b734987c209e Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Sat, 15 Oct 2022 13:51:41 +0300 Subject: [PATCH] re2: switch to CMake --- pkgs/development/libraries/re2/default.nix | 79 +++++++++++----------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/pkgs/development/libraries/re2/default.nix b/pkgs/development/libraries/re2/default.nix index 2e163a79d596..857da102bb8c 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" ]; + + nativeBuildInputs = [ cmake ninja ]; + + postPatch = '' + substituteInPlace re2Config.cmake.in \ + --replace "\''${PACKAGE_PREFIX_DIR}/" "" ''; - buildFlags = lib.optionals stdenv.hostPlatform.isStatic [ "static" ]; + # Needed for case-insensitive filesystems (i.e. MacOS) because a file named + # BUILD already exists. + cmakeBuildDir = "build_dir"; - enableParallelBuilding = true; + cmakeFlags = lib.optional (!stdenv.hostPlatform.isStatic) "-DBUILD_SHARED_LIBS:BOOL=ON"; + + # This installs a pkg-config definition. + postInstall = '' + pushd "$src" + make common-install prefix="$dev" SED_INPLACE="sed -i" + popd + ''; - preCheck = "patchShebangs runtests"; doCheck = true; - checkTarget = if stdenv.hostPlatform.isStatic then "static-test" else "test"; - installTargets = lib.optionals stdenv.hostPlatform.isStatic [ "static-install" ]; - - doInstallCheck = true; - installCheckTarget = if stdenv.hostPlatform.isStatic then "static-testinstall" else "testinstall"; - - 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; }; }