diff --git a/common.gypi b/common.gypi index d6f024ab93a365..694f15ebd23c61 100644 --- a/common.gypi +++ b/common.gypi @@ -458,6 +458,10 @@ '_HAS_EXCEPTIONS=0', 'BUILDING_V8_SHARED=1', 'BUILDING_UV_SHARED=1', + # Stop from defining macros that conflict with + # std::min() and std::max(). We don't use (much) + # but we still inherit it from uv.h. + 'NOMINMAX', ], }], [ 'OS in "linux freebsd openbsd solaris aix os400"', { diff --git a/node.gypi b/node.gypi index 95133818dff7c7..e3c125fb9ec7f8 100644 --- a/node.gypi +++ b/node.gypi @@ -63,10 +63,6 @@ 'FD_SETSIZE=1024', # we need to use node's preferred "win32" rather than gyp's preferred "win" 'NODE_PLATFORM="win32"', - # Stop from defining macros that conflict with - # std::min() and std::max(). We don't use (much) - # but we still inherit it from uv.h. - 'NOMINMAX', '_UNICODE=1', ], 'msvs_precompiled_header': 'tools/msvs/pch/node_pch.h', diff --git a/test/addons/hello-world/binding.gyp b/test/addons/hello-world/binding.gyp index 55fbe7050f18e4..a445af3d1cd18e 100644 --- a/test/addons/hello-world/binding.gyp +++ b/test/addons/hello-world/binding.gyp @@ -4,6 +4,11 @@ 'target_name': 'binding', 'sources': [ 'binding.cc' ], 'includes': ['../common.gypi'], + }, + { + 'target_name': 'binding2', + 'sources': [ 'binding2.cc' ], + 'includes': ['../common.gypi'], } ] } diff --git a/test/addons/hello-world/binding2.cc b/test/addons/hello-world/binding2.cc new file mode 100644 index 00000000000000..b94aecb3c76b26 --- /dev/null +++ b/test/addons/hello-world/binding2.cc @@ -0,0 +1,21 @@ +// Include uv.h and v8.h ahead of node.h to verify that node.h doesn't need to +// be included first. Disable clang-format as it will sort the include lists. +// clang-format off +#include +#include +#include +// clang-format on + +static void Method(const v8::FunctionCallbackInfo& args) { + v8::Isolate* isolate = args.GetIsolate(); + args.GetReturnValue().Set( + v8::String::NewFromUtf8(isolate, "world").ToLocalChecked()); +} + +static void InitModule(v8::Local exports, + v8::Local module, + v8::Local context) { + NODE_SET_METHOD(exports, "hello", Method); +} + +NODE_MODULE(NODE_GYP_MODULE_NAME, InitModule) diff --git a/test/addons/hello-world/test.js b/test/addons/hello-world/test.js index d1d67d34f688c9..79f03f44be857a 100644 --- a/test/addons/hello-world/test.js +++ b/test/addons/hello-world/test.js @@ -6,6 +6,9 @@ const binding = require(bindingPath); assert.strictEqual(binding.hello(), 'world'); console.log('binding.hello() =', binding.hello()); +const binding2 = require(require.resolve(`./build/${common.buildType}/binding2`)); +assert.strictEqual(binding2.hello(), 'world'); + // Test multiple loading of the same module. delete require.cache[bindingPath]; const rebinding = require(bindingPath);