class Webp < Formula desc "Image format providing lossless and lossy compression for web images" homepage "https://developers.google.com/speed/webp/" url "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.5.0.tar.gz" sha256 "7d6fab70cf844bf6769077bd5d7a74893f8ffd4dfb42861745750c63c2a5c92c" license "BSD-3-Clause" head "https://chromium.googlesource.com/webm/libwebp.git", branch: "main" livecheck do url "https://developers.google.com/speed/webp/docs/compiling" regex(/libwebp[._-]v?(\d+(?:\.\d+)+)\.t/i) end depends_on "cmake" => :build depends_on "giflib" depends_on "jpeg-turbo" depends_on "libpng" depends_on "libtiff" def install args = %W[ -DCMAKE_INSTALL_RPATH=#{rpath} ] system "cmake", "-S", ".", "-B", "build", *std_cmake_args, "-DBUILD_SHARED_LIBS=ON", *args system "cmake", "--build", "build" system "cmake", "--install", "build" system "cmake", "-S", ".", "-B", "static", *std_cmake_args, "-DBUILD_SHARED_LIBS=OFF", *args system "cmake", "--build", "static" lib.install buildpath.glob("static/*.a") # Avoid rebuilding dependents that hard-code the prefix. inreplace (lib/"pkgconfig").glob("*.pc"), prefix, opt_prefix end test do system bin/"cwebp", test_fixtures("test.png"), "-o", "webp_test.png" system bin/"dwebp", "webp_test.png", "-o", "webp_test.webp" assert_predicate testpath/"webp_test.webp", :exist? end end