class Bochs < Formula desc "Open source IA-32 (x86) PC emulator written in C++" homepage "https://bochs.sourceforge.io/" url "https://downloads.sourceforge.net/project/bochs/bochs/2.6.9/bochs-2.6.9.tar.gz" sha256 "ee5b677fd9b1b9f484b5aeb4614f43df21993088c0c0571187f93acb0866e98c" revision 2 bottle do rebuild 1 sha256 "5a86a2dd7612402c22d0d1383123c69bdcdea2a108976e43b65910b97ea0dd83" => :catalina sha256 "e891728542536430a5d04c6fcd645e53fe3521d9a4f0aa4f3ba7eff175b1066b" => :mojave sha256 "2c21df2f382582ab435e1f9534aea7609a59c080d581ca0b1963f0e1720cdc66" => :high_sierra sha256 "5a80b2f0e3447bebc7c29ba7f3b19b1038e84409f5c33766fb029a49ea64ad5a" => :sierra end depends_on "pkg-config" => :build depends_on "libtool" depends_on "sdl2" # Fix pointer cast issue # https://sourceforge.net/p/bochs/patches/537/ if DevelopmentTools.clang_build_version >= 900 patch do url "https://raw.githubusercontent.com/Homebrew/formula-patches/e9b520dd4c/bochs/xcode9.patch" sha256 "373c670083a3e96f4012cfe7356d8b3584e2f0d10196b4294d56670124f5e5e7" end end def install args = %W[ --prefix=#{prefix} --disable-docbook --enable-a20-pin --enable-alignment-check --enable-all-optimizations --enable-avx --enable-cdrom --enable-clgd54xx --enable-cpu-level=6 --enable-debugger --enable-debugger-gui --enable-disasm --enable-fpu --enable-iodebug --enable-large-ramfile --enable-logging --enable-long-phy-address --enable-pci --enable-plugins --enable-readline --enable-show-ips --enable-smp --enable-usb --enable-vmx=2 --enable-x86-64 --with-nogui --with-sdl2 --with-term ] system "./configure", *args system "make" system "make", "install" end test do require "open3" (testpath/"bochsrc.txt").write <<~EOS panic: action=fatal error: action=report info: action=ignore debug: action=ignore display_library: nogui EOS expected = <<~EOS Bochs is exiting with the following message: \[BIOS \] No bootable device\. EOS command = "#{bin}/bochs -qf bochsrc.txt" # When the debugger is enabled, bochs will stop on a breakpoint early # during boot. We can pass in a command file to continue when it is hit. (testpath/"debugger.txt").write("c\n") command << " -rc debugger.txt" _, stderr, = Open3.capture3(command) assert_match(expected, stderr) end end