Unverified Commit 91e51b33 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

thrift: 0.18.1 -> 0.22.0 + clean (#445433)

parents 2cd3686f c9041aef
Loading
Loading
Loading
Loading
+18 −60
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchurl,
  fetchpatch,
  fetchFromGitHub,
  boost,
  zlib,
  libevent,
@@ -12,16 +11,19 @@
  pkg-config,
  bison,
  flex,
  ctestCheckHook,
  static ? stdenv.hostPlatform.isStatic,
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "thrift";
  version = "0.18.1";
  version = "0.22.0";

  src = fetchurl {
    url = "https://archive.apache.org/dist/thrift/${version}/${pname}-${version}.tar.gz";
    hash = "sha256-BMbxDl14jKeOE+4u8NIVLHsHDAr1VIPWuULinP8pZyY=";
  src = fetchFromGitHub {
    owner = "apache";
    repo = "thrift";
    tag = "v${finalAttrs.version}";
    hash = "sha256-gGAO+D0A/hEoHMm6OvRBc1Mks9y52kfd0q/Sg96pdW4=";
  };

  # Workaround to make the Python wrapper not drop this package:
@@ -58,62 +60,26 @@ stdenv.mkDerivation rec {
    zlib
  ];

  postPatch = ''
    # Python 3.10 related failures:
    # SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats
    # AttributeError: module 'collections' has no attribute 'Hashable'
    substituteInPlace test/py/RunClientServer.py \
      --replace "'FastbinaryTest.py'," "" \
      --replace "'TestEof.py'," "" \
      --replace "'TestFrozen.py'," ""

    # these functions are removed in Python3.12
    substituteInPlace test/py/SerializationTest.py \
      --replace-fail "assertEquals" "assertEqual" \
      --replace-fail "assertNotEquals" "assertNotEqual"
  '';
  nativeCheckInputs = [ ctestCheckHook ];

  preConfigure = ''
    export PY_PREFIX=$out
  '';

  patches = [
    # ToStringTest.cpp is failing from some reason due to locale issue, this
    # doesn't disable all UnitTests as in Darwin.
    ./disable-failing-test.patch
    (fetchpatch {
      name = "setuptools-gte-62.1.0.patch"; # https://github.com/apache/thrift/pull/2635
      url = "https://github.com/apache/thrift/commit/c41ad9d5119e9bdae1746167e77e224f390f2c42.diff";
      hash = "sha256-FkErrg/6vXTomS4AsCsld7t+Iccc55ZiDaNjJ3W1km0=";
    })
    (fetchpatch {
      name = "thrift-install-FindLibevent.patch"; # https://github.com/apache/thrift/pull/2726
      url = "https://github.com/apache/thrift/commit/2ab850824f75d448f2ba14a468fb77d2594998df.diff";
      hash = "sha256-ejMKFG/cJgoPlAFzVDPI4vIIL7URqaG06/IWdQ2NkhY=";
    })
    (fetchpatch {
      name = "thrift-fix-tests-OpenSSL3.patch"; # https://github.com/apache/thrift/pull/2760
      url = "https://github.com/apache/thrift/commit/eae3ac418f36c73833746bcd53e69ed8a12f0e1a.diff";
      hash = "sha256-0jlN4fo94cfGFUKcLFQgVMI/x7uxn5OiLiFk6txVPzs=";
    })
  ];

  cmakeFlags = [
    "-DBUILD_JAVASCRIPT:BOOL=OFF"
    "-DBUILD_NODEJS:BOOL=OFF"
    (lib.cmakeBool "BUILD_JAVASCRIPT" false)
    (lib.cmakeBool "BUILD_NODEJS" false)
    (lib.cmakeBool "BUILD_SHARED_LIBS" (!static))
    (lib.cmakeBool "OPENSSL_USE_STATIC_LIBS" static)

    # FIXME: Fails to link in static mode with undefined reference to
    # `boost::unit_test::unit_test_main(bool (*)(), int, char**)'
    "-DBUILD_TESTING:BOOL=${if static then "OFF" else "ON"}"
  ]
  ++ lib.optionals static [
    "-DWITH_STATIC_LIB:BOOL=ON"
    "-DOPENSSL_USE_STATIC_LIBS=ON"
    (lib.cmakeBool "BUILD_TESTING" (!static))
  ];

  disabledTests = [
    "PythonTestSSLSocket"
    "PythonThriftTNonblockingServer"
    "UnitTests" # getaddrinfo() -> -3; Temporary failure in name resolution
    "python_test" # many failures about python 2 or network things
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    # Tests that hang up in the Darwin sandbox
@@ -138,14 +104,6 @@ stdenv.mkDerivation rec {

  doCheck = !static;

  checkPhase = ''
    runHook preCheck

    ${lib.optionalString stdenv.hostPlatform.isDarwin "DY"}LD_LIBRARY_PATH=$PWD/lib ctest -E "($(echo "$disabledTests" | tr " " "|"))"

    runHook postCheck
  '';

  enableParallelChecking = false;

  meta = with lib; {
@@ -156,4 +114,4 @@ stdenv.mkDerivation rec {
    platforms = platforms.linux ++ platforms.darwin;
    maintainers = with maintainers; [ bjornfor ];
  };
}
})