121 lines
3.9 KiB
Ruby
121 lines
3.9 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.2.tar.xz"
|
|
sha256 "d240abe6da9c65cb1900dd9bf3a3501ccf88b3c2a1cb98317d03f272dda5b265"
|
|
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_monterey: "7281512e642f45f7ce883de48ae32786a2942a0252b0133a23cc62633f2f2851"
|
|
sha256 cellar: :any, arm64_big_sur: "a92b48bea7270ae1ad549225dc06a12b94b234121033a40b7f19886621b910e9"
|
|
sha256 cellar: :any, monterey: "b153b19cd51d3e13f9fa3c21f546d1cfa3fb04afa866baf8507c71cec54e274b"
|
|
sha256 cellar: :any, big_sur: "bfc635ea5b8428255183f1de146e8e83d6cb41cdfe6467874a4207ee3f96b985"
|
|
sha256 cellar: :any, catalina: "eb853d351e63c98fa9fe05b1a53f801ba03e0dc9bcf0b67499bb5e53c86baa34"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "7c53fce421547511201e757c2556a3fe53fc1ec2e98e3bb8db5d92b7ce3277dd"
|
|
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.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 install
|
|
system "autoreconf", "-fiv" if build.head?
|
|
|
|
system "./configure", "--disable-dependency-tracking",
|
|
"--prefix=#{prefix}",
|
|
"--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}"
|
|
|
|
["3.9", "3.10"].each do |xy|
|
|
system "python#{xy}", *Language::Python.setup_install_args(prefix, "python#{xy}")
|
|
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 = %w[test.c -o test]
|
|
args += shell_output("#{bin}/xml2-config --cflags --libs").split
|
|
system ENV.cc, *args
|
|
system "./test"
|
|
|
|
# Test build with pkg-config
|
|
ENV.append "PKG_CONFIG_PATH", lib/"pkgconfig"
|
|
args = %w[test.c -o test]
|
|
args += shell_output("#{Formula["pkg-config"].opt_bin}/pkg-config --cflags --libs libxml-2.0").split
|
|
system ENV.cc, *args
|
|
system "./test"
|
|
|
|
orig_pypath = ENV["PYTHONPATH"]
|
|
["3.9", "3.10"].each do |xy|
|
|
ENV.prepend_path "PYTHONPATH", lib/"python#{xy}/site-packages"
|
|
system Formula["python@#{xy}"].opt_bin/"python#{xy}", "-c", "import libxml2"
|
|
ENV["PYTHONPATH"] = orig_pypath
|
|
end
|
|
end
|
|
end
|