class Mesa < Formula desc "Graphics Library" homepage "https://www.mesa3d.org/" url "https://mesa.freedesktop.org/archive/mesa-20.1.7.tar.xz" sha256 "4de9dd0cb2ca367606cada421db62fbf6d276dfd533e522bfab6001ff9aba288" license "MIT" head "https://gitlab.freedesktop.org/mesa/mesa.git" livecheck do url :stable end bottle do cellar :any sha256 "817e191cc4dd4246a93d2674ebc6243800c838f72b7d982332f45c2e653767ad" => :catalina sha256 "389a3ec813a6cbe713e5c11c3acda6c7e724c6869aa88742be9c5faaff6a026d" => :mojave sha256 "2faff11eb73e2edd64b395abaacae324362752cdf037d1536433cfc517fbd9de" => :high_sierra end depends_on "meson-internal" => :build depends_on "ninja" => :build depends_on "pkg-config" => :build depends_on "python@3.8" => :build depends_on "freeglut" => :test depends_on "expat" depends_on "gettext" resource "Mako" do url "https://files.pythonhosted.org/packages/72/89/402d2b4589e120ca76a6aed8fee906a0f5ae204b50e455edd36eda6e778d/Mako-1.1.3.tar.gz" sha256 "8195c8c1400ceb53496064314c6736719c6f25e7479cd24c77be3d9361cddc27" end resource "gears.c" do url "https://www.opengl.org/archives/resources/code/samples/glut_examples/mesademos/gears.c" sha256 "7df9d8cda1af9d0a1f64cc028df7556705d98471fdf3d0830282d4dcfb7a78cc" end def install python3 = Formula["python@3.8"].opt_bin/"python3" xy = Language::Python.major_minor_version python3 ENV.prepend_create_path "PYTHONPATH", buildpath/"vendor/lib/python#{xy}/site-packages" resource("Mako").stage do system python3, *Language::Python.setup_install_args(buildpath/"vendor") end resource("gears.c").stage(pkgshare.to_s) mkdir "build" do system "meson", *std_meson_args, "..", "-Db_ndebug=true", "-Dplatforms=surfaceless", "-Dglx=disabled" system "ninja" system "ninja", "install" end end test do flags = %W[ -framework OpenGL -I#{Formula["freeglut"].opt_include} -L#{Formula["freeglut"].opt_lib} -lglut ] system ENV.cc, "#{pkgshare}/gears.c", "-o", "gears", *flags end end