ac0722190d
no /usr/local/lib for you
58 lines
2 KiB
Ruby
58 lines
2 KiB
Ruby
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-2.1.3/msgpack-2.1.3.tar.gz"
|
|
sha256 "beaac1209f33276b5a75e7a02f8689ed44b97209cef82ba0909e06f0c45f6cae"
|
|
head "https://github.com/msgpack/msgpack-c.git"
|
|
|
|
bottle do
|
|
sha256 "676cc2d2c30367ed29f607431622d49758b29fc80b61c5fd5b698f5a62fe4606" => :sierra
|
|
sha256 "53c063172cdbb7bdeced1c164b7e7d5387cef82571c70657c250e491d7dc10c7" => :el_capitan
|
|
sha256 "a15f24a623631f1f215f90e97d08cfe17945ffb5efc43ebe8cf8b62145d01f05" => :yosemite
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
|
|
def install
|
|
system "cmake", ".", *std_cmake_args
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
# Reference: http://wiki.msgpack.org/display/MSGPACK/QuickStart+for+C+Language
|
|
(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", "-L#{lib}", "-lmsgpackc"
|
|
assert_equal "1\n2\n3\n", `./test`
|
|
end
|
|
end
|