homebrew-core/Formula/librsvg.rb

104 lines
3.5 KiB
Ruby

class Librsvg < Formula
desc "Library to render SVG files using Cairo"
homepage "https://wiki.gnome.org/Projects/LibRsvg"
url "https://download.gnome.org/sources/librsvg/2.52/librsvg-2.52.6.tar.xz"
sha256 "a3f939a1e6a3a60408244632d0323f8c3b20eb4b7b000536e2e5bd93b8effaad"
license "LGPL-2.1-or-later"
bottle do
sha256 arm64_monterey: "3ae9c2be700cbffc3fba1be84c2588f068799737408cf7fcd4bae954da7e0e6b"
sha256 arm64_big_sur: "19d6a6bae28c9109ab6bffc2982fd207bb337b0c7964f959238a7d3ea79e904e"
sha256 monterey: "f5812acbbe90b455eee65640ebb2cb7235126af4c212e30ab570b83650a58ab7"
sha256 big_sur: "da2690af234f810bf90ce07089b7a1469f11738d6079904d9a5c22aad52ea265"
sha256 catalina: "056ad0c2e69f30cad2b2931eef802eedfe086859c6d0c76e4745f568a33ce01f"
sha256 cellar: :any_skip_relocation, x86_64_linux: "d6fc71ac3c99694f6b031c950367abed7c040bef95198b857ed05b38c6380d86"
end
depends_on "gobject-introspection" => :build
depends_on "pkg-config" => :build
depends_on "rust" => :build
depends_on "cairo"
depends_on "gdk-pixbuf"
depends_on "glib"
depends_on "pango"
def install
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
--disable-Bsymbolic
--enable-tools=yes
--enable-pixbuf-loader=yes
--enable-introspection=yes
]
system "./configure", *args
# disable updating gdk-pixbuf cache, we will do this manually in post_install
# https://github.com/Homebrew/homebrew/issues/40833
inreplace "gdk-pixbuf-loader/Makefile",
"$(GDK_PIXBUF_QUERYLOADERS) > $(DESTDIR)$(gdk_pixbuf_cache_file) ;",
""
system "make", "install",
"gdk_pixbuf_binarydir=#{lib}/gdk-pixbuf-2.0/2.10.0/loaders",
"gdk_pixbuf_moduledir=#{lib}/gdk-pixbuf-2.0/2.10.0/loaders"
end
def post_install
# librsvg is not aware GDK_PIXBUF_MODULEDIR must be set
# set GDK_PIXBUF_MODULEDIR and update loader cache
ENV["GDK_PIXBUF_MODULEDIR"] = "#{HOMEBREW_PREFIX}/lib/gdk-pixbuf-2.0/2.10.0/loaders"
system "#{Formula["gdk-pixbuf"].opt_bin}/gdk-pixbuf-query-loaders", "--update-cache"
end
test do
(testpath/"test.c").write <<~EOS
#include <librsvg/rsvg.h>
int main(int argc, char *argv[]) {
RsvgHandle *handle = rsvg_handle_new();
return 0;
}
EOS
cairo = Formula["cairo"]
fontconfig = Formula["fontconfig"]
freetype = Formula["freetype"]
gdk_pixbuf = Formula["gdk-pixbuf"]
gettext = Formula["gettext"]
glib = Formula["glib"]
libpng = Formula["libpng"]
pixman = Formula["pixman"]
flags = %W[
-I#{cairo.opt_include}/cairo
-I#{fontconfig.opt_include}
-I#{freetype.opt_include}/freetype2
-I#{gdk_pixbuf.opt_include}/gdk-pixbuf-2.0
-I#{gettext.opt_include}
-I#{glib.opt_include}/glib-2.0
-I#{glib.opt_lib}/glib-2.0/include
-I#{include}/librsvg-2.0
-I#{libpng.opt_include}/libpng16
-I#{pixman.opt_include}/pixman-1
-D_REENTRANT
-L#{cairo.opt_lib}
-L#{gdk_pixbuf.opt_lib}
-L#{gettext.opt_lib}
-L#{glib.opt_lib}
-L#{lib}
-lcairo
-lgdk_pixbuf-2.0
-lgio-2.0
-lglib-2.0
-lgobject-2.0
-lm
-lrsvg-2
]
on_macos do
flags << "-lintl"
end
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end