Skip to content

Commit ecb6009

Browse files
committed
To reduce nanomsg lib size
1 parent e8ae12d commit ecb6009

File tree

3 files changed

+258
-24
lines changed

3 files changed

+258
-24
lines changed

CMakeLists.txt

+105-2
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ else ()
9494
endif()
9595

9696
# User-defined options.
97+
# Commenting out few code to reduce libnanomsg size for yocto environment.
9798

9899
option (NN_STATIC_LIB "Build static library instead of shared library." OFF)
99-
option (NN_ENABLE_DOC "Enable building documentation." ON)
100+
option (NN_ENABLE_DOC "Enable building documentation." OFF)
100101
option (NN_ENABLE_GETADDRINFO_A "Enable/disable use of getaddrinfo_a in place of getaddrinfo." ON)
101102
option (NN_TESTS "Build and run nanomsg tests" OFF)
102103
option (NN_TOOLS "Build nanomsg tools" OFF)
103-
104+
#option (NN_ENABLE_NANOCAT "Enable building nanocat utility." ${NN_TOOLS})
104105

105106
# Platform checks.
106107

@@ -241,6 +242,10 @@ add_subdirectory (src)
241242

242243
# Build the tools
243244

245+
if (NN_ENABLE_NANOCAT)
246+
add_executable (nanocat tools/nanocat.c tools/options.c)
247+
target_link_libraries (nanocat ${PROJECT_NAME})
248+
endif ()
244249

245250
if (NN_ENABLE_DOC)
246251
find_program (ASCIIDOCTOR_EXE asciidoctor)
@@ -289,6 +294,9 @@ if (NN_ENABLE_DOC)
289294

290295
endmacro (add_libnanomsg_man)
291296

297+
if (NN_ENABLE_NANOCAT)
298+
add_libnanomsg_man (nanocat 1)
299+
endif ()
292300

293301
add_libnanomsg_man (nn_errno 3)
294302
add_libnanomsg_man (nn_strerror 3)
@@ -334,13 +342,108 @@ endif ()
334342

335343
# Build unit tests.
336344

345+
if (NN_TESTS)
346+
347+
enable_testing ()
348+
set (all_tests "")
349+
350+
set (TEST_PORT 12100)
351+
macro (add_libnanomsg_test NAME TIMEOUT)
352+
list (APPEND all_tests ${NAME})
353+
add_executable (${NAME} tests/${NAME}.c)
354+
target_link_libraries (${NAME} ${PROJECT_NAME})
355+
add_test (NAME ${NAME} COMMAND ${NAME} ${TEST_PORT})
356+
set_tests_properties (${NAME} PROPERTIES TIMEOUT ${TIMEOUT})
357+
math (EXPR TEST_PORT "${TEST_PORT}+10")
358+
endmacro (add_libnanomsg_test)
359+
360+
# Transport tests.
361+
add_libnanomsg_test (inproc 5)
362+
add_libnanomsg_test (inproc_shutdown 5)
363+
add_libnanomsg_test (ipc 5)
364+
add_libnanomsg_test (ipc_shutdown 30)
365+
add_libnanomsg_test (ipc_stress 5)
366+
add_libnanomsg_test (tcp 5)
367+
add_libnanomsg_test (tcp_shutdown 120)
368+
add_libnanomsg_test (ws 5)
369+
370+
# Protocol tests.
371+
add_libnanomsg_test (pair 5)
372+
add_libnanomsg_test (pubsub 5)
373+
add_libnanomsg_test (reqrep 5)
374+
add_libnanomsg_test (pipeline 5)
375+
add_libnanomsg_test (survey 5)
376+
add_libnanomsg_test (bus 5)
377+
378+
# Feature tests.
379+
add_libnanomsg_test (async_shutdown 30)
380+
add_libnanomsg_test (block 5)
381+
add_libnanomsg_test (term 5)
382+
add_libnanomsg_test (timeo 5)
383+
add_libnanomsg_test (iovec 5)
384+
add_libnanomsg_test (msg 5)
385+
add_libnanomsg_test (prio 5)
386+
add_libnanomsg_test (poll 5)
387+
add_libnanomsg_test (device 5)
388+
add_libnanomsg_test (device4 5)
389+
add_libnanomsg_test (device5 5)
390+
add_libnanomsg_test (device6 5)
391+
add_libnanomsg_test (device7 30)
392+
add_libnanomsg_test (emfile 5)
393+
add_libnanomsg_test (domain 5)
394+
add_libnanomsg_test (trie 5)
395+
add_libnanomsg_test (list 5)
396+
add_libnanomsg_test (hash 5)
397+
add_libnanomsg_test (stats 5)
398+
add_libnanomsg_test (symbol 5)
399+
add_libnanomsg_test (separation 5)
400+
add_libnanomsg_test (zerocopy 5)
401+
add_libnanomsg_test (shutdown 5)
402+
add_libnanomsg_test (cmsg 5)
403+
add_libnanomsg_test (bug328 5)
404+
add_libnanomsg_test (bug777 5)
405+
add_libnanomsg_test (ws_async_shutdown 5)
406+
add_libnanomsg_test (reqttl 10)
407+
add_libnanomsg_test (surveyttl 10)
408+
409+
# Platform-specific tests
410+
if (WIN32)
411+
add_libnanomsg_test (win_sec_attr 5)
412+
endif()
413+
414+
# Build the performance tests.
337415

