| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6481c93 commit 56e881d
88 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -193,9 +193,10 @@ v8: | |||
| 193 | 193 | ||
| 194 | 194 | test: all | |
| 195 | 195 | $(MAKE) build-addons | |
| 196 | + $(MAKE) build-addons-napi | ||
| 196 | 197 | $(MAKE) cctest | |
| 197 | 198 | $(PYTHON) tools/test.py --mode=release -J \ | |
| 198 | - addons doctool inspector known_issues message pseudo-tty parallel sequential | ||
| 199 | + addons addons-napi doctool inspector known_issues message pseudo-tty parallel sequential | ||
| 199 | 200 | $(MAKE) lint | |
| 200 | 201 | ||
| 201 | 202 | test-parallel: all | |
@@ -262,6 +263,41 @@ test/addons/.buildstamp: config.gypi \ | |||
| 262 | 263 | # TODO(bnoordhuis) Force rebuild after gyp update. | |
| 263 | 264 | build-addons: $(NODE_EXE) test/addons/.buildstamp | |
| 264 | 265 | ||
| 266 | + ADDONS_NAPI_BINDING_GYPS := \ | ||
| 267 | + $(filter-out test/addons-napi/??_*/binding.gyp, \ | ||
| 268 | + $(wildcard test/addons-napi/*/binding.gyp)) | ||
| 269 | + | ||
| 270 | + ADDONS_NAPI_BINDING_SOURCES := \ | ||
| 271 | + $(filter-out test/addons-napi/??_*/*.cc, $(wildcard test/addons-napi/*/*.cc)) \ | ||
| 272 | + $(filter-out test/addons-napi/??_*/*.h, $(wildcard test/addons-napi/*/*.h)) | ||
| 273 | + | ||
| 274 | + # Implicitly depends on $(NODE_EXE), see the build-addons-napi rule for rationale. | ||
| 275 | + test/addons-napi/.buildstamp: config.gypi \ | ||
| 276 | + deps/npm/node_modules/node-gyp/package.json \ | ||
| 277 | + $(ADDONS_NAPI_BINDING_GYPS) $(ADDONS_NAPI_BINDING_SOURCES) \ | ||
| 278 | + deps/uv/include/*.h deps/v8/include/*.h \ | ||
| 279 | + src/node.h src/node_buffer.h src/node_object_wrap.h src/node_version.h \ | ||
| 280 | + src/node_api.h src/node_api_types.h | ||
| 281 | + # Cannot use $(wildcard test/addons-napi/*/) here, it's evaluated before | ||
| 282 | + # embedded addons have been generated from the documentation. | ||
| 283 | + @for dirname in test/addons-napi/*/; do \ | ||
| 284 | + printf "\nBuilding addon $$PWD/$$dirname\n" ; \ | ||
| 285 | + env MAKEFLAGS="-j1" $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp \ | ||
| 286 | + --loglevel=$(LOGLEVEL) rebuild \ | ||
| 287 | + --python="$(PYTHON)" \ | ||
| 288 | + --directory="$$PWD/$$dirname" \ | ||
| 289 | + --nodedir="$$PWD" || exit 1 ; \ | ||
| 290 | + done | ||
| 291 | + touch $@ | ||
| 292 | + | ||
| 293 | + # .buildstamp and .docbuildstamp need $(NODE_EXE) but cannot depend on it | ||
| 294 | + # directly because it calls make recursively. The parent make cannot know | ||
| 295 | + # if the subprocess touched anything so it pessimistically assumes that | ||
| 296 | + # .buildstamp and .docbuildstamp are out of date and need a rebuild. | ||
| 297 | + # Just goes to show that recursive make really is harmful... | ||
| 298 | + # TODO(bnoordhuis) Force rebuild after gyp or node-gyp update. | ||
| 299 | + build-addons-napi: $(NODE_EXE) test/addons-napi/.buildstamp | ||
| 300 | + | ||
| 265 | 301 | ifeq ($(OSTYPE),$(filter $(OSTYPE),darwin aix)) | |
| 266 | 302 | XARGS = xargs | |
| 267 | 303 | else | |
@@ -274,20 +310,22 @@ clear-stalled: | |||
| 274 | 310 | test-gc: all test/gc/build/Release/binding.node | |
| 275 | 311 | $(PYTHON) tools/test.py --mode=release gc | |
| 276 | 312 | ||
| 277 | - test-build: | all build-addons | ||
| 313 | + test-build: | all build-addons build-addons-napi | ||
| 314 | + | ||
| 315 | + test-build-addons-napi: all build-addons-napi | ||
| 278 | 316 | ||
| 279 | 317 | test-all: test-build test/gc/build/Release/binding.node | |
| 280 | 318 | $(PYTHON) tools/test.py --mode=debug,release | |
| 281 | 319 | ||
| 282 | 320 | test-all-valgrind: test-build | |
| 283 | 321 | $(PYTHON) tools/test.py --mode=debug,release --valgrind | |
| 284 | 322 | ||
| 285 | - CI_NATIVE_SUITES := addons | ||
| 323 | + CI_NATIVE_SUITES := addons addons-napi | ||
| 286 | 324 | CI_JS_SUITES := doctool inspector known_issues message parallel pseudo-tty sequential | |
| 287 | 325 | ||
| 288 | 326 | # Build and test addons without building anything else | |
| 289 | 327 | test-ci-native: LOGLEVEL := info | |
| 290 | - test-ci-native: | test/addons/.buildstamp | ||
| 328 | + test-ci-native: | test/addons/.buildstamp test/addons-napi/.buildstamp | ||
| 291 | 329 | $(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \ | |
| 292 | 330 | --mode=release --flaky-tests=$(FLAKY_TESTS) \ | |
| 293 | 331 | $(TEST_CI_ARGS) $(CI_NATIVE_SUITES) | |
@@ -304,11 +342,11 @@ test-ci-js: | clear-stalled | |||
| 304 | 342 | fi | |
| 305 | 343 | ||
| 306 | 344 | test-ci: LOGLEVEL := info | |
| 307 | - test-ci: | clear-stalled build-addons | ||
| 345 | + test-ci: | clear-stalled build-addons build-addons-napi | ||
| 308 | 346 | out/Release/cctest --gtest_output=tap:cctest.tap | |
| 309 | 347 | $(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \ | |
| 310 | 348 | --mode=release --flaky-tests=$(FLAKY_TESTS) \ | |
| 311 | - $(TEST_CI_ARGS) $(CI_NATIVE_SUITES) $(CI_JS_SUITES) | ||
| 349 | + $(TEST_CI_ARGS) $(CI_NATIVE_SUITES) addons-napi $(CI_JS_SUITES) | ||
| 312 | 350 | # Clean up any leftover processes | |
| 313 | 351 | PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \ | |
| 314 | 352 | if [ "$${PS_OUT}" ]; then \ | |
@@ -355,7 +393,10 @@ test-npm: $(NODE_EXE) | |||
| 355 | 393 | test-npm-publish: $(NODE_EXE) | |
| 356 | 394 | npm_package_config_publishtest=true $(NODE) deps/npm/test/run.js | |
| 357 | 395 | ||
| 358 | - test-addons: test-build | ||
| 396 | + test-addons-napi: test-build-addons-napi | ||
| 397 | + $(PYTHON) tools/test.py --mode=release addons-napi | ||
| 398 | + | ||
| 399 | + test-addons: test-build test-addons-napi | ||
| 359 | 400 | $(PYTHON) tools/test.py --mode=release addons | |
| 360 | 401 | ||
| 361 | 402 | test-addons-clean: | |
@@ -821,6 +862,7 @@ CPPLINT_EXCLUDE += src/node_root_certs.h | |||
| 821 | 862 | CPPLINT_EXCLUDE += src/queue.h | |
| 822 | 863 | CPPLINT_EXCLUDE += src/tree.h | |
| 823 | 864 | CPPLINT_EXCLUDE += $(wildcard test/addons/??_*/*.cc test/addons/??_*/*.h) | |
| 865 | + CPPLINT_EXCLUDE += $(wildcard test/addons-napi/??_*/*.cc test/addons-napi/??_*/*.h) | ||
| 824 | 866 | ||
| 825 | 867 | CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \ | |
| 826 | 868 | src/*.c \ | |
@@ -830,6 +872,8 @@ CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \ | |||
| 830 | 872 | test/addons/*/*.h \ | |
| 831 | 873 | test/cctest/*.cc \ | |
| 832 | 874 | test/cctest/*.h \ | |
| 875 | + test/addons-napi/*/*.cc \ | ||
| 876 | + test/addons-napi/*/*.h \ | ||
| 833 | 877 | test/gc/binding.cc \ | |
| 834 | 878 | tools/icu/*.cc \ | |
| 835 | 879 | tools/icu/*.h \ | |
@@ -869,4 +913,4 @@ endif | |||
| 869 | 913 | test-v8-intl test-v8-benchmarks test-v8-all v8 lint-ci bench-ci jslint-ci \ | |
| 870 | 914 | doc-only $(TARBALL)-headers test-ci test-ci-native test-ci-js build-ci \ | |
| 871 | 915 | clear-stalled coverage-clean coverage-build coverage-test coverage \ | |
| 872 | - list-gtests | ||
| 916 | + list-gtests test-addons-napi build-addons-napi | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -144,6 +144,14 @@ added: v6.0.0 | |||
| 144 | 144 | ||
| 145 | 145 | Silence all process warnings (including deprecations). | |
| 146 | 146 | ||
| 147 | + ### `--napi-modules` | ||
| 148 | + <!-- YAML | ||
| 149 | + added: REPLACEME | ||
| 150 | + --> | ||
| 151 | + | ||
| 152 | + Enable loading native modules compiled with the ABI-stable Node.js API (N-API) | ||
| 153 | + (experimental). | ||
| 154 | + | ||
| 147 | 155 | ### `--trace-warnings` | |
| 148 | 156 | <!-- YAML | |
| 149 | 157 | added: v6.0.0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,6 +119,11 @@ Throw errors for deprecations. | |||
| 119 | 119 | .BR \-\-no\-warnings | |
| 120 | 120 | Silence all process warnings (including deprecations). | |
| 121 | 121 | ||
| 122 | + .TP | ||
| 123 | + .BR \-\-napi\-modules | ||
| 124 | + Enable loading native modules compiled with the ABI-stable Node.js API (N-API) | ||
| 125 | + (experimental). | ||
| 126 | + | ||
| 122 | 127 | .TP | |
| 123 | 128 | .BR \-\-trace\-warnings | |
| 124 | 129 | Print stack traces for process warnings (including deprecations). | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -167,6 +167,9 @@ | |||
| 167 | 167 | 'src/handle_wrap.cc', | |
| 168 | 168 | 'src/js_stream.cc', | |
| 169 | 169 | 'src/node.cc', | |
| 170 | + 'src/node_api.cc', | ||
| 171 | + 'src/node_api.h', | ||
| 172 | + 'src/node_api_types.h', | ||
| 170 | 173 | 'src/node_buffer.cc', | |
| 171 | 174 | 'src/node_config.cc', | |
| 172 | 175 | 'src/node_constants.cc', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -180,6 +180,9 @@ static const char* trace_enabled_categories = nullptr; | |||
| 180 | 180 | std::string icu_data_dir; // NOLINT(runtime/string) | |
| 181 | 181 | #endif | |
| 182 | 182 | ||
| 183 | + // N-API is in experimental state, disabled by default. | ||
| 184 | + bool load_napi_modules = false; | ||
| 185 | + | ||
| 183 | 186 | // used by C++ modules as well | |
| 184 | 187 | bool no_deprecation = false; | |
| 185 | 188 | ||
@@ -2463,15 +2466,25 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) { | |||
| 2463 | 2466 | } | |
| 2464 | 2467 | if (mp->nm_version != NODE_MODULE_VERSION) { | |
| 2465 | 2468 | char errmsg[1024]; | |
| 2466 | - snprintf(errmsg, | ||
| 2467 | - sizeof(errmsg), | ||
| 2468 | - "The module '%s'" | ||
| 2469 | - "\nwas compiled against a different Node.js version using" | ||
| 2470 | - "\nNODE_MODULE_VERSION %d. This version of Node.js requires" | ||
| 2471 | - "\nNODE_MODULE_VERSION %d. Please try re-compiling or " | ||
| 2472 | - "re-installing\nthe module (for instance, using `npm rebuild` or " | ||
| 2473 | - "`npm install`).", | ||
| 2474 | - *filename, mp->nm_version, NODE_MODULE_VERSION); | ||
| 2469 | + if (mp->nm_version == -1) { | ||
| 2470 | + snprintf(errmsg, | ||
| 2471 | + sizeof(errmsg), | ||
| 2472 | + "The module '%s'" | ||
| 2473 | + "\nwas compiled against the ABI-stable Node.js API (N-API)." | ||
| 2474 | + "\nThis feature is experimental and must be enabled on the " | ||
| 2475 | + "\ncommand-line by adding --napi-modules.", | ||
| 2476 | + *filename); | ||
| 2477 | + } else { | ||
| 2478 | + snprintf(errmsg, | ||
| 2479 | + sizeof(errmsg), | ||
| 2480 | + "The module '%s'" | ||
| 2481 | + "\nwas compiled against a different Node.js version using" | ||
| 2482 | + "\nNODE_MODULE_VERSION %d. This version of Node.js requires" | ||
| 2483 | + "\nNODE_MODULE_VERSION %d. Please try re-compiling or " | ||
| 2484 | + "re-installing\nthe module (for instance, using `npm rebuild` " | ||
| 2485 | + "or `npm install`).", | ||
| 2486 | + *filename, mp->nm_version, NODE_MODULE_VERSION); | ||
| 2487 | + } | ||
| 2475 | 2488 | ||
| 2476 | 2489 | // NOTE: `mp` is allocated inside of the shared library's memory, calling | |
| 2477 | 2490 | // `uv_dlclose` will deallocate it | |
@@ -3537,6 +3550,7 @@ static void PrintHelp() { | |||
| 3537 | 3550 | " --trace-deprecation show stack traces on deprecations\n" | |
| 3538 | 3551 | " --throw-deprecation throw an exception on deprecations\n" | |
| 3539 | 3552 | " --no-warnings silence all process warnings\n" | |
| 3553 | + " --napi-modules load N-API modules\n" | ||
| 3540 | 3554 | " --trace-warnings show stack traces on process warnings\n" | |
| 3541 | 3555 | " --redirect-warnings=path\n" | |
| 3542 | 3556 | " write warnings to path instead of\n" | |
@@ -3709,6 +3723,8 @@ static void ParseArgs(int* argc, | |||
| 3709 | 3723 | force_repl = true; | |
| 3710 | 3724 | } else if (strcmp(arg, "--no-deprecation") == 0) { | |
| 3711 | 3725 | no_deprecation = true; | |
| 3726 | + } else if (strcmp(arg, "--napi-modules") == 0) { | ||
| 3727 | + load_napi_modules = true; | ||
| 3712 | 3728 | } else if (strcmp(arg, "--no-warnings") == 0) { | |
| 3713 | 3729 | no_process_warnings = true; | |
| 3714 | 3730 | } else if (strcmp(arg, "--trace-warnings") == 0) { | |
@@ -4489,6 +4505,11 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data, | |||
| 4489 | 4505 | if (debug_enabled) | |
| 4490 | 4506 | EnableDebug(&env); | |
| 4491 | 4507 | ||
| 4508 | + if (load_napi_modules) { | ||
| 4509 | + ProcessEmitWarning(&env, "N-API is an experimental feature " | ||
| 4510 | + "and could change at any time."); | ||
| 4511 | + } | ||
| 4512 | + | ||
| 4492 | 4513 | { | |
| 4493 | 4514 | SealHandleScope seal(isolate); | |
| 4494 | 4515 | bool more; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments