homebrew-core/Formula/mesa.rb

128 lines
3.9 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.2.3.tar.xz"
sha256 "7245284a159d2484770e1835a673e79e4322a9ddf43b17859668244946db7174"
license "MIT"
head "https://gitlab.freedesktop.org/mesa/mesa.git", branch: "main"
bottle do
sha256 arm64_big_sur: "647680c6c57f129e8a468a24b1e3a292806e58678268eaaa7c041850e959b46a"
sha256 big_sur: "0a32b4ff6af04519287fcc66da4942dc312bd42729ddfaa88014dea8fa8ccb23"
sha256 catalina: "65b59e30dacdec6377fad8b31216e8be39e43bf710037fae96a62b8dc394d5ee"
sha256 mojave: "be170207296c7caf6990afeed20b1d081f5bbd66a7a59c2cc365dd8fa8a2aede"
sha256 x86_64_linux: "a164f6e33f6a4e8d7bac9d7cfc42600d2d7b96dd213515678255868bdc3264e6"
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/d1/42/ff293411e980debfc647be9306d89840c8b82ea24571b014f1a35b2ad80f/Mako-1.1.5.tar.gz"
sha256 "169fa52af22a91900d852e937400e79f535496191c63712e3b9fda5a9bed6fc3"
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 << "-Dxvmc=true"
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