416+
macro (add_libnanomsg_perf NAME)
417+
add_executable (${NAME} perf/${NAME}.c)
418+
target_link_libraries (${NAME} ${PROJECT_NAME})
419+
endmacro (add_libnanomsg_perf)
420+
421+
add_libnanomsg_perf (inproc_lat)
422+
add_libnanomsg_perf (inproc_thr)
423+
add_libnanomsg_perf (local_lat)
424+
add_libnanomsg_perf (remote_lat)
425+
add_libnanomsg_perf (local_thr)
426+
add_libnanomsg_perf (remote_thr)
427+
428+
endif ()
338429

339430
install (TARGETS LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
340431
install (TARGETS ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
341432
install (FILES src/nn.h DESTINATION include/nanomsg)
433+
#install (FILES src/inproc.h DESTINATION include/nanomsg)
434+
#install (FILES src/ipc.h DESTINATION include/nanomsg)
342435
install (FILES src/tcp.h DESTINATION include/nanomsg)
436+
#install (FILES src/ws.h DESTINATION include/nanomsg)
437+
#install (FILES src/pair.h DESTINATION include/nanomsg)
438+
#install (FILES src/pubsub.h DESTINATION include/nanomsg)
439+
#install (FILES src/reqrep.h DESTINATION include/nanomsg)
343440
install (FILES src/pipeline.h DESTINATION include/nanomsg)
441+
#install (FILES src/survey.h DESTINATION include/nanomsg)
442+
#install (FILES src/bus.h DESTINATION include/nanomsg)
443+
444+
if (NN_ENABLE_NANOCAT)
445+
install (TARGETS nanocat RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
446+
endif()
344447

345448
set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
346449
set (CPACK_PACKAGE_VERSION ${NN_PACKAGE_VERSION})

src/CMakeLists.txt

+97-22
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,20 @@
2323
# IN THE SOFTWARE.
2424
#
2525

26+
# /* Commenting out few code to reduce libnanomsg size for yocto environment. */
27+
2628
set (NN_SOURCES
2729
nn.h
30+
# inproc.h
31+
# ipc.h
2832
tcp.h
33+
# ws.h
34+
# pair.h
35+
# pubsub.h
36+
# reqrep.h
2937
pipeline.h
38+
# survey.h
39+
# bus.h
3040

3141
core/ep.h
3242
core/ep.c
@@ -105,8 +115,8 @@ set (NN_SOURCES
105115
utils/wire.h
106116
utils/wire.c
107117

108-
devices/device.h
109-
devices/device.c
118+
# devices/device.h
119+
# devices/device.c
110120

111121
protocols/utils/dist.h
112122
protocols/utils/dist.c
@@ -119,6 +129,9 @@ set (NN_SOURCES
119129
protocols/utils/priolist.h
120130
protocols/utils/priolist.c
121131

132+
# protocols/bus/bus.c
133+
# protocols/bus/xbus.h
134+
# protocols/bus/xbus.c
122135

123136
protocols/pipeline/push.c
124137
protocols/pipeline/pull.c
@@ -127,27 +140,77 @@ set (NN_SOURCES
127140
protocols/pipeline/xpush.h
128141
protocols/pipeline/xpush.c
129142

143+
# protocols/pair/pair.c
144+
# protocols/pair/xpair.h
145+
# protocols/pair/xpair.c
130146

131-
transports/utils/backoff.h
132-
transports/utils/backoff.c
133-
transports/utils/dns.h
134-
transports/utils/dns.c
135-
transports/utils/dns_getaddrinfo.h
136-
transports/utils/dns_getaddrinfo.inc
137-
transports/utils/dns_getaddrinfo_a.h
138-
transports/utils/dns_getaddrinfo_a.inc
139-
transports/utils/iface.h
140-
transports/utils/iface.c
141-
transports/utils/literal.h
142-
transports/utils/literal.c
143-
transports/utils/port.h
144-
transports/utils/port.c
145-
transports/utils/streamhdr.h
146-
transports/utils/streamhdr.c
147-
transports/utils/base64.h
148-
transports/utils/base64.c
147+
# protocols/pubsub/pub.c
148+
# protocols/pubsub/sub.c
149+
# protocols/pubsub/trie.h
150+
# protocols/pubsub/trie.c
151+
# protocols/pubsub/xpub.h
152+
# protocols/pubsub/xpub.c
153+
# protocols/pubsub/xsub.h
154+
# protocols/pubsub/xsub.c
149155

150-
156+
# protocols/reqrep/req.h
157+
# protocols/reqrep/req.c
158+
# protocols/reqrep/rep.h
159+
# protocols/reqrep/rep.c
160+
# protocols/reqrep/task.h
161+
# protocols/reqrep/task.c
162+
# protocols/reqrep/xrep.h
163+
# protocols/reqrep/xrep.c
164+
# protocols/reqrep/xreq.h
165+
# protocols/reqrep/xreq.c
166+
167+
# protocols/survey/respondent.c
168+
# protocols/survey/surveyor.c
169+
# protocols/survey/xrespondent.h
170+
# protocols/survey/xrespondent.c
171+
# protocols/survey/xsurveyor.h
172+
# protocols/survey/xsurveyor.c
173+
174+
# transports/utils/backoff.h
175+
# transports/utils/backoff.c
176+
# transports/utils/dns.h
177+
# transports/utils/dns.c
178+
# transports/utils/dns_getaddrinfo.h
179+
# transports/utils/dns_getaddrinfo.inc
180+
# transports/utils/dns_getaddrinfo_a.h
181+
# transports/utils/dns_getaddrinfo_a.inc
182+
# transports/utils/iface.h
183+
# transports/utils/iface.c
184+
# transports/utils/literal.h
185+
# transports/utils/literal.c
186+
# transports/utils/port.h
187+
# transports/utils/port.c
188+
# transports/utils/streamhdr.h
189+
# transports/utils/streamhdr.c
190+
# transports/utils/base64.h
191+
# transports/utils/base64.c
192+
193+
# transports/inproc/binproc.h
194+
# transports/inproc/binproc.c
195+
# transports/inproc/cinproc.h
196+
# transports/inproc/cinproc.c
197+
# transports/inproc/inproc.c
198+
# transports/inproc/ins.h
199+
# transports/inproc/ins.c
200+
# transports/inproc/msgqueue.h
201+
# transports/inproc/msgqueue.c
202+
# transports/inproc/sinproc.h
203+
# transports/inproc/sinproc.c
204+
205+
# transports/ipc/aipc.h
206+
# transports/ipc/aipc.c
207+
# transports/ipc/bipc.h
208+
# transports/ipc/bipc.c
209+
# transports/ipc/cipc.h
210+
# transports/ipc/cipc.c
211+
# transports/ipc/ipc.c
212+
# transports/ipc/sipc.h
213+
# transports/ipc/sipc.c
151214

152215
transports/tcp/atcp.h
153216
transports/tcp/atcp.c
@@ -159,7 +222,19 @@ set (NN_SOURCES
159222
transports/tcp/stcp.c
160223
transports/tcp/tcp.c
161224

162-
225+
# transports/ws/aws.h
226+
# transports/ws/aws.c
227+
# transports/ws/bws.h
228+
# transports/ws/bws.c
229+
# transports/ws/cws.h
230+
# transports/ws/cws.c
231+
# transports/ws/sws.h
232+
# transports/ws/sws.c
233+
# transports/ws/ws.c
234+
# transports/ws/ws_handshake.h
235+
# transports/ws/ws_handshake.c
236+
# transports/ws/sha1.h
237+
# transports/ws/sha1.c
163238
)
164239

165240
if (WIN32)

src/core/global.c

+56
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
#include "../utils/msg.h"
4646
#include "../utils/attr.h"
4747

48+
/* Commenting out few code to reduce libnanomsg size for yocto environment. */
49+
50+
//#include "../pubsub.h"
4851
#include "../pipeline.h"
4952

5053
#include <stddef.h>
@@ -78,27 +81,80 @@ CT_ASSERT (NN_MAX_SOCKETS <= 0x10000);
7881

7982
/* We could put these in an external header file, but there really is
8083
need to. We are the only thing that needs them. */
84+
85+
/*extern struct nn_socktype nn_pair_socktype;
86+
extern struct nn_socktype nn_xpair_socktype;
87+
extern struct nn_socktype nn_pub_socktype;
88+
extern struct nn_socktype nn_sub_socktype;
89+
extern struct nn_socktype nn_xpub_socktype;
90+
extern struct nn_socktype nn_xsub_socktype;
91+
extern struct nn_socktype nn_rep_socktype;
92+
extern struct nn_socktype nn_req_socktype;
93+
extern struct nn_socktype nn_xrep_socktype;
94+
extern struct nn_socktype nn_xreq_socktype;*/
8195
extern struct nn_socktype nn_push_socktype;
8296
extern struct nn_socktype nn_xpush_socktype;
8397
extern struct nn_socktype nn_pull_socktype;
8498
extern struct nn_socktype nn_xpull_socktype;
8599

100+
/*extern struct nn_socktype nn_respondent_socktype;
101+
extern struct nn_socktype nn_surveyor_socktype;
102+
extern struct nn_socktype nn_xrespondent_socktype;
103+
extern struct nn_socktype nn_xsurveyor_socktype;
104+
extern struct nn_socktype nn_bus_socktype;
105+
extern struct nn_socktype nn_xbus_socktype;*/
106+
107+
86108
/* Array of known socket types. */
87109
const struct nn_socktype *nn_socktypes[] = {
110+
/*
111+
&nn_pair_socktype,
112+
&nn_xpair_socktype,
113+
&nn_pub_socktype,
114+
&nn_sub_socktype,
115+
&nn_xpub_socktype,
116+
&nn_xsub_socktype,
117+
&nn_rep_socktype,
118+
&nn_req_socktype,
119+
&nn_xrep_socktype,
120+
&nn_xreq_socktype,
121+
*/
88122
&nn_push_socktype,
89123
&nn_xpush_socktype,
90124
&nn_pull_socktype,
91125
&nn_xpull_socktype,
126+
/*
127+
&nn_respondent_socktype,
128+
&nn_surveyor_socktype,
129+
&nn_xrespondent_socktype,
130+
&nn_xsurveyor_socktype,
131+
&nn_bus_socktype,
132+
&nn_xbus_socktype,
133+
*/
92134
NULL,
93135
};
94136

95137
/* As with protocols, we could have these in a header file, but we are the
96138
only consumer, so just declare them inline. */
97139

140+
/*
141+
extern struct nn_transport nn_inproc;
142+
extern struct nn_transport nn_ipc;
143+
*/
98144
extern struct nn_transport nn_tcp;
145+
/*
146+
extern struct nn_transport nn_ws;
147+
*/
99148

100149
const struct nn_transport *nn_transports[] = {
150+
/*
151+
&nn_inproc,
152+
&nn_ipc,
153+
*/
101154
&nn_tcp,
155+
/*
156+
&nn_ws,
157+
*/
102158
NULL,
103159
};
104160

0 commit comments

Comments
 (0)