class MsgpackCxx < Formula desc "MessagePack implementation for C++ / msgpack.org[C++]" homepage "https://msgpack.org/" url "https://github.com/msgpack/msgpack-c/releases/download/cpp-6.0.0/msgpack-cxx-6.0.0.tar.gz" sha256 "0948d2db98245fb97b9721cfbc3e44c1b832e3ce3b8cfd7485adc368dc084d14" license "BSL-1.0" head "https://github.com/msgpack/msgpack-c.git", branch: "cpp_master" livecheck do url :stable regex(/^cpp[._-]v?(\d+(?:\.\d+)+)$/i) end bottle do sha256 cellar: :any_skip_relocation, all: "6d0eb136ec6e4cc6c700562837ca5a937631dd475d5ca000f357686f8d6ef2aa" end depends_on "cmake" => :build depends_on "boost" def install system "cmake", "-S", ".", "-B", "build", *std_cmake_args system "cmake", "--build", "build" system "cmake", "--install", "build" end test do # Reference: https://github.com/msgpack/msgpack-c/blob/cpp_master/QUICKSTART-CPP.md (testpath/"test.cpp").write <<~EOS #include #include #include #include int main(void) { // serializes this object. std::vector vec; vec.push_back("Hello"); vec.push_back("MessagePack"); // serialize it into simple buffer. msgpack::sbuffer sbuf; msgpack::pack(sbuf, vec); // deserialize it. msgpack::object_handle oh = msgpack::unpack(sbuf.data(), sbuf.size()); // print the deserialized object. msgpack::object obj = oh.get(); std::cout << obj << std::endl; //=> ["Hello", "MessagePack"] // convert it into statically typed object. std::vector rvec; obj.convert(rvec); } EOS system ENV.cxx, "-o", "test", "test.cpp", "-I#{include}" assert_equal "[\"Hello\",\"MessagePack\"]\n", `./test` end end