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.28.2.tar.gz" sha256 "42b5f1e9b9159d66d86fff0394215c5733b6ef8f9b9d054cdd8c73ad47177fc3" head "https://github.com/libgit2/libgit2.git" bottle do cellar :any sha256 "e1e27df1ed510a850d7cdd342b73207324b7e746946a55f8456b8ce3466ff396" => :mojave sha256 "e0c298cb472a0fcfbef04c8a127d1ab5c51ff5b95957ed17bad88bf1bbff0bb9" => :high_sierra sha256 "ee33e4f829bdc4b29daa5d6ed42adef4ca78d718220012958d32ba54d4eadb39" => :sierra end 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 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