n-api: add support for abi stable module API · nodejs/node@56e881d

@@ -193,9 +193,10 @@ v8:

193193194194

test: all

195195

$(MAKE) build-addons

196+

$(MAKE) build-addons-napi

196197

$(MAKE) cctest

197198

$(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

199200

$(MAKE) lint

200201201202

test-parallel: all

@@ -262,6 +263,41 @@ test/addons/.buildstamp: config.gypi \

262263

# TODO(bnoordhuis) Force rebuild after gyp update.

263264

build-addons: $(NODE_EXE) test/addons/.buildstamp

264265266+

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+265301

ifeq ($(OSTYPE),$(filter $(OSTYPE),darwin aix))

266302

XARGS = xargs

267303

else

@@ -274,20 +310,22 @@ clear-stalled:

274310

test-gc: all test/gc/build/Release/binding.node

275311

$(PYTHON) tools/test.py --mode=release gc

276312277-

test-build: | all build-addons

313+

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

314+315+

test-build-addons-napi: all build-addons-napi

278316279317

test-all: test-build test/gc/build/Release/binding.node

280318

$(PYTHON) tools/test.py --mode=debug,release

281319282320

test-all-valgrind: test-build

283321

$(PYTHON) tools/test.py --mode=debug,release --valgrind

284322285-

CI_NATIVE_SUITES := addons

323+

CI_NATIVE_SUITES := addons addons-napi

286324

CI_JS_SUITES := doctool inspector known_issues message parallel pseudo-tty sequential

287325288326

# Build and test addons without building anything else

289327

test-ci-native: LOGLEVEL := info

290-

test-ci-native: | test/addons/.buildstamp

328+

test-ci-native: | test/addons/.buildstamp test/addons-napi/.buildstamp

291329

$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \

292330

--mode=release --flaky-tests=$(FLAKY_TESTS) \

293331

$(TEST_CI_ARGS) $(CI_NATIVE_SUITES)

@@ -304,11 +342,11 @@ test-ci-js: | clear-stalled

304342

fi

305343306344

test-ci: LOGLEVEL := info

307-

test-ci: | clear-stalled build-addons

345+

test-ci: | clear-stalled build-addons build-addons-napi

308346

out/Release/cctest --gtest_output=tap:cctest.tap

309347

$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \

310348

--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)

312350

# Clean up any leftover processes

313351

PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \

314352

if [ "$${PS_OUT}" ]; then \

@@ -355,7 +393,10 @@ test-npm: $(NODE_EXE)

355393

test-npm-publish: $(NODE_EXE)

356394

npm_package_config_publishtest=true $(NODE) deps/npm/test/run.js

357395358-

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

359400

$(PYTHON) tools/test.py --mode=release addons

360401361402

test-addons-clean:

@@ -821,6 +862,7 @@ CPPLINT_EXCLUDE += src/node_root_certs.h

821862

CPPLINT_EXCLUDE += src/queue.h

822863

CPPLINT_EXCLUDE += src/tree.h

823864

CPPLINT_EXCLUDE += $(wildcard test/addons/??_*/*.cc test/addons/??_*/*.h)

865+

CPPLINT_EXCLUDE += $(wildcard test/addons-napi/??_*/*.cc test/addons-napi/??_*/*.h)

824866825867

CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \

826868

src/*.c \

@@ -830,6 +872,8 @@ CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \

830872

test/addons/*/*.h \

831873

test/cctest/*.cc \

832874

test/cctest/*.h \

875+

test/addons-napi/*/*.cc \

876+

test/addons-napi/*/*.h \

833877

test/gc/binding.cc \

834878

tools/icu/*.cc \

835879

tools/icu/*.h \

@@ -869,4 +913,4 @@ endif

869913

test-v8-intl test-v8-benchmarks test-v8-all v8 lint-ci bench-ci jslint-ci \

870914

doc-only $(TARBALL)-headers test-ci test-ci-native test-ci-js build-ci \

871915

clear-stalled coverage-clean coverage-build coverage-test coverage \

872-

list-gtests

916+

list-gtests test-addons-napi build-addons-napi