Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,7 @@
#include "nan.h"

#ifdef _WIN32
# include <delayimp.h>
# define snprintf _snprintf_s
typedef BOOL (WINAPI* SetDllDirectoryFunc)(wchar_t *lpPathName);
class SetDllDirectoryCaller {
public:
explicit SetDllDirectoryCaller() : func_(NULL) { }
~SetDllDirectoryCaller() {
if (func_)
func_(NULL);
}
// Sets the SetDllDirectory function pointer to activates this object.
void set_func(SetDllDirectoryFunc func) { func_ = func; }
private:
SetDllDirectoryFunc func_;
};
#endif

#define ZMQ_CAN_DISCONNECT (ZMQ_VERSION_MAJOR == 3 && ZMQ_VERSION_MINOR >= 2) || ZMQ_VERSION_MAJOR > 3
Expand Down Expand Up @@ -1586,36 +1572,6 @@ namespace zmq {
// module

extern "C" NAN_MODULE_INIT(init) {
#ifdef _MSC_VER
// On Windows, inject the windows/lib folder into the DLL search path so that
// it will pick up our bundled DLL in case we do not have zmq installed on
// this system.
HMODULE kernel32_dll = GetModuleHandleW(L"kernel32.dll");
SetDllDirectoryCaller caller;
SetDllDirectoryFunc set_dll_directory;
wchar_t path[MAX_PATH] = L"";
wchar_t pathDir[MAX_PATH] = L"";
if (kernel32_dll != NULL) {
set_dll_directory =
reinterpret_cast<SetDllDirectoryFunc>(GetProcAddress(kernel32_dll, "SetDllDirectoryW"));
if (set_dll_directory) {
GetModuleFileNameW(GetModuleHandleW(L"zmq.node"), path, MAX_PATH - 1);
wcsncpy(pathDir, path, wcsrchr(path, '\\') - path);
path[0] = '\0';
pathDir[wcslen(pathDir)] = '\0';
# ifdef _WIN64
wcscat(pathDir, L"\\..\\..\\windows\\lib\\x64");
# else
wcscat(pathDir, L"\\..\\..\\windows\\lib\\x86");
# endif
_wfullpath(path, pathDir, MAX_PATH);
set_dll_directory(path);
caller.set_func(set_dll_directory);
assert (!FAILED(__HrLoadAllImportsForDll("libzmq-v100-mt-4_0_4.dll")) &&
"delayload error");
}
}
#endif
zmq::Initialize(target);
}

Expand Down
50 changes: 20 additions & 30 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,41 @@
{
'target_name': 'zmq',
'sources': [ 'binding.cc' ],
'include_dirs' : [
"<!(node -e \"require('nan')\")"
],
'include_dirs' : ["<!(node -e \"require('nan')\")"],
'cflags!': ['-fno-exceptions'],
'cflags_cc!': ['-fno-exceptions'],
'conditions': [
['OS=="win"', {
'win_delay_load_hook': 'true',
'msbuild_toolset': 'v120',
'defines': ['ZMQ_STATIC'],
'include_dirs': ['windows/include'],
'link_settings': {
'libraries': [
'Delayimp.lib',
],
'conditions': [
['target_arch=="ia32"', {
'libraries': [
'<(PRODUCT_DIR)/../../windows/lib/x86/libzmq-v100-mt-4_0_4.lib',
]
},{
'libraries': [
'<(PRODUCT_DIR)/../../windows/lib/x64/libzmq-v100-mt-4_0_4.lib',
]
}]
],
},
'msvs_settings': {
'VCLinkerTool': {
'DelayLoadDLLs': ['libzmq-v100-mt-4_0_4.dll']
}
},
}, {
'libraries': [ '<(PRODUCT_DIR)/../../zmq/lib/libzmq.a' ],
'include_dirs': [ '<(PRODUCT_DIR)/../../zmq/include' ],
'cflags!': ['-fno-exceptions'],
'cflags_cc!': ['-fno-exceptions'],
'conditions': [
['target_arch=="ia32"', {
'libraries': [
'<(PRODUCT_DIR)/../../windows/lib/Win32/libzmq',
'ws2_32.lib',
]
},{
'libraries': [
'<(PRODUCT_DIR)/../../windows/lib/x64/libzmq',
'ws2_32.lib',
]
}]
],
}],
['OS=="mac" or OS=="solaris"', {
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'MACOSX_DEPLOYMENT_TARGET': '10.6',
},
'libraries': [ '<(PRODUCT_DIR)/../../zmq/lib/libzmq.a' ],
'include_dirs': [ '<(PRODUCT_DIR)/../../zmq/include' ],
}],
['OS=="openbsd" or OS=="freebsd"', {
}],
['OS=="linux"', {
'libraries': [ '<(PRODUCT_DIR)/../../zmq/lib/libzmq.a' ],
'include_dirs': [ '<(PRODUCT_DIR)/../../zmq/include' ],
}],
]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow you really went to town here. 👀

Expand Down
Loading