153 lines
4.8 KiB
Ruby
153 lines
4.8 KiB
Ruby
class Mesa < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Graphics Library"
|
|
homepage "https://www.mesa3d.org/"
|
|
license "MIT"
|
|
head "https://gitlab.freedesktop.org/mesa/mesa.git", branch: "main"
|
|
|
|
stable do
|
|
url "https://mesa.freedesktop.org/archive/mesa-22.2.0.tar.xz"
|
|
sha256 "b1f9c8fd08f2cae3adf83355bef4d2398e8025f44947332880f2d0066bdafa8c"
|
|
|
|
patch do
|
|
url "https://raw.githubusercontent.com/Homebrew/formula-patches/f0a40cf7d70ee5a25639b91d9a8088749a2dd04e/mesa/fix-build-on-macOS.patch"
|
|
sha256 "a9b646e48d4e4228c3e06d8ca28f65e01e59afede91f58d4bd5a9c42a66b338d"
|
|
end
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "f856ff4256f79abe07d9d9c8e4f32c929ef88269690e772ae1a9642539dc42b7"
|
|
sha256 arm64_big_sur: "39e11cc7d6eb68c5e7d9b9a8d7529cace9926bdefb204436700ceba5bff6bf12"
|
|
sha256 monterey: "b51e0e20be9f2804eab96e2ca821f308662c04c9c744c65ce51f4f0972f4afd2"
|
|
sha256 big_sur: "453013a4383e00a9b4fe1b9d748d74ddf3268b0b36ae13d2604fc661dfc9e592"
|
|
sha256 catalina: "3e22af09c028ba4554ed236138ce177e093516781adbc2ddbe15dbe79293d8da"
|
|
sha256 x86_64_linux: "0d75cbb223809d965d503e98b83a2080930507a2c97139ead75aaed3244c3649"
|
|
end
|
|
|
|
depends_on "bison" => :build # can't use form macOS, needs '> 2.3'
|
|
depends_on "meson" => :build
|
|
depends_on "ninja" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "python@3.10" => :build
|
|
depends_on "xorgproto" => :build
|
|
|
|
depends_on "expat"
|
|
depends_on "gettext"
|
|
depends_on "libx11"
|
|
depends_on "libxcb"
|
|
depends_on "libxdamage"
|
|
depends_on "libxext"
|
|
|
|
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 "glslang"
|
|
depends_on "gzip"
|
|
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/6d/f2/8ad2ec3d531c97c4071572a4104e00095300e278a7449511bee197ca22c9/Mako-1.2.2.tar.gz"
|
|
sha256 "3724869b363ba630a272a5f89f68c070352137b8fd1757650017b7e06fda163f"
|
|
end
|
|
|
|
resource "Pygments" do
|
|
url "https://files.pythonhosted.org/packages/e0/ef/5905cd3642f2337d44143529c941cc3a02e5af16f0f65f81cbef7af452bb/Pygments-2.13.0.tar.gz"
|
|
sha256 "56a8508ae95f98e2b9bdf93a6be5ae3f7d8af858b43e02c5a2ff083726be40c1"
|
|
end
|
|
|
|
resource "MarkupSafe" do
|
|
url "https://files.pythonhosted.org/packages/1d/97/2288fe498044284f39ab8950703e88abbac2abbdf65524d576157af70556/MarkupSafe-2.1.1.tar.gz"
|
|
sha256 "7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b"
|
|
end
|
|
|
|
resource "glxgears.c" do
|
|
url "https://gitlab.freedesktop.org/mesa/demos/-/raw/db5ad06a346774a249b22797e660d55bde0d9571/src/xdemos/glxgears.c"
|
|
sha256 "3873db84d708b5d8b3cac39270926ba46d812c2f6362da8e6cd0a1bff6628ae6"
|
|
end
|
|
|
|
resource "gl_wrap.h" do
|
|
url "https://gitlab.freedesktop.org/mesa/demos/-/raw/ddc35ca0ea2f18c5011c5573b4b624c128ca7616/src/util/gl_wrap.h"
|
|
sha256 "41f5a84f8f5abe8ea2a21caebf5ff31094a46953a83a738a19e21c010c433c88"
|
|
end
|
|
|
|
def install
|
|
venv_root = buildpath/"venv"
|
|
venv = virtualenv_create(venv_root, "python3.10")
|
|
|
|
%w[Mako Pygments MarkupSafe].each do |res|
|
|
venv.pip_install resource(res)
|
|
end
|
|
|
|
ENV.prepend_path "PATH", "#{venv_root}/bin"
|
|
|
|
args = ["-Db_ndebug=true"]
|
|
|
|
if OS.linux?
|
|
args += %w[
|
|
-Dplatforms=x11,wayland
|
|
-Dglx=auto
|
|
-Ddri3=true
|
|
-Dgallium-drivers=auto
|
|
-Dgallium-omx=disabled
|
|
-Degl=true
|
|
-Dgbm=true
|
|
-Dopengl=true
|
|
-Dgles1=enabled
|
|
-Dgles2=enabled
|
|
-Dgallium-xvmc=disabled
|
|
-Dvalgrind=false
|
|
-Dtools=drm-shim,etnaviv,freedreno,glsl,nir,nouveau,xvmc,lima
|
|
]
|
|
end
|
|
|
|
system "meson", "build", *args, *std_meson_args
|
|
system "meson", "compile", "-C", "build"
|
|
system "meson", "install", "-C", "build"
|
|
inreplace lib/"pkgconfig/dri.pc" do |s|
|
|
s.change_make_var! "dridriverdir", HOMEBREW_PREFIX/"lib/dri"
|
|
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
|