From 8a548332d4f116c1f95d3b817e33355f8175d80a Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sat, 23 Apr 2016 17:11:24 +0100 Subject: [PATCH] czmqpp 1.2.0 (new formula) Closes #907. Signed-off-by: Mike McQuaid --- Formula/czmqpp.rb | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Formula/czmqpp.rb diff --git a/Formula/czmqpp.rb b/Formula/czmqpp.rb new file mode 100644 index 0000000000..633a38dc2c --- /dev/null +++ b/Formula/czmqpp.rb @@ -0,0 +1,79 @@ +class Czmqpp < Formula + desc "C++ wrapper for czmq" + homepage "https://github.com/zeromq/czmqpp" + url "https://github.com/zeromq/czmqpp/archive/v1.2.0.tar.gz" + sha256 "4ed983c3cfa7c5b0f035c2868357887f5663a7fce75c55da4b0dc47f37d83e2a" + + head "https://github.com/zeromq/czmqpp.git" + + option :universal + + depends_on "autoconf" => :build + depends_on "automake" => :build + depends_on "libtool" => :build + depends_on "pkg-config" => :build + depends_on "czmq" + + needs :cxx11 + + def install + ENV.cxx11 + ENV.universal_binary if build.universal? + + system "./autogen.sh" + system "./configure", "--disable-debug", + "--disable-dependency-tracking", + "--disable-silent-rules", + "--prefix=#{prefix}" + system "make", "install" + end + + test do + (testpath/"test.cpp").write <<-EOS.undent + #include + #include + + #include + + using namespace std; + + int main() + { + const string addr = "inproc://hello-world"; + const string msg = "Hello, World!"; + + czmqpp::context context; + + czmqpp::socket pull_sock(context, ZMQ_PULL); + pull_sock.bind(addr); + + czmqpp::socket push_sock(context, ZMQ_PUSH); + push_sock.connect(addr); + + czmqpp::message send_msg; + const czmqpp::data_chunk send_data(msg.begin(), msg.end()); + send_msg.append(send_data); + if (!send_msg.send(push_sock)) + return 1; + + czmqpp::message recv_msg; + if (!recv_msg.receive(pull_sock)) + return 1; + const czmqpp::data_chunk recv_data = recv_msg.parts()[0]; + string received_msg(recv_data.begin(), recv_data.end()); + cout << received_msg << flush; + + return 0; + } + EOS + + ENV.cxx11 + args = ENV.cxx.split + ENV.cxxflags.to_s.split + %W[ + -o test test.cpp + -I#{include} -L#{lib} -lczmq++ + -L#{Formula["czmq"].opt_lib} -lczmq + ] + system *args + assert_equal "Hello, World!", shell_output("./test") + end +end