126 lines
4.3 KiB
Ruby
126 lines
4.3 KiB
Ruby
class Libxml2 < Formula
|
|
desc "GNOME XML library"
|
|
homepage "http://xmlsoft.org/"
|
|
url "https://download.gnome.org/sources/libxml2/2.10/libxml2-2.10.3.tar.xz"
|
|
sha256 "5d2cc3d78bec3dbe212a9d7fa629ada25a7da928af432c93060ff5c17ee28a9c"
|
|
license "MIT"
|
|
revision 1
|
|
|
|
# We use a common regex because libxml2 doesn't use GNOME's "even-numbered
|
|
# minor is stable" version scheme.
|
|
livecheck do
|
|
url :stable
|
|
regex(/libxml2[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_ventura: "a47d746469bbec6db18bf4adf78c651fb5a88597f2cf6713d2b81aa7ed1d2659"
|
|
sha256 cellar: :any, arm64_monterey: "0b95b0fa3cae856264629a446f18ad37160760d75863a15fdb2633e1bc9fbcff"
|
|
sha256 cellar: :any, arm64_big_sur: "8ee63f97a42907837e318b651145b156b62ce0a9c11c9ae5a68fdb75c52cbc79"
|
|
sha256 cellar: :any, ventura: "30ea52d1a1c5613d4e168a29c4aba2adcf79e9c856d5ae1db583ed51fb22d133"
|
|
sha256 cellar: :any, monterey: "ece890dc84e7f40e927da92b2a6a38bda2263c9eb48f1bfe59686a457f4bc929"
|
|
sha256 cellar: :any, big_sur: "d45e968d3a420beaa8e04c7f11177b9dbd9851894abe6ec15790041b7e02f310"
|
|
sha256 cellar: :any, catalina: "2b8be40a79ddc2e29fd4a959628ada26747286a290ec0216bc18b9462d46349a"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "df9caed670118ab9d1b84110243428e3b494b2be38d254864d4bfbba6c5c7be2"
|
|
end
|
|
|
|
head do
|
|
url "https://gitlab.gnome.org/GNOME/libxml2.git", branch: "master"
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "libtool" => :build
|
|
depends_on "pkg-config" => :build
|
|
end
|
|
|
|
keg_only :provided_by_macos
|
|
|
|
depends_on "python@3.10" => [:build, :test]
|
|
depends_on "python@3.11" => [:build, :test]
|
|
depends_on "python@3.9" => [:build, :test]
|
|
depends_on "pkg-config" => :test
|
|
depends_on "icu4c"
|
|
depends_on "readline"
|
|
|
|
uses_from_macos "zlib"
|
|
|
|
# Fix crash when using Python 3 using Fedora's patch.
|
|
# Reported upstream:
|
|
# https://bugzilla.gnome.org/show_bug.cgi?id=789714
|
|
# https://gitlab.gnome.org/GNOME/libxml2/issues/12
|
|
patch do
|
|
url "https://bugzilla.opensuse.org/attachment.cgi?id=746044"
|
|
sha256 "37eb81a8ec6929eed1514e891bff2dd05b450bcf0c712153880c485b7366c17c"
|
|
end
|
|
|
|
def pythons
|
|
deps.map(&:to_formula)
|
|
.select { |f| f.name.match?(/^python@\d\.\d+$/) }
|
|
.map { |f| f.opt_libexec/"bin/python" }
|
|
end
|
|
|
|
def install
|
|
system "autoreconf", "--force", "--install", "--verbose" if build.head?
|
|
system "./configure", *std_configure_args,
|
|
"--disable-silent-rules",
|
|
"--with-history",
|
|
"--with-icu",
|
|
"--without-python",
|
|
"--without-lzma"
|
|
system "make", "install"
|
|
|
|
cd "python" do
|
|
sdk_include = if OS.mac?
|
|
sdk = MacOS.sdk_path_if_needed
|
|
sdk/"usr/include" if sdk
|
|
else
|
|
HOMEBREW_PREFIX/"include"
|
|
end
|
|
|
|
includes = [include, sdk_include].compact.map do |inc|
|
|
"'#{inc}',"
|
|
end.join(" ")
|
|
|
|
# We need to insert our include dir first
|
|
inreplace "setup.py", "includes_dir = [",
|
|
"includes_dir = [#{includes}"
|
|
|
|
pythons.each do |python|
|
|
system python, *Language::Python.setup_install_args(prefix, python)
|
|
end
|
|
end
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.c").write <<~EOS
|
|
#include <libxml/tree.h>
|
|
|
|
int main()
|
|
{
|
|
xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
|
|
xmlNodePtr root_node = xmlNewNode(NULL, BAD_CAST "root");
|
|
xmlDocSetRootElement(doc, root_node);
|
|
xmlFreeDoc(doc);
|
|
return 0;
|
|
}
|
|
EOS
|
|
|
|
# Test build with xml2-config
|
|
args = shell_output("#{bin}/xml2-config --cflags --libs").split
|
|
system ENV.cc, "test.c", "-o", "test", *args
|
|
system "./test"
|
|
|
|
# Test build with pkg-config
|
|
ENV.append "PKG_CONFIG_PATH", lib/"pkgconfig"
|
|
args = shell_output("#{Formula["pkg-config"].opt_bin}/pkg-config --cflags --libs libxml-2.0").split
|
|
system ENV.cc, "test.c", "-o", "test", *args
|
|
system "./test"
|
|
|
|
pythons.each do |python|
|
|
with_env(PYTHONPATH: prefix/Language::Python.site_packages(python)) do
|
|
system python, "-c", "import libxml2"
|
|
end
|
|
end
|
|
end
|
|
end
|