Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glib, glib-utils: merge #108307

Closed
wants to merge 9 commits into from
Closed
1 change: 1 addition & 0 deletions Formula/gjs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Gjs < Formula
url "https://download.gnome.org/sources/gjs/1.72/gjs-1.72.2.tar.xz"
sha256 "ddee379bdc5a7d303a5d894be2b281beb8ac54508604e7d3f20781a869da3977"
license all_of: ["LGPL-2.0-or-later", "MIT"]
revision 1
head "https://gitlab.gnome.org/GNOME/gjs.git", branch: "master"

bottle do
Expand Down
117 changes: 0 additions & 117 deletions Formula/glib-utils.rb

This file was deleted.

68 changes: 25 additions & 43 deletions Formula/glib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Glib < Formula
url "https://download.gnome.org/sources/glib/2.72/glib-2.72.3.tar.xz"
sha256 "4a39a2f624b8512d500d5840173eda7fa85f51c109052eae806acece85d345f0"
license "LGPL-2.1-or-later"
revision 1

bottle do
sha256 arm64_monterey: "36038c2b4fb7dbede91facedd3dd3062e0ae697149e5ce758bbd17ce0e2448ab"
Expand All @@ -19,15 +20,20 @@ class Glib < Formula
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "python@3.10" => :build
depends_on "gettext"
depends_on "libffi"
depends_on "pcre"

uses_from_macos "libffi", since: :catalina
uses_from_macos "python", since: :catalina

on_linux do
depends_on "util-linux"
end

# These used to live in the now defunct `glib-utils`.
link_overwrite "bin/gdbus-codegen", "bin/glib-genmarshal", "bin/glib-mkenums", "bin/gtester-report"
link_overwrite "share/glib-2.0/codegen", "share/glib-2.0/gdb"

# Sync this with `glib-utils.rb`
# replace several hardcoded paths with homebrew counterparts
patch do
Expand All @@ -36,12 +42,11 @@ class Glib < Formula
end

def install
inreplace %w[gio/xdgmime/xdgmime.c glib/gutils.c],
"@@HOMEBREW_PREFIX@@", HOMEBREW_PREFIX
inreplace %w[gio/xdgmime/xdgmime.c glib/gutils.c], "@@HOMEBREW_PREFIX@@", HOMEBREW_PREFIX

