Skip to content

Instantly share code, notes, and snippets.

@marcofucci
Last active August 12, 2019 15:39
Show Gist options
  • Save marcofucci/a5c146be5877d8352e38759352ba2577 to your computer and use it in GitHub Desktop.
Save marcofucci/a5c146be5877d8352e38759352ba2577 to your computer and use it in GitHub Desktop.
Libgit2 0.27.3
=begin
Instructions:
brew reinstall --build-from-source <path-to-raw-version-of-this-gist>
=end
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"
head "https://github.com/libgit2/libgit2.git"
depends_on "cmake" => :build
depends_on "pkg-config" => :build
depends_on "libssh2"
def install
args = std_cmake_args
args << "-DBUILD_EXAMPLES=YES"
args << "-DBUILD_CLAR=NO" # Don't build tests.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment