Skip to content

Commit

Permalink
Support external libnanomsg better for --use_system_libnanomsg=true
Browse files Browse the repository at this point in the history
nanomsg headers are installed in /usr/include/nanomsg but only
ancient versions (0.8 and before) provided -I/usr/include/nanomsg
in libnanomsg.pc, if ever. The embedded source is for 1.1.0, the
previous commit stopped using libnanomsg.pc.

Instead, pass -DSYSTEM_NANOMSG=1 to the compiler when using
--use_system_libnanomsg=true and use conditional compiling to
include headers from the correct location.

Signed-off-by: Zoltán Böszörményi <[email protected]>
  • Loading branch information
zboszor committed Feb 9, 2024
1 parent 5d98b8f commit f43a1de
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
8 changes: 7 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
}],
['OS=="linux" and use_system_libnanomsg=="true"', {
'include_dirs+': [
'<!@(pkg-config nanomsg --cflags-only-I | sed s/-I//g)/nanomsg || echo "")'
'<!@(pkg-config nanomsg --cflags-only-I | sed s/-I//g || echo "")'
],
'libraries': [
'<!@(pkg-config nanomsg --libs || echo "")'
],
'defines': [
'SYSTEM_NANOMSG=1',
],
}],
['OS=="mac" and use_system_libnanomsg=="true"', {
'include_dirs+': [
Expand All @@ -32,6 +35,9 @@
'libraries': [
'<!@(pkg-config nanomsg --libs || echo "")'
],
'defines': [
'SYSTEM_NANOMSG=1',
],
}],
['OS=="mac" and asan=="true"', {
'xcode_settings': {
Expand Down
21 changes: 20 additions & 1 deletion src/node_nanomsg.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
#ifndef SYSTEM_NANOMSG

#include "bus.h"
#include "inproc.h"
#include "ipc.h"
#include "nn.h"
#include "pair.h"
#include "pipeline.h"
#include "poll_ctx.h"
#include "pubsub.h"
#include "reqrep.h"
#include "survey.h"
#include "tcp.h"
#include "ws.h"

#else

#include "nanomsg/bus.h"
#include "nanomsg/inproc.h"
#include "nanomsg/ipc.h"
#include "nanomsg/nn.h"
#include "nanomsg/pair.h"
#include "nanomsg/pipeline.h"
#include "nanomsg/pubsub.h"
#include "nanomsg/reqrep.h"
#include "nanomsg/survey.h"
#include "nanomsg/tcp.h"
#include "nanomsg/ws.h"

#endif

#include "poll_ctx.h"

NAN_METHOD(Socket) {
int domain = Nan::To<int>(info[0]).FromJust();
int protocol = Nan::To<int>(info[1]).FromJust();
Expand Down
4 changes: 4 additions & 0 deletions src/poll_ctx.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#ifndef SYSTEM_NANOMSG
#include "nn.h"
#else
#include "nanomsg/nn.h"
#endif
#include "poll_ctx.h"

void PollCtx::on_readable(uv_poll_t* req, int /* status */, int events) {
Expand Down

0 comments on commit f43a1de

Please sign in to comment.