homebrew-core/Formula/mesa.rb

129 lines
4.0 KiB
Ruby

class Mesa < Formula
include Language::Python::Virtualenv
desc "Graphics Library"
homepage "https://www.mesa3d.org/"
url "https://mesa.freedesktop.org/archive/mesa-21.3.2.tar.xz"
sha256 "e2e7bafb8307e7abc3bf982f39382fae3619c84b45504920a21504be52f126bd"
license "MIT"
head "https://gitlab.freedesktop.org/mesa/mesa.git", branch: "main"
bottle do
sha256 arm64_monterey: "f801aa873e629ef73f65ae8b1992be8b274aba9cb761686c7f17b41b635b60f5"
sha256 arm64_big_sur: "b53304841bd7dc22a654f678c92a22be95b75889ee0fa74ec6132122639fba23"
sha256 monterey: "c67232faa9df4f1addc831fd3b826b5e104206acc566e66f13d61dcd6bf03fa7"
sha256 big_sur: "a970ecb7a8f12ccc0152a6de178a80d2ee60d9e15810c8e5f8cffdc8cfacff4e"
sha256 catalina: "71bba5c7be97365e1b02a301b20a8ca43e34731034e3c7c602bb492f8257a553"
sha256 x86_64_linux: "caf4f1021e3badaae21643d6af21aadfc2c35c67b610a49dbb6b6651d416bdc3"
end
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "python@3.9" => :build
depends_on "expat"
depends_on "gettext"
depends_on "libx11"
depends_on "libxcb"
depends_on "libxdamage"
depends_on "libxext"
uses_from_macos "bison" => :build
uses_from_macos "flex" => :build
uses_from_macos "llvm"
uses_from_macos "ncurses"
uses_from_macos "zlib"
on_linux do
depends_on "elfutils"
depends_on "gcc"
depends_on "libdrm"
depends_on "libva"
depends_on "libvdpau"
depends_on "libxfixes"
depends_on "libxrandr"
depends_on "libxshmfence"
depends_on "libxv"
depends_on "libxvmc"
depends_on "libxxf86vm"
depends_on "lm-sensors"
depends_on "wayland"
depends_on "wayland-protocols"
end
fails_with gcc: "5"
resource "Mako" do
url "https://files.pythonhosted.org/packages/af/b6/42cd322ae555aa770d49e31b8c5c28a243ba1bbb57ad927e1a5f5b064811/Mako-1.1.6.tar.gz"
sha256 "4e9e345a41924a954251b95b4b28e14a301145b544901332e658907a7464b6b2"
end
resource "glxgears.c" do
url "https://gitlab.freedesktop.org/mesa/demos/-/raw/faaa319d704ac677c3a93caadedeb91a4a74b7a7/src/xdemos/glxgears.c"
sha256 "3873db84d708b5d8b3cac39270926ba46d812c2f6362da8e6cd0a1bff6628ae6"
end
resource "gl_wrap.h" do
url "https://gitlab.freedesktop.org/mesa/demos/-/raw/faaa319d704ac677c3a93caadedeb91a4a74b7a7/src/util/gl_wrap.h"
sha256 "c727b2341d81c2a1b8a0b31e46d24f9702a1ec55c8be3f455ddc8d72120ada72"
end
def install
ENV.prepend_path "PATH", Formula["python@3.9"].opt_libexec/"bin"
venv_root = libexec/"venv"
venv = virtualenv_create(venv_root, "python3")
venv.pip_install resource("Mako")
ENV.prepend_path "PATH", "#{venv_root}/bin"
mkdir "build" do
args = ["-Db_ndebug=true"]
if OS.linux?
args << "-Dplatforms=x11,wayland"
args << "-Dglx=auto"
args << "-Ddri3=true"
args << "-Ddri-drivers=auto"
args << "-Dgallium-drivers=auto"
args << "-Dgallium-omx=disabled"
args << "-Degl=true"
args << "-Dgbm=true"
args << "-Dopengl=true"
args << "-Dgles1=true"
args << "-Dgles2=true"
args << "-Dgallium-xvmc=disabled"
args << "-Dvalgrind=false"
args << "-Dtools=drm-shim,etnaviv,freedreno,glsl,nir,nouveau,xvmc,lima"
end
system "meson", *std_meson_args, "..", *args
system "ninja"
system "ninja", "install"
end
if OS.linux?
# Strip executables/libraries/object files to reduce their size
system("strip", "--strip-unneeded", "--preserve-dates", *(Dir[bin/"**/*", lib/"**/*"]).select do |f|
f = Pathname.new(f)
f.file? && (f.elf? || f.extname == ".a")
end)
end
end
test do
%w[glxgears.c gl_wrap.h].each { |r| resource(r).stage(testpath) }
flags = %W[
-I#{include}
-L#{lib}
-L#{Formula["libx11"].lib}
-L#{Formula["libxext"].lib}
-lGL
-lX11
-lXext
-lm
]
system ENV.cc, "glxgears.c", "-o", "gears", *flags
end
end