class Mpv < Formula desc "Media player based on MPlayer and mplayer2" homepage "https://mpv.io" url "https://github.com/mpv-player/mpv/archive/refs/tags/v0.36.0.tar.gz" sha256 "29abc44f8ebee013bb2f9fe14d80b30db19b534c679056e4851ceadf5a5e8bf6" license :cannot_represent head "https://github.com/mpv-player/mpv.git", branch: "master" bottle do rebuild 1 sha256 arm64_sonoma: "ac4ac761953fa4f60b8cc89dd7e50b858848ac6bf2dd3261a26e8a3dcbd88d05" sha256 arm64_ventura: "9ce84a4b91458042f142b5d16081cfc5e57a8e09d3306fc5c5d4643467e5035e" sha256 arm64_monterey: "cba94988f688214e7ab997cc61b5327e4b0fcbae5e061723deda18897d2c8e9c" sha256 sonoma: "f5a0586b34ef65b7f652a75ccc464da405667382c1ae98adb56db1e76344aa06" sha256 ventura: "3756a699dbc655ee50e4e0562318a23c32f045f131a0d8a172cae0e50bd0bef3" sha256 monterey: "31519705d2827ffc36c89d6527f0e8e55cf592919a93f5b702a7e1c35a4b23ca" sha256 x86_64_linux: "65c4d2170fe3d7df98ab09b1fa5e997033b40c255d1d2237b86209081dfcc2f2" end depends_on "docutils" => :build depends_on "meson" => :build depends_on "pkg-config" => [:build, :test] depends_on xcode: :build depends_on "ffmpeg" depends_on "jpeg-turbo" depends_on "libarchive" depends_on "libass" depends_on "libplacebo" depends_on "little-cms2" depends_on "luajit" depends_on "mujs" depends_on "uchardet" depends_on "vapoursynth" depends_on "yt-dlp" on_linux do depends_on "alsa-lib" end def install # LANG is unset by default on macOS and causes issues when calling getlocale # or getdefaultlocale in docutils. Force the default c/posix locale since # that's good enough for building the manpage. ENV["LC_ALL"] = "C" # force meson find ninja from homebrew ENV["NINJA"] = Formula["ninja"].opt_bin/"ninja" # libarchive is keg-only ENV.prepend_path "PKG_CONFIG_PATH", Formula["libarchive"].opt_lib/"pkgconfig" args = %W[ -Dhtml-build=enabled -Djavascript=enabled -Dlibmpv=true -Dlua=luajit -Dlibarchive=enabled -Duchardet=enabled --sysconfdir=#{pkgetc} --datadir=#{pkgshare} --mandir=#{man} ] system "meson", "setup", "build", *args, *std_meson_args system "meson", "compile", "-C", "build", "--verbose" system "meson", "install", "-C", "build" if OS.mac? # `pkg-config --libs mpv` includes libarchive, but that package is # keg-only so it needs to look for the pkgconfig file in libarchive's opt # path. libarchive = Formula["libarchive"].opt_prefix inreplace lib/"pkgconfig/mpv.pc" do |s| s.gsub!(/^Requires\.private:(.*)\blibarchive\b(.*?)(,.*)?$/, "Requires.private:\\1#{libarchive}/lib/pkgconfig/libarchive.pc\\3") end end bash_completion.install "etc/mpv.bash-completion" => "mpv" zsh_completion.install "etc/_mpv.zsh" => "_mpv" end test do system bin/"mpv", "--ao=null", "--vo=null", test_fixtures("test.wav") assert_match "vapoursynth", shell_output(bin/"mpv --vf=help") # Make sure `pkg-config` can parse `mpv.pc` after the `inreplace`. system "pkg-config", "mpv" end end