# Disable dtrace; see https://trac.macports.org/ticket/30413
# and https://gitlab.gnome.org/GNOME/glib/-/issues/653
args = std_meson_args + %W[
args = %W[
--default-library=both
--localstatedir=#{var}
-Diconv=auto
Expand All @@ -50,11 +55,9 @@ def install
-Ddtrace=false
]

mkdir "build" do
system "meson", *args, ".."
system "ninja", "-v"
system "ninja", "install", "-v"
end
system "meson", "setup", "build", *args, *std_meson_args
system "meson", "compile", "-C", "build", "--verbose"
system "meson", "install", "-C", "build"

# ensure giomoduledir contains prefix, as this pkgconfig variable will be
# used by glib-networking and glib-openssl to determine where to install
Expand All @@ -63,58 +66,37 @@ def install
"giomoduledir=#{HOMEBREW_PREFIX}/lib/gio/modules",
"giomoduledir=${libdir}/gio/modules"

# Delete python files because they are provided by `glib-utils`
python_extension_regex = /\.(py(?:[diwx])?|px[di]|cpython-(?:[23]\d{1,2})[-\w]*\.(so|dylib))$/i
python_shebang_regex = %r{^#! ?/usr/bin/(?:env )?python(?:[23](?:\.\d{1,2})?)?( |$)}
shebang_max_length = 28 # the length of "#! /usr/bin/env pythonx.yyy "
prefix.find do |f|
next unless f.file?

f.unlink if python_extension_regex.match?(f.basename) || python_shebang_regex.match?(f.read(shebang_max_length))
end

# Delete empty directories
# Note: We need to traversal the directories in reverse order (i.e. deepest first).
# Also, we should put checking emptiness and deletion in a single loop.
# `dirs.select(&:empty?).map(&:rmdir)` will not work because it will not delete
# directories that only contain empty directories.
prefix.find.select(&:directory?).reverse_each { |d| d.rmdir if d.empty? }

if OS.mac?
# `pkg-config --libs glib-2.0` includes -lintl, and gettext itself does not
# have a pkgconfig file, so we add gettext lib and include paths here.
gettext = Formula["gettext"].opt_prefix
inreplace lib+"pkgconfig/glib-2.0.pc" do |s|
inreplace lib/"pkgconfig/glib-2.0.pc" do |s|
s.gsub! "Libs: -L${libdir} -lglib-2.0 -lintl",
"Libs: -L${libdir} -lglib-2.0 -L#{gettext}/lib -lintl"
s.gsub! "Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include",
"Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include -I#{gettext}/include"
end
end

# `pkg-config --print-requires-private gobject-2.0` includes libffi,
# but that package is keg-only so it needs to look for the pkgconfig file
# in libffi's opt path.
libffi = Formula["libffi"].opt_prefix
inreplace lib+"pkgconfig/gobject-2.0.pc" do |s|
s.gsub! "Requires.private: libffi",
"Requires.private: #{libffi}/lib/pkgconfig/libffi.pc"
if MacOS.version < :catalina
# `pkg-config --print-requires-private gobject-2.0` includes libffi,
# but that package is keg-only so it needs to look for the pkgconfig file
# in libffi's opt path.
libffi = Formula["libffi"].opt_prefix
inreplace lib/"pkgconfig/gobject-2.0.pc" do |s|
s.gsub! "Requires.private: libffi",
"Requires.private: #{libffi}/lib/pkgconfig/libffi.pc"
end
end

bash_completion.install Dir["gio/completion/*"]
bash_completion.install (buildpath/"gio/completion").children
rewrite_shebang detected_python_shebang(use_python_from_path: true), *bin.children
end

def post_install
(HOMEBREW_PREFIX/"lib/gio/modules").mkpath
end

def caveats
<<~EOS
Python executables and libraries are no longer included with this formula, but they are available separately:
brew install glib-utils
EOS
end

test do
(testpath/"test.c").write <<~EOS
#include <string.h>
Expand Down
4 changes: 2 additions & 2 deletions Formula/gobject-introspection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class GobjectIntrospection < Formula
url "https://download.gnome.org/sources/gobject-introspection/1.72/gobject-introspection-1.72.0.tar.xz"
sha256 "02fe8e590861d88f83060dd39cda5ccaa60b2da1d21d0f95499301b186beaabc"
license all_of: ["GPL-2.0-or-later", "LGPL-2.0-or-later", "MIT"]
revision 1
revision 2

bottle do
sha256 arm64_monterey: "0043e3c72a3ddc9b6a055b0d79637016a8532139b5229bfd197d43642f0fee30"
Expand All @@ -23,7 +23,7 @@ class GobjectIntrospection < Formula
depends_on "cairo"
depends_on "glib"
depends_on "pkg-config"
# TODO: Consider using `uses_from_macos "python"` instead.
# Ships a `_giscanner.cpython-310-darwin.so`, so needs a specific version.
depends_on "python@3.10"
Copy link
Member Author

@carlocab carlocab Aug 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ships a

_giscanner.cpython-310-darwin.so

so this is not flexible about the version of Python used.


uses_from_macos "flex" => :build
Expand Down
2 changes: 1 addition & 1 deletion Formula/lanraragi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Lanraragi < Formula
url "https://github.com/Difegue/LANraragi/archive/v.0.8.5.tar.gz"
sha256 "2cf53f7405a6a4e16e6d61a1109bdd87c25471c2ee6cf2fb79129c7f5666fa31"
license "MIT"
revision 1
revision 2
head "https://github.com/Difegue/LANraragi.git", branch: "dev"

bottle do
Expand Down
2 changes: 1 addition & 1 deletion Formula/openmodelica.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Openmodelica < Formula
tag: "v1.18.0",
revision: "49be4faa5a625a18efbbd74cc2f5be86aeea37bb"
license "GPL-3.0-only"
revision 4
revision 5
head "https://github.com/OpenModelica/OpenModelica.git", branch: "master"

bottle do
Expand Down
1 change: 1 addition & 0 deletions Formula/pygobject3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Pygobject3 < Formula
url "https://download.gnome.org/sources/pygobject/3.42/pygobject-3.42.2.tar.xz"
sha256 "ade8695e2a7073849dd0316d31d8728e15e1e0bc71d9ff6d1c09e86be52bc957"
license "LGPL-2.1-or-later"
revision 1

bottle do
sha256 cellar: :any, arm64_monterey: "8421dca7ad4ca708e794833f7d52900d242c69f7dedb68293d092ec8ad2825f7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"librasterlite",
"predictionio",
"sqoop",
"swtpm"
"swtpm",
"synergy-core"
]
1 change: 1 addition & 0 deletions formula_renames.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"geth": "ethereum",
"gitlab-ci-multi-runner": "gitlab-runner",
"giflib@5": "giflib",
"glib-utils": "glib",
"glibmm@2.64": "glibmm@2.66",
"glfw3": "glfw",
"gloo-ctl": "glooctl",
Expand Down