Created
March 9, 2016 22:14
-
-
Save raizyr/f7ef280d6c2bf0213106 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.24.0.tar.gz" | |
sha256 "1c6693f943bee3f634b9094376f93e7e03b9ca77354a33f4e903fdcb2ee8b2b0" | |
head "https://github.com/libgit2/libgit2.git" | |
bottle do | |
cellar :any | |
revision 1 | |
sha256 "76ab9cf0de803820f9009475bb1646ae584a496aacbe5fa77480379af4adff15" => :el_capitan | |
sha256 "479dfc903eb7f90d6ddf9d2e197afc1eaa359116de4ab5ca0c81a6cda2fef165" => :yosemite | |
sha256 "6e0e3c7d27cdba4579bbda4a88bfdad8e49e8e3ce19502778d2c9e646fa24f15" => :mavericks | |
end | |
option :universal | |
depends_on "pkg-config" => :build | |
depends_on "cmake" => :build | |
depends_on "libssh2" => :optional | |
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" | |
if build.universal? | |
ENV.universal_binary | |
args << "-DCMAKE_OSX_ARCHITECTURES=#{Hardware::CPU.universal_archs.as_cmake_arch_flags}" | |
end | |
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 | |
end | |
end | |
test do | |
(testpath/"test.c").write <<-EOS.undent | |
#include <git2.h> | |
int main(int argc, char *argv[]) { | |
int options = git_libgit2_features(); | |
return 0; | |
} | |
EOS | |
libssh2 = Formula["libssh2"] | |
flags = (ENV.cflags || "").split + (ENV.cppflags || "").split + (ENV.ldflags || "").split | |
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