From 64b6938e5dd70128d358c4c7eb55255cf4b3579d Mon Sep 17 00:00:00 2001 From: Eugine Blikh Date: Fri, 6 Oct 2017 19:49:15 +0300 Subject: [PATCH] msgpuck 2.0 (new formula) Closes #19116. Signed-off-by: ilovezfs --- Formula/msgpuck.rb | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Formula/msgpuck.rb diff --git a/Formula/msgpuck.rb b/Formula/msgpuck.rb new file mode 100644 index 0000000000..2169d74336 --- /dev/null +++ b/Formula/msgpuck.rb @@ -0,0 +1,51 @@ +class Msgpuck < Formula + desc "A simple and efficient MsgPack binary serialization library" + homepage "https://rtsisyk.github.io/msgpuck/" + url "https://github.com/rtsisyk/msgpuck/archive/2.0.tar.gz" + sha256 "01e6aa55d4d52a5b19f7ce9a9845506d9ab3f5abcf844a75e880b8378150a63d" + head "https://github.com/rtsisyk/msgpuck.git" + + depends_on "cmake" => :build + + def install + system "cmake", ".", *std_cmake_args + system "make", "install" + end + + test do + (testpath/"test.c").write <<-'EOS'.undent + /* Encode and decode an array */ + #include + #include + + int main() { + const char *str = "hello world"; + + char buf[1024]; + char *w = buf; + const char *pos = buf; + + w = mp_encode_array(w, 4); + w = mp_encode_uint(w, 10); + w = mp_encode_str(w, str, strlen(str)); + w = mp_encode_bool(w, true); + w = mp_encode_double(w, 3.1415); + + assert(mp_typeof(*pos) == MP_ARRAY ); + mp_decode_array(&pos); + assert(mp_typeof(*pos) == MP_UINT ); + mp_next(&pos); + assert(mp_typeof(*pos) == MP_STR ); + mp_next(&pos); + assert(mp_typeof(*pos) == MP_BOOL ); + mp_next(&pos); + assert(mp_typeof(*pos) == MP_DOUBLE); + mp_next(&pos); + + return 0; + } + EOS + system ENV.cc, "-I#{include}", "-L#{lib}", "-lmsgpuck", "-o", "test", "test.c" + system "#{testpath}/test" + end +end