<commit_before>{ stdenv
, fetchpatch
, fetchTritonPatch
, fetchurl

, curl
, cairo
, freetype
, fontconfig
, glib
, gobject-introspection
, libtiff
, lcms2
, libjpeg
, libpng
, openjpeg
, qt5
, zlib

, utils ? false
, suffix ? "glib"
}:

let
  inherit (stdenv.lib)
    enFlag
    optional
    optionals
    wtFlag;
in

assert (
  suffix == "glib" ||
  suffix == "qt5" ||
  suffix == "utils"
);

stdenv.mkDerivation rec {
  name = "poppler-${suffix}-${version}";
  version = "0.40.0";

  src = fetchurl {
    url = "http://poppler.freedesktop.org/poppler-${version}.tar.xz";
    sha256 = "1bbfxq0aclhaiyj1jcjr583prv5662jvphdqsafgr3q3srwa43dw";
  };

  buildInputs = [
    cairo
    curl
    fontconfig
    freetype
    glib
    gobject-introspection
    lcms2
    libjpeg
    libpng
    libtiff
    openjpeg
    qt5
    zlib
  ];

  patches = [
    (fetchTritonPatch {
      rev = "d3fc5e59bd2b4b465c2652aae5e7428b24eb5669";
      file = "poppler/poppler-datadir_env.patch";
      sha256 = "da3dd1d57a7ef0dcda7442dff2fff5375e249ba85caba9828be4fc51bfa300ff";
    })
  ];

  configureFlags = [
    "--enable-xpdf-headers"
    "--disable-single-precision"
    "--disable-fixed-point"
    "--enable-cmyk"
    (enFlag "libopenjpeg" (openjpeg != null) null)
    (enFlag "libtiff" (libtiff != null) null)
    (enFlag "zlib" (zlib != null) null)
    (enFlag "libcurl" (curl != null) null)
    (enFlag "libjpeg" (libjpeg != null) null)
    (enFlag "libpng" (libpng != null) null)
    (wtFlag "font-configuration" (fontconfig != null) "fontconfig")
    #"--enable-splash"
    (enFlag "cairo-output" (cairo != null) null)
    (enFlag "poppler-glib" (
      cairo != null &&
      glib != null &&
      gobject-introspection != null) null)
    "--disable-popper-qt4"
    (enFlag "poppler-qt5" (qt5 != null) null)
    (enFlag "poppler-cpp" true null)
    #"gtk-test"
    (enFlag "utils" utils null)
    #"compile-warnings"
    #"cms"
    #"testdatadir"
  ];

  meta = with stdenv.lib; {
    description = "A PDF rendering library";
    homepage = http://poppler.freedesktop.org/;
    license = licenses.gpl2;
    maintainers = with maintainers; [
      codyopel
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}
<commit_msg>poppler: 0.40.0 -> 0.46.0<commit_after>{ stdenv
, cmake
, fetchTritonPatch
, fetchurl

, curl
, cairo
, freetype
, fontconfig
, glib
, gobject-introspection
, libtiff
, lcms2
, libjpeg
, libpng
, nspr
, nss
, openjpeg
, qt5
, zlib

, utils ? false
, suffix ? "glib"
}:

# FIXME: gobject-introspection and openjpeg support is not working currently

let
  inherit (stdenv.lib)
    cmFlag
    enFlag
    optional
    optionals
    wtFlag;

  # If a is true, return b
  ifDo = a: b:
    if a then
      b
    else
      false;
in

assert (
  suffix == "glib" ||
  suffix == "qt5" ||
  suffix == "utils"
);

stdenv.mkDerivation rec {
  name = "poppler-${suffix}-${version}";
  version = "0.46.0";

  src = fetchurl {
    url = "https://poppler.freedesktop.org/poppler-${version}.tar.xz";
    sha256 = "967d35d13d61dee2fee656b80efef9e388a9e752bc79b7123f15b49c7769e487";
  };

  nativeBuildInputs = [
    cmake
  ];

  buildInputs = [
    cairo
    curl
    fontconfig
    freetype
    glib
    #gobject-introspection
    lcms2
    libjpeg
    libpng
    libtiff
    nspr
    nss
    openjpeg
    qt5
    zlib
  ];

  postUnpack = ''
    rm -v $sourceRoot/configure{,.ac}
  '';

  patches = [
    (fetchTritonPatch {
      rev = "d3fc5e59bd2b4b465c2652aae5e7428b24eb5669";
      file = "poppler/poppler-datadir_env.patch";
      sha256 = "da3dd1d57a7ef0dcda7442dff2fff5375e249ba85caba9828be4fc51bfa300ff";
    })
  ];

  cmakeFlags = [
    "-DBUILD_CPP_TESTS=OFF"
    "-DBUILD_GTK_TESTS=OFF"
    "-DBUILD_QT4_TESTS=OFF"
    "-DBUILD_QT5_TESTS=OFF"
    (cmFlag "ENABLE_CMS" (ifDo (lcms2 != null) "lcms2"))
    "-DENABLE_CPP=ON"
    (cmFlag "ENABLE_LIBCURL" (curl != null))
    (cmFlag "ENABLE_LIBOPENJPEG" (ifDo (openjpeg != null) "openjpeg2"))
    #"-DENABLE_SPLASH=ON"
    (cmFlag "ENABLE_UTILS" utils)
    "-DENABLE_XPDF_HEADERS=ON"
    (cmFlag "ENABLE_ZLIB" (zlib != null))
    (cmFlag "ENABLE_ZLIB_UNCOMPRESS" (zlib != null))
    (cmFlag "FONT_CONFIGURATION" (ifDo (fontconfig != null) "fontconfig"))
    "-DSPLASH_CMYK=ON"
    "-DUSE_FIXEDPOINT=OFF"
    "-DUSE_FLOAT=ON"
    (cmFlag "WITH_Cairo" (cairo != null))
    (cmFlag "WITH_GLIB" (
      cairo != null
      && glib != null
      && gobject-introspection != null))
    #(cmFlag "WITH_GObjectIntrospection" (gobject-introspection != null))
    #(cmFlag "WITH_GTK" (gtk3 != null))
    "-DWITH_Iconv=ON"
    (cmFlag "WITH_JPEG" (libjpeg != null))
    (cmFlag "WITH_NSS3" (nss != null))
    (cmFlag "WITH_PNG" (libpng != null))
    "-DWITH_Qt4=OFF"
    (cmFlag "WITH_TIFF" (libtiff != null))
  ];

  NIX_CFLAGS_COMPILE = [
    "-Wno-deprecated-declarations"
  ];

  meta = with stdenv.lib; {
    description = "A PDF rendering library";
    homepage = http://poppler.freedesktop.org/;
    license = licenses.gpl2;
    maintainers = with maintainers; [
      codyopel
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}

{'fraction_non_alphanumeric': 0.1379647749510763, 'fraction_numerical': 0.04324853228962818, 'mean_word_length': 2.8866920152091256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7370665', 'n_tokens_mistral': 2204, 'n_tokens_neox': 2065, 'n_words': 376}