homebrew-core/Formula/gdk-pixbuf.rb

121 lines
3.8 KiB
Ruby

class GdkPixbuf < Formula
desc "Toolkit for image loading and pixel buffer manipulation"
homepage "https://gtk.org"
url "https://download.gnome.org/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.8.tar.xz"
sha256 "84acea3acb2411b29134b32015a5b1aaa62844b19c4b1ef8b8971c6b0759f4c6"
license "LGPL-2.1-or-later"
bottle do
sha256 arm64_monterey: "a64b406a58be74567a9409ad763937b14a2619754734e5ee91c840965d1bd354"
sha256 arm64_big_sur: "23e63e68d3a4e1b7d62a8380184d2070f054e4377331a2861bda7b9447bb3466"
sha256 monterey: "da834da5d08e57860283a288993b954d978fd8b6bc5f441dfb9b9f42d28ff082"
sha256 big_sur: "b2ad72a9e6f1b793e39cd9a079838342fe2e1ceae21a793a757a3e828e2c9b7e"
sha256 catalina: "2767c9d0973ac43175331aa5f6b3d543cbde679343f813052bb4c5155a14b4eb"
sha256 x86_64_linux: "46f21d535b3568bc3c3ec11ce063a220e7b01d7b9df164a497b5dc939bbf15e7"
end
depends_on "glib-utils" => :build
depends_on "gobject-introspection" => :build
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "glib"
depends_on "jpeg"
depends_on "libpng"
depends_on "libtiff"
on_linux do
depends_on "shared-mime-info"
end
# gdk-pixbuf has an internal version number separate from the overall
# version number that specifies the location of its module and cache
# files, this will need to be updated if that internal version number
# is ever changed (as evidenced by the location no longer existing)
def gdk_so_ver
"2.0"
end
def gdk_module_ver
"2.10.0"
end
def install
inreplace "gdk-pixbuf/meson.build",
"-DGDK_PIXBUF_LIBDIR=\"@0@\"'.format(gdk_pixbuf_libdir)",
"-DGDK_PIXBUF_LIBDIR=\"@0@\"'.format('#{HOMEBREW_PREFIX}/lib')"
args = std_meson_args + %w[
-Drelocatable=false
-Dnative_windows_loaders=false
-Dinstalled_tests=false
-Dman=false
-Dgtk_doc=false
-Dpng=enabled
-Dtiff=enabled
-Djpeg=enabled
-Dintrospection=enabled
]
ENV["DESTDIR"] = "/"
mkdir "build" do
system "meson", *args, ".."
system "ninja", "-v"
system "ninja", "install"
end
# Other packages should use the top-level modules directory
# rather than dumping their files into the gdk-pixbuf keg.
inreplace lib/"pkgconfig/gdk-pixbuf-#{gdk_so_ver}.pc" do |s|
libv = s.get_make_var "gdk_pixbuf_binary_version"
s.change_make_var! "gdk_pixbuf_binarydir",
HOMEBREW_PREFIX/"lib/gdk-pixbuf-#{gdk_so_ver}"/libv
end
end
# The directory that loaders.cache gets linked into, also has the "loaders"
# directory that is scanned by gdk-pixbuf-query-loaders in the first place
def module_dir
"#{HOMEBREW_PREFIX}/lib/gdk-pixbuf-#{gdk_so_ver}/#{gdk_module_ver}"
end
def post_install
ENV["GDK_PIXBUF_MODULEDIR"] = "#{module_dir}/loaders"
system "#{bin}/gdk-pixbuf-query-loaders", "--update-cache"
end
test do
(testpath/"test.c").write <<~EOS
#include <gdk-pixbuf/gdk-pixbuf.h>
int main(int argc, char *argv[]) {
GType type = gdk_pixbuf_get_type();
return 0;
}
EOS
gettext = Formula["gettext"]
glib = Formula["glib"]
libpng = Formula["libpng"]
pcre = Formula["pcre"]
flags = (ENV.cflags || "").split + (ENV.cppflags || "").split + (ENV.ldflags || "").split
flags += %W[
-I#{gettext.opt_include}
-I#{glib.opt_include}/glib-2.0
-I#{glib.opt_lib}/glib-2.0/include
-I#{include}/gdk-pixbuf-2.0
-I#{libpng.opt_include}/libpng16
-I#{pcre.opt_include}
-D_REENTRANT
-L#{gettext.opt_lib}
-L#{glib.opt_lib}
-L#{lib}
-lgdk_pixbuf-2.0
-lglib-2.0
-lgobject-2.0
]
flags << "-lintl" if OS.mac?
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end