-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathczmqpp.rb
79 lines (62 loc) · 2.03 KB
/
czmqpp.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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 <iostream>
#include <string>
#include <czmq++/czmqpp.hpp>
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