class Msgpack < Formula desc "Library for a binary-based efficient data interchange format" homepage "https://msgpack.org/" url "https://github.com/msgpack/msgpack-c/releases/download/cpp-1.3.0/msgpack-1.3.0.tar.gz" sha256 "b539c9aa1bbe728b9c43bfae7120353461793fa007363aae8e4bb8297948b4b7" bottle do cellar :any sha256 "fe84050181a04546212fbfd270340b5cccf37267ed612820d048f43dfa0f646f" => :el_capitan sha256 "ffc401b8c943bb0702e2f0e4ed5851921cbfc0afa3d6608e3f9b889e91e574ea" => :yosemite sha256 "7bed7c201a147f3b275d79fdd8364c7a18b8e7f732e7da6a331df40ca79b15dd" => :mavericks end head do url "https://github.com/msgpack/msgpack-c.git" depends_on "automake" => :build depends_on "autoconf" => :build depends_on "libtool" => :build end fails_with :llvm do build 2334 end def install system "./bootstrap" if build.head? system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}" system "make", "install" end test do # Reference: http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+C+Language (testpath/"test.c").write <<-EOS.undent #include #include int main(void) { msgpack_sbuffer* buffer = msgpack_sbuffer_new(); msgpack_packer* pk = msgpack_packer_new(buffer, msgpack_sbuffer_write); msgpack_pack_int(pk, 1); msgpack_pack_int(pk, 2); msgpack_pack_int(pk, 3); /* deserializes these objects using msgpack_unpacker. */ msgpack_unpacker pac; msgpack_unpacker_init(&pac, MSGPACK_UNPACKER_INIT_BUFFER_SIZE); /* feeds the buffer. */ msgpack_unpacker_reserve_buffer(&pac, buffer->size); memcpy(msgpack_unpacker_buffer(&pac), buffer->data, buffer->size); msgpack_unpacker_buffer_consumed(&pac, buffer->size); /* now starts streaming deserialization. */ msgpack_unpacked result; msgpack_unpacked_init(&result); while(msgpack_unpacker_next(&pac, &result)) { msgpack_object_print(stdout, result.data); puts(""); } } EOS system ENV.cc, "-o", "test", "test.c", "-lmsgpack" assert_equal "1\n2\n3\n", `./test` end end