Unverified Commit 79d5de60 authored by Yueh-Shun Li's avatar Yueh-Shun Li Committed by GitHub
Browse files

rdkafka: switch to cmake, split outputs, remove static library from non-static...

rdkafka: switch to cmake, split outputs, remove static library from non-static targets, fix static build (#349725)
parents 181ac6f4 0aca4a28
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -41,6 +41,11 @@ stdenv.mkDerivation rec {
      url = "https://github.com/morganstanley/modern-cpp-kafka/commit/236f8f91f5c3ad6e1055a6f55cd3aebd218e1226.patch";
      hash = "sha256-cy568TQUu08sadq79hDz9jMvDqiDjfr+1cLMxFWGm1Q=";
    })
    (fetchpatch {
      name = "macos-find-dylib.patch";
      url = "https://github.com/morganstanley/modern-cpp-kafka/commit/dc2753cd95b607a7202b40bad3aad472558bf350.patch";
      hash = "sha256-Te3GwAVRDyb6GFWlvkq1mIcNeXCtMyLr+/w1LilUYbE=";
    })
  ];

  postPatch = ''
@@ -53,12 +58,17 @@ stdenv.mkDerivation rec {
  buildInputs = [ boost ];
  propagatedBuildInputs = [ rdkafka ];

  cmakeFlags = [
    "-DLIBRDKAFKA_INCLUDE_DIR=${rdkafka.out}/include"
    "-DGTEST_LIBRARY_DIR=${gtest.out}/lib"
    "-DGTEST_INCLUDE_DIR=${gtest.dev}/include"
    "-DRAPIDJSON_INCLUDE_DIRS=${rapidjson.out}/include"
    "-DCMAKE_CXX_FLAGS=-Wno-uninitialized"
  cmakeFlags =
    let
      inherit (lib) cmakeFeature getLib getInclude;
    in
    [
      (cmakeFeature "LIBRDKAFKA_LIBRARY_DIR" "${getLib rdkafka}/lib")
      (cmakeFeature "LIBRDKAFKA_INCLUDE_DIR" "${getInclude rdkafka}/include")
      (cmakeFeature "GTEST_LIBRARY_DIR" "${getLib gtest}/lib")
      (cmakeFeature "GTEST_INCLUDE_DIR" "${getInclude gtest}/include")
      (cmakeFeature "RAPIDJSON_INCLUDE_DIRS" "${getInclude rapidjson}/include")
      (cmakeFeature "CMAKE_CXX_FLAGS" "-Wno-uninitialized")
    ];

  checkInputs = [
+28 −7
Original line number Diff line number Diff line
@@ -4,11 +4,10 @@
  fetchFromGitHub,
  zlib,
  zstd,
  pkg-config,
  python3,
  openssl,
  which,
  curl,
  cmake,
  ninja,
}:

stdenv.mkDerivation (finalAttrs: {
@@ -22,10 +21,14 @@ stdenv.mkDerivation (finalAttrs: {
    sha256 = "sha256-OCCsxgEO8UvCcC0XwzqpqmaT8dV0Klrspp+2o1FbH2Y=";
  };

  outputs = [
    "out"
    "dev"
  ];

  nativeBuildInputs = [
    pkg-config
    python3
    which
    cmake
    ninja
  ];

  buildInputs = [
@@ -35,12 +38,30 @@ stdenv.mkDerivation (finalAttrs: {
    curl
  ];

  env.NIX_CFLAGS_COMPILE = "-Wno-error=strict-overflow";
  # examples and tests don't build on darwin statically
  cmakeFlags = [
    (lib.cmakeBool "RDKAFKA_BUILD_STATIC" stdenv.hostPlatform.isStatic)
    (lib.cmakeBool "RDKAFKA_BUILD_TESTS" (
      !stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isStatic
    ))
    (lib.cmakeBool "RDKAFKA_BUILD_EXAMPLES" (
      !stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isStatic
    ))
    (lib.cmakeFeature "CMAKE_C_FLAGS" "-Wno-error=strict-overflow")
  ];

  postPatch = ''
    patchShebangs .
  '';

  postFixup = lib.optionalString stdenv.hostPlatform.isStatic ''
    # rdkafka changes the library names for static libraries but users in pkgsStatic aren't likely to be aware of this
    # make sure the libraries are findable with both names
    for pc in rdkafka{,++}; do
      ln -s $dev/lib/pkgconfig/$pc{-static,}.pc
    done
  '';

  enableParallelBuilding = true;

  meta = with lib; {
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ buildPecl {

  postPhpize = ''
    substituteInPlace configure \
      --replace 'SEARCH_PATH="/usr/local /usr"' 'SEARCH_PATH=${rdkafka}'
      --replace-fail 'SEARCH_PATH="/usr/local /usr"' 'SEARCH_PATH=${lib.getInclude rdkafka}'
  '';

  meta = with lib; {