diff --git a/projects/msgpack.org/package.yml b/projects/msgpack.org/package.yml new file mode 100644 index 00000000..a3bac68b --- /dev/null +++ b/projects/msgpack.org/package.yml @@ -0,0 +1,39 @@ +distributable: + url: https://github.com/msgpack/msgpack-c/releases/download/c-{{version}}/msgpack-c-{{version}}.tar.gz + strip-components: 1 + +versions: + github: msgpack/msgpack-c + strip: /^cpp-/ + +build: + dependencies: + tea.xyz/gx/cc: c99 + tea.xyz/gx/make: '*' + cmake.org: '*' + google.com/googletest: '*' + + script: + - cmake -S . -B build $ARGS + - cmake --build build + - cmake --install build + env: + ARGS: + - -DMSGPACK_BUILD_TESTS=OFF + - -DCMAKE_INSTALL_PREFIX={{prefix}} + - -DCMAKE_INSTALL_LIBDIR=lib + - -DCMAKE_BUILD_TYPE=Release + - -DCMAKE_FIND_FRAMEWORK=LAST + - -DCMAKE_VERBOSE_MAKEFILE=ON + - -Wno-dev + - -DBUILD_TESTING=OFF + +test: + dependencies: + tea.xyz/gx/cc: c99 + freedesktop.org/pkg-config: '*' + script: + - cc test.c -lmsgpack-c -o test + - ./test + - pkg-config --modversion msgpack-c | grep {{version}} + \ No newline at end of file diff --git a/projects/msgpack.org/test.c b/projects/msgpack.org/test.c new file mode 100644 index 00000000..ecaad5b1 --- /dev/null +++ b/projects/msgpack.org/test.c @@ -0,0 +1,29 @@ +#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(""); + } +} \ No newline at end of file