Skip to content

Commit

Permalink
Merge pull request #44 from lgeiger/windows
Browse files Browse the repository at this point in the history
Windows prebuilts
  • Loading branch information
rgbkrk authored Sep 16, 2016
2 parents dc8bf6d + 841deea commit 59bea2c
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 229 deletions.
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' ],
}],
]
}
Expand Down
Loading

0 comments on commit 59bea2c

Please sign in to comment.