homebrew-core/Formula/libgit2.rb
2018-07-09 09:31:25 -07:00

62 lines
2 KiB
Ruby

class Libgit2 < Formula
desc "C library of Git core methods that is re-entrant and linkable"
homepage "https://libgit2.github.com/"
url "https://github.com/libgit2/libgit2/archive/v0.27.3.tar.gz"
sha256 "50a57bd91f57aa310fb7d5e2a340b3779dc17e67b4e7e66111feac5c2432f1a5"
head "https://github.com/libgit2/libgit2.git"
bottle do
cellar :any
sha256 "c635ed5de02c318e538f24bf2f29b1f402cba6b3fca085845f90d62430771cab" => :high_sierra
sha256 "c7238e859b188c391a111fc06095f0ffdeb2fc4893dcf66592d6c44871904209" => :sierra
sha256 "c807a735d96482f60543364f33cd706d19647129a8d9d0a3dced6e1d2c2e13f8" => :el_capitan
end
depends_on "pkg-config" => :build
depends_on "cmake" => :build
depends_on "libssh2" => :recommended
depends_on "openssl" if MacOS.version <= :lion # Uses SecureTransport on >10.7
def install
args = std_cmake_args
args << "-DBUILD_EXAMPLES=YES"
args << "-DBUILD_CLAR=NO" # Don't build tests.
args << "-DUSE_SSH=NO" if build.without? "libssh2"
mkdir "build" do
system "cmake", "..", *args
system "make", "install"
cd "examples" do
(pkgshare/"examples").install "add", "blame", "cat-file", "cgit2",
"describe", "diff", "for-each-ref",
"general", "init", "log", "remote",
"rev-list", "rev-parse", "showindex",
"status", "tag"
end
system "make", "clean"
system "cmake", "..", "-DBUILD_SHARED_LIBS=OFF", *args
system "make"
lib.install "libgit2.a"
end
end
test do
(testpath/"test.c").write <<~EOS
#include <git2.h>
int main(int argc, char *argv[]) {
int options = git_libgit2_features();
return 0;
}
EOS
libssh2 = Formula["libssh2"]
flags = %W[
-I#{include}
-I#{libssh2.opt_include}
-L#{lib}
-lgit2
]
system ENV.cc, "test.c", "-o", "test", *flags
system "./test"
end
end