Skip to content

Commit

Permalink
Merge pull request #198519 from Homebrew/webp-pixbuf-loader-pkgconf
Browse files Browse the repository at this point in the history
webp-pixbuf-loader: migrate to `pkgconf`
  • Loading branch information
chenrui333 authored Nov 22, 2024
2 parents 0aebd65 + ae03ac0 commit 317868c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Formula/w/webp-pixbuf-loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class WebpPixbufLoader < Formula

depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => [:build, :test]
depends_on "pkgconf" => [:build, :test]
depends_on "gdk-pixbuf"
depends_on "glib"
depends_on "webp"

# Constants for gdk-pixbuf's multiple version numbers, which are the same as
Expand All @@ -39,20 +40,20 @@ def module_subdir
end

def install
system "meson", "setup", "build", *std_meson_args, "-Dgdk_pixbuf_moduledir=#{prefix}/#{module_subdir}"
system "meson", "setup", "build", "-Dgdk_pixbuf_moduledir=#{prefix}/#{module_subdir}", *std_meson_args
system "meson", "compile", "-C", "build", "--verbose"
system "meson", "install", "-C", "build"
end

# After the loader is linked in, update the global cache of pixbuf loaders
def post_install
ENV["GDK_PIXBUF_MODULEDIR"] = "#{HOMEBREW_PREFIX}/#{module_subdir}"
system "#{Formula["gdk-pixbuf"].opt_bin}/gdk-pixbuf-query-loaders", "--update-cache"
system Formula["gdk-pixbuf"].opt_bin/"gdk-pixbuf-query-loaders", "--update-cache"
end

test do
# Generate a .webp file to test with.
system "#{Formula["webp"].opt_bin}/cwebp", test_fixtures("test.png"), "-o", "test.webp"
system Formula["webp"].opt_bin/"cwebp", test_fixtures("test.png"), "-o", "test.webp"

# Sample program to load a .webp file via gdk-pixbuf.
(testpath/"test.c").write <<~C
Expand All @@ -73,7 +74,7 @@ def post_install
}
C

flags = shell_output("pkg-config --cflags --libs gdk-pixbuf-#{gdk_so_ver}").chomp.split
flags = shell_output("pkgconf --cflags --libs gdk-pixbuf-#{gdk_so_ver}").chomp.split
system ENV.cc, "test.c", "-o", "test_loader", *flags
system "./test_loader", "test.webp"
end
Expand Down

0 comments on commit 317868c

Please sign in to comment.