136 lines
4.3 KiB
Ruby
136 lines
4.3 KiB
Ruby
class XorgServer < Formula
|
|
desc "X Window System display server"
|
|
homepage "https://www.x.org"
|
|
url "https://www.x.org/releases/individual/xserver/xorg-server-21.1.6.tar.xz"
|
|
sha256 "1eb86ed674d042b6c8b1f9135e59395cbbca35ed551b122f73a7d8bb3bb22484"
|
|
license all_of: ["MIT", "APSL-2.0"]
|
|
|
|
bottle do
|
|
sha256 arm64_ventura: "d9e8763f9c626e33fdd588560292b9b40808b700b0626a1447ed8221e84be118"
|
|
sha256 arm64_monterey: "08ff802a6846e14b45b161fc90561b430b9196627589638b667d42c94fc2c44d"
|
|
sha256 arm64_big_sur: "ac1815046be1cbdb3de0ec6ff255d42ff367b70b16c2e83a912af6e8e34987b0"
|
|
sha256 ventura: "db951b6b598f1f06c399ab099d02a2f4a10fdda3f77fe42cc1178c9bf772d890"
|
|
sha256 monterey: "7f53b65000508cb7074ab7be0b9298a8cb8643a01226931fb902ea1fa0f10d53"
|
|
sha256 big_sur: "b024b869d7d7b1f9f7c23cf4036488fea44c18484549cfad77e59847c6714abe"
|
|
sha256 x86_64_linux: "18d0f486f0c19d60bc2760be2cc3eaa7dff4745acc1577a89b12aec1d68f3b1c"
|
|
end
|
|
|
|
depends_on "font-util" => :build
|
|
depends_on "libxkbfile" => :build
|
|
depends_on "meson" => :build
|
|
depends_on "ninja" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "util-macros" => :build
|
|
depends_on "xorgproto" => :build
|
|
depends_on "xtrans" => :build
|
|
|
|
depends_on "libxfixes"
|
|
depends_on "libxfont2"
|
|
depends_on "mesa"
|
|
depends_on "pixman"
|
|
depends_on "xauth"
|
|
depends_on "xcb-util"
|
|
depends_on "xcb-util-image"
|
|
depends_on "xcb-util-keysyms"
|
|
depends_on "xcb-util-renderutil"
|
|
depends_on "xcb-util-wm"
|
|
depends_on "xkbcomp"
|
|
depends_on "xkeyboardconfig"
|
|
|
|
on_macos do
|
|
depends_on "libapplewm"
|
|
end
|
|
|
|
on_linux do
|
|
depends_on "dbus"
|
|
depends_on "libdrm"
|
|
depends_on "libepoxy"
|
|
depends_on "libxcvt"
|
|
depends_on "libxshmfence"
|
|
depends_on "nettle"
|
|
depends_on "systemd"
|
|
|
|
resource "xvfb-run" do
|
|
url "https://salsa.debian.org/xorg-team/xserver/xorg-server/-/raw/xorg-server-2_21.1.4-1/debian/local/xvfb-run"
|
|
sha256 "fd05e0f8e6207c3984b980a0f037381c9c4a6f22a6dd94fdcfa995318db2a0a4"
|
|
end
|
|
|
|
resource "xvfb-run.1" do
|
|
url "https://salsa.debian.org/xorg-team/xserver/xorg-server/-/raw/xorg-server-2_21.1.4-1/debian/local/xvfb-run.1"
|
|
sha256 "08f14f55e14e52e5d98713c4d8f25ae68d67e2ee188dc0247770c6ada6e27c05"
|
|
end
|
|
end
|
|
|
|
def install
|
|
# ChangeLog contains some non relocatable strings
|
|
rm "ChangeLog"
|
|
meson_args = std_meson_args.reject { |s| s["prefix"] } + %W[
|
|
-Dxephyr=true
|
|
-Dxf86bigfont=true
|
|
-Dxcsecurity=true
|
|
|
|
-Dbundle-id-prefix=#{Formula["xinit"].plist_name.chomp ".startx"}
|
|
-Dbuilder_addr=#{tap.remote}
|
|
-Dbuilder_string=#{tap.name}
|
|
]
|
|
# macOS doesn't provide `authdes_cred` so `secure-rpc=false`
|
|
# glamor needs GLX with `libepoxy` on macOS
|
|
if OS.mac?
|
|
meson_args += %w[
|
|
-Dsecure-rpc=false
|
|
-Dapple-applications-dir=libexec
|
|
]
|
|
end
|
|
|
|
# X11.app need startx etc. in the same directory
|
|
destdir = buildpath/"dest"
|
|
system "meson", "build", *meson_args
|
|
system "meson", "compile", "-C", "build"
|
|
system "meson", "install", "-C", "build", "--destdir", destdir
|
|
prefix.install Dir["#{destdir}#{HOMEBREW_PREFIX}/*"]
|
|
# follow https://github.com/XQuartz/XQuartz/blob/main/compile.sh#L955
|
|
bin.install_symlink bin/"Xquartz" => "X" if OS.mac?
|
|
|
|
if OS.linux?
|
|
bin.install resource("xvfb-run")
|
|
man1.install resource("xvfb-run.1")
|
|
end
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
To launch X server, it is recommend to install xinit,
|
|
especially on macOS, otherwise X11.app will not work:
|
|
brew install xinit
|
|
If cask xquartz is installed, this link may be helpful:
|
|
https://www.xquartz.org/FAQs.html#want-another-x11app-server
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.c").write <<~EOS
|
|
#include <assert.h>
|
|
#include <xcb/xcb.h>
|
|
|
|
int main(void) {
|
|
xcb_connection_t *connection = xcb_connect(NULL, NULL);
|
|
int has_err = xcb_connection_has_error(connection);
|
|
assert(has_err == 0);
|
|
xcb_disconnect(connection);
|
|
return 0;
|
|
}
|
|
EOS
|
|
xcb = Formula["libxcb"]
|
|
system ENV.cc, "./test.c", "-o", "test", "-I#{xcb.include}", "-L#{xcb.lib}", "-lxcb"
|
|
|
|
fork do
|
|
exec bin/"Xvfb", ":1"
|
|
end
|
|
ENV["DISPLAY"] = ":1"
|
|
sleep 10
|
|
system "./test"
|
|
|
|
system bin/"xvfb-run", "./test" if OS.linux?
|
|
end
|
|
end
|