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
38 changes: 19 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ v8:

test: all
$(MAKE) build-addons
$(MAKE) build-addons-abi
$(MAKE) build-addons-napi
$(MAKE) cctest
$(PYTHON) tools/test.py --mode=release -J \
addons addons-abi doctool inspector known_issues message pseudo-tty parallel sequential
addons addons-napi doctool inspector known_issues message pseudo-tty parallel sequential
$(MAKE) lint

test-parallel: all
Expand Down Expand Up @@ -190,16 +190,16 @@ test/addons/.buildstamp: config.gypi \
build-addons: $(NODE_EXE) test/addons/.buildstamp

ADDONS_ABI_BINDING_GYPS := \
$(filter-out test/addons-abi/??_*/binding.gyp, \
$(wildcard test/addons-abi/*/binding.gyp))
$(filter-out test/addons-napi/??_*/binding.gyp, \
$(wildcard test/addons-napi/*/binding.gyp))

# Implicitly depends on $(NODE_EXE), see the build-addons-abi rule for rationale.
test/addons-abi/.buildstamp: $(ADDONS_ABI_BINDING_GYPS) \
# Implicitly depends on $(NODE_EXE), see the build-addons-napi rule for rationale.
test/addons-napi/.buildstamp: $(ADDONS_ABI_BINDING_GYPS) \
deps/uv/include/*.h deps/v8/include/*.h \
src/node.h src/node_buffer.h src/node_object_wrap.h
# Cannot use $(wildcard test/addons-abi/*/) here, it's evaluated before
# Cannot use $(wildcard test/addons-napi/*/) here, it's evaluated before
# embedded addons have been generated from the documentation.
for dirname in test/addons-abi/*/; do \
for dirname in test/addons-napi/*/; do \
$(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp rebuild \
--python="$(PYTHON)" \
--directory="$$PWD/$$dirname" \
Expand All @@ -213,13 +213,13 @@ test/addons-abi/.buildstamp: $(ADDONS_ABI_BINDING_GYPS) \
# .buildstamp and .docbuildstamp are out of date and need a rebuild.
# Just goes to show that recursive make really is harmful...
# TODO(bnoordhuis) Force rebuild after gyp or node-gyp update.
build-addons-abi: $(NODE_EXE) test/addons-abi/.buildstamp
build-addons-napi: $(NODE_EXE) test/addons-napi/.buildstamp


test-gc: all test/gc/node_modules/weak/build/Release/weakref.node
$(PYTHON) tools/test.py --mode=release gc

test-build: | all build-addons build-addons-abi
test-build: | all build-addons build-addons-napi

test-all: test-build test/gc/node_modules/weak/build/Release/weakref.node
$(PYTHON) tools/test.py --mode=debug,release
Expand All @@ -244,11 +244,11 @@ test-ci-js:
$(TEST_CI_ARGS) $(CI_JS_SUITES)

test-ci: LOGLEVEL := info
test-ci: | build-addons build-addons-abi
test-ci: | build-addons build-addons-napi
out/Release/cctest --gtest_output=tap:cctest.tap
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
--mode=release --flaky-tests=$(FLAKY_TESTS) \
$(TEST_CI_ARGS) addons-abi $(CI_NATIVE_SUITES) $(CI_JS_SUITES)
$(TEST_CI_ARGS) addons-napi $(CI_NATIVE_SUITES) $(CI_JS_SUITES)

test-release: test-build
$(PYTHON) tools/test.py --mode=release
Expand Down Expand Up @@ -289,8 +289,8 @@ test-npm-publish: $(NODE_EXE)
test-addons: test-build
$(PYTHON) tools/test.py --mode=release addons

test-addons-abi: test-build
$(PYTHON) tools/test.py --mode=release addons-abi
test-addons-napi: test-build
$(PYTHON) tools/test.py --mode=release addons-napi

test-timers:
$(MAKE) --directory=tools faketime
Expand Down Expand Up @@ -744,7 +744,7 @@ CPPLINT_EXCLUDE += src/node_root_certs.h
CPPLINT_EXCLUDE += src/queue.h
CPPLINT_EXCLUDE += src/tree.h
CPPLINT_EXCLUDE += $(wildcard test/addons/??_*/*.cc test/addons/??_*/*.h)
CPPLINT_EXCLUDE += $(wildcard test/addons-abi/??_*/*.cc test/addons-abi/??_*/*.h)
CPPLINT_EXCLUDE += $(wildcard test/addons-napi/??_*/*.cc test/addons-napi/??_*/*.h)

CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \
src/*.c \
Expand All @@ -754,8 +754,8 @@ CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \
test/addons/*/*.h \
test/cctest/*.cc \
test/cctest/*.h \
test/addons-abi/*/*.cc \
test/addons-abi/*/*.h \
test/addons-napi/*/*.cc \
test/addons-napi/*/*.h \
tools/icu/*.cc \
tools/icu/*.h \
))
Expand Down Expand Up @@ -788,8 +788,8 @@ endif
.PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean \
check uninstall install install-includes install-bin all staticlib \
dynamiclib test test-all \
test-addons build-addons test-addons-abi build-addons-abi \
test-addons-abi build-addons-abi website-upload pkg \
test-addons build-addons test-addons-napi build-addons-napi \
test-addons-napi build-addons-napi website-upload pkg \
blog blogclean tar binary release-only bench-http-simple bench-idle \
bench-all bench bench-misc bench-array bench-buffer bench-net \
bench-http bench-fs bench-tls cctest run-ci test-v8 test-v8-intl \
Expand Down
15 changes: 4 additions & 11 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@
'src/handle_wrap.cc',
'src/js_stream.cc',
'src/node.cc',
'src/node_asyncapi.cc',
# 'src/node_api.cc',
'src/node_api_jsrt.cc',
'src/node_buffer.cc',
'src/node_config.cc',
'src/node_constants.cc',
Expand All @@ -164,8 +165,6 @@
'src/node_file.cc',
'src/node_http_parser.cc',
'src/node_javascript.cc',
'src/node_jsrtapi.cc',
# 'src/node_jsvmapi.cc',
'src/node_main.cc',
'src/node_os.cc',
'src/node_revert.cc',
Expand Down Expand Up @@ -201,10 +200,8 @@
'src/handle_wrap.h',
'src/js_stream.h',
'src/node.h',
'src/node_api_helpers.h',
'src/node_asyncapi.h',
'src/node_asyncapi_internal.h',
'src/node_asyncapi_types.h',
'src/node_api.h',
'src/node_api_types.h',
'src/node_buffer.h',
'src/node_constants.h',
'src/node_debug_options.h',
Expand All @@ -213,10 +210,6 @@
'src/node_internals.h',
'src/node_javascript.h',
'src/node_mutex.h',
'src/node_jsvmapi.h',
'src/node_jsvmapi_internal.h',
'src/node_jsvmapi_types.h',
'src/node_mutex.h',
'src/node_root_certs.h',
'src/node_version.h',
'src/node_watchdog.h',
Expand Down
72 changes: 28 additions & 44 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#include "node_lttng.h"
#endif

#include "node_jsvmapi_internal.h"

#include "ares.h"
#include "async-wrap.h"
#include "async-wrap-inl.h"
Expand Down Expand Up @@ -2502,19 +2500,27 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
return;
}

bool isNapiModule = mp->nm_version == -1;

if (mp->nm_version != NODE_MODULE_VERSION && !isNapiModule) {
if (mp->nm_version != NODE_MODULE_VERSION) {
char errmsg[1024];
snprintf(errmsg,
sizeof(errmsg),
"The module '%s'"
"\nwas compiled against a different Node.js version using"
"\nNODE_MODULE_VERSION %d. This version of Node.js requires"
"\nNODE_MODULE_VERSION %d. Please try re-compiling or "
"re-installing\nthe module (for instance, using `npm rebuild` or"
"`npm install`).",
*filename, mp->nm_version, NODE_MODULE_VERSION);
if (mp->nm_version == -1) {
snprintf(errmsg,
sizeof(errmsg),
"The module '%s'"
"\nwas compiled against the ABI-stable Node.js API (N-API)."
"\nThis feature is experimental and must be enabled on the "
"\ncommand-line by adding --napi-modules.",
*filename);
} else {
snprintf(errmsg,
sizeof(errmsg),
"The module '%s'"
"\nwas compiled against a different Node.js version using"
"\nNODE_MODULE_VERSION %d. This version of Node.js requires"
"\nNODE_MODULE_VERSION %d. Please try re-compiling or "
"re-installing\nthe module (for instance, using `npm rebuild` "
"or `npm install`).",
*filename, mp->nm_version, NODE_MODULE_VERSION);
}

// NOTE: `mp` is allocated inside of the shared library's memory, calling
// `uv_dlclose` will deallocate it
Expand All @@ -2535,28 +2541,14 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
Local<String> exports_string = env->exports_string();
Local<Object> exports = module->Get(exports_string)->ToObject(env->isolate());

if (isNapiModule) {
if (mp->nm_register_func != nullptr) {
reinterpret_cast<node::addon_abi_register_func>(mp->nm_register_func)(
v8impl::JsEnvFromV8Isolate(v8::Isolate::GetCurrent()),
v8impl::JsValueFromV8LocalValue(exports),
v8impl::JsValueFromV8LocalValue(module),
mp->nm_priv);
} else {
uv_dlclose(&lib);
env->ThrowError("Module has no declared entry point.");
return;
}
if (mp->nm_context_register_func != nullptr) {
mp->nm_context_register_func(exports, module, env->context(), mp->nm_priv);
} else if (mp->nm_register_func != nullptr) {
mp->nm_register_func(exports, module, mp->nm_priv);
} else {
if (mp->nm_context_register_func != nullptr) {
mp->nm_context_register_func(exports, module, env->context(), mp->nm_priv);
} else if (mp->nm_register_func != nullptr) {
mp->nm_register_func(exports, module, mp->nm_priv);
} else {
uv_dlclose(&lib);
env->ThrowError("Module has no declared entry point.");
return;
}
uv_dlclose(&lib);
env->ThrowError("Module has no declared entry point.");
return;
}

// Tell coverity that 'handle' should not be freed when we return.
Expand Down Expand Up @@ -2784,15 +2776,7 @@ static void LinkedBinding(const FunctionCallbackInfo<Value>& args) {
env->context(),
mod->nm_priv);
} else if (mod->nm_register_func != nullptr) {
if (mod->nm_version != -1) {
mod->nm_register_func(exports, module, mod->nm_priv);
} else {
reinterpret_cast<node::addon_abi_register_func>(mod->nm_register_func)(
v8impl::JsEnvFromV8Isolate(v8::Isolate::GetCurrent()),
v8impl::JsValueFromV8LocalValue(exports),
v8impl::JsValueFromV8LocalValue(module),
mod->nm_priv);
}
mod->nm_register_func(exports, module, mod->nm_priv);
} else {
return env->ThrowError("Linked module has no declared entry point.");
}
Expand Down
7 changes: 0 additions & 7 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "v8.h" // NOLINT(build/include_order)
#include "node_version.h" // NODE_MODULE_VERSION
#include "tracing/trace_event.h"
#include "node_jsvmapi.h"

#define NODE_MAKE_VERSION(major, minor, patch) \
((major) * 0x1000 + (minor) * 0x100 + (patch))
Expand Down Expand Up @@ -393,12 +392,6 @@ typedef void (*addon_context_register_func)(
v8::Local<v8::Context> context,
void* priv);

typedef void (*addon_abi_register_func)(
napi_env env,
napi_value exports,
napi_value module,
void* priv);

#define NM_F_BUILTIN 0x01
#define NM_F_LINKED 0x02

Expand Down
Loading