2010-03-22 22:56:32 +00:00
|
|
|
require 'formula'
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Msgpack < Formula
|
2011-05-22 01:08:13 +00:00
|
|
|
homepage 'http://msgpack.org/'
|
2012-02-04 17:45:57 +00:00
|
|
|
url 'http://msgpack.org/releases/cpp/msgpack-0.5.7.tar.gz'
|
|
|
|
sha256 '7c203265cf14a4723820e0fc7ac14bf4bad5578f7bc525e9835c70cd36e7d1b8'
|
2010-03-22 22:56:32 +00:00
|
|
|
|
2012-03-18 20:33:24 +00:00
|
|
|
fails_with :llvm do
|
2012-04-11 05:25:58 +00:00
|
|
|
build 2334
|
|
|
|
end
|
2012-02-08 02:05:18 +00:00
|
|
|
|
2010-03-22 22:56:32 +00:00
|
|
|
def install
|
2010-07-01 23:11:09 +00:00
|
|
|
system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}"
|
2010-03-22 22:56:32 +00:00
|
|
|
system "make install"
|
|
|
|
end
|
2012-04-11 05:26:32 +00:00
|
|
|
|
2012-11-01 19:48:36 +00:00
|
|
|
test do
|
2012-04-11 05:26:32 +00:00
|
|
|
# Reference: http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+C+Language
|
2012-11-01 19:48:36 +00:00
|
|
|
(testpath/'test.c').write <<-EOS.undent
|
|
|
|
#include <msgpack.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
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"
|
|
|
|
`./test` == "1\n2\n3\n"
|
2012-04-11 05:26:32 +00:00
|
|
|
end
|
2010-03-22 22:56:32 +00:00
|
|
|
end
|