libjxl: build gdk-pixbuf loader and thumbnailer

This commit is contained in:
zzzsyyy 2024-03-29 20:41:25 +08:00
parent e5bc6d679f
commit 319f05e7db
No known key found for this signature in database
GPG Key ID: 3F2409FFE586FB7F

View File

@ -8,15 +8,22 @@
, libjpeg , libjpeg
, libpng , libpng
, libwebp , libwebp
, gdk-pixbuf
, openexr_3 , openexr_3
, pkg-config , pkg-config
, makeWrapper
, zlib , zlib
, asciidoc , asciidoc
, graphviz , graphviz
, doxygen , doxygen
, python3 , python3
, lcms2
}: }:
let
loadersPath = "${gdk-pixbuf.binaryDir}/jxl-loaders.cache";
in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "libjxl"; pname = "libjxl";
version = "0.9.1"; version = "0.9.1";
@ -37,6 +44,8 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ nativeBuildInputs = [
cmake cmake
pkg-config pkg-config
gdk-pixbuf
makeWrapper
asciidoc asciidoc
doxygen doxygen
python3 python3
@ -63,12 +72,14 @@ stdenv.mkDerivation rec {
# conclusively in its README or otherwise; they can best be determined # conclusively in its README or otherwise; they can best be determined
# by checking the CMake output for "Could NOT find". # by checking the CMake output for "Could NOT find".
buildInputs = [ buildInputs = [
lcms2
giflib giflib
gperftools # provides `libtcmalloc` gperftools # provides `libtcmalloc`
gtest gtest
libjpeg libjpeg
libpng libpng
libwebp libwebp
gdk-pixbuf
openexr_3 openexr_3
zlib zlib
]; ];
@ -96,17 +107,30 @@ stdenv.mkDerivation rec {
# Viewer tools for evaluation. # Viewer tools for evaluation.
# "-DJPEGXL_ENABLE_VIEWERS=ON" # "-DJPEGXL_ENABLE_VIEWERS=ON"
# TODO: Update this package to enable this (overridably via an option):
# Enable plugins, such as: # Enable plugins, such as:
# * the `gdk-pixbuf` one, which allows applications like `eog` to load jpeg-xl files # * the `gdk-pixbuf` one, which allows applications like `eog` to load jpeg-xl files
# * the `gimp` one, which allows GIMP to load jpeg-xl files # * the `gimp` one, which allows GIMP to load jpeg-xl files
# "-DJPEGXL_ENABLE_PLUGINS=ON" "-DJPEGXL_ENABLE_PLUGINS=ON"
] ++ lib.optionals stdenv.hostPlatform.isStatic [ ] ++ lib.optionals stdenv.hostPlatform.isStatic [
"-DJPEGXL_STATIC=ON" "-DJPEGXL_STATIC=ON"
] ++ lib.optionals stdenv.hostPlatform.isAarch32 [ ] ++ lib.optionals stdenv.hostPlatform.isAarch32 [
"-DJPEGXL_FORCE_NEON=ON" "-DJPEGXL_FORCE_NEON=ON"
]; ];
postPatch = ''
substituteInPlace plugins/gdk-pixbuf/jxl.thumbnailer \
--replace '/usr/bin/gdk-pixbuf-thumbnailer' "$out/libexec/gdk-pixbuf-thumbnailer-jxl"
'';
postInstall = ''
GDK_PIXBUF_MODULEDIR="$out/${gdk-pixbuf.moduleDir}" \
GDK_PIXBUF_MODULE_FILE="$out/${loadersPath}" \
gdk-pixbuf-query-loaders --update-cache
mkdir -p "$out/bin"
makeWrapper ${gdk-pixbuf}/bin/gdk-pixbuf-thumbnailer "$out/libexec/gdk-pixbuf-thumbnailer-jxl" \
--set GDK_PIXBUF_MODULE_FILE "$out/${loadersPath}"
'';
CXXFLAGS = lib.optionalString stdenv.hostPlatform.isAarch32 "-mfp16-format=ieee"; CXXFLAGS = lib.optionalString stdenv.hostPlatform.isAarch32 "-mfp16-format=ieee";
# FIXME x86_64-darwin: # FIXME x86_64-darwin: