class Stella < Formula desc "Atari 2600 VCS emulator" homepage "https://stella-emu.github.io/" url "https://github.com/stella-emu/stella/releases/download/5.1.2/stella-5.1.2-src.tar.xz" sha256 "77b210d51af7e4be88c14014d507e48367bcdff6b8ba513793f035f3e30a21bd" head "https://github.com/stella-emu/stella.git" bottle do cellar :any sha256 "3952794f385c60186388081e30bff9208b25792832fe136214c290a70b2dc65c" => :high_sierra sha256 "d327544aed23ac67426578a999edd4fed8359293d3ae8ce455aaad61ad4cdbeb" => :sierra sha256 "a7920d654f7597a49d89ce9190c5d431ca64da21dac254503fde71e4e94af020" => :el_capitan end depends_on :xcode => :build depends_on "sdl2" depends_on "libpng" def install sdl2 = Formula["sdl2"] libpng = Formula["libpng"] cd "src/macosx" do inreplace "stella.xcodeproj/project.pbxproj" do |s| s.gsub! %r{(\w{24} \/\* SDL2\.framework)}, '//\1' s.gsub! %r{(\w{24} \/\* png)}, '//\1' s.gsub! /(HEADER_SEARCH_PATHS) = \(/, "\\1 = (#{sdl2.opt_include}/SDL2, #{libpng.opt_include}," s.gsub! /(LIBRARY_SEARCH_PATHS) = ("\$\(LIBRARY_SEARCH_PATHS\)");/, "\\1 = (#{sdl2.opt_lib}, #{libpng.opt_lib}, \\2);" s.gsub! /(OTHER_LDFLAGS) = "((-\w+)*)"/, '\1 = "-lSDL2 -lpng \2"' end xcodebuild "SYMROOT=build" prefix.install "build/Release/Stella.app" bin.write_exec_script "#{prefix}/Stella.app/Contents/MacOS/Stella" end end test do assert_match /Stella version #{version}/, shell_output("#{bin}/Stella -help").strip end end