Merge pull request #196123 from azahi/re2

re2: switch to CMake
This commit is contained in:
Sandro 2022-10-25 19:56:09 +02:00 committed by GitHub
commit 4075fed47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
};
}