Skip to content

Commit 76c9b68

Browse files
committed
lib,src,test,doc: add node:ffi module
1 parent 8edeff9 commit 76c9b68

File tree

237 files changed

+78564
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+78564
-11
lines changed

Makefile

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,23 @@ else
542542
build-sqlite-tests:
543543
endif
544544

545+
FFI_BINDING_GYPS := $(wildcard test/ffi/*/binding.gyp)
546+
547+
FFI_BINDING_SOURCES := \
548+
$(wildcard test/ffi/*/*.c)
549+
550+
# Implicitly depends on $(NODE_EXE), see the build-ffi-tests rule for rationale.
551+
test/ffi/.buildstamp: $(ADDONS_PREREQS) \
552+
$(FFI_BINDING_GYPS) $(FFI_BINDING_SOURCES)
553+
@$(call run_build_addons,"$$PWD/test/ffi",$@)
554+
555+
.PHONY: build-ffi-tests
556+
# .buildstamp needs $(NODE_EXE) but cannot depend on it
557+
# directly because it calls make recursively. The parent make cannot know
558+
# if the subprocess touched anything so it pessimistically assumes that
559+
# .buildstamp is out of date and need a rebuild.
560+
build-ffi-tests: | $(NODE_EXE) test/ffi/.buildstamp ## Build FFI tests.
561+
545562
.PHONY: clear-stalled
546563
clear-stalled: ## Clear any stalled processes.
547564
$(info Clean up any leftover processes but don't error if found.)
@@ -552,7 +569,7 @@ clear-stalled: ## Clear any stalled processes.
552569
fi
553570

554571
.PHONY: test-build
555-
test-build: | all build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests ## Build all tests.
572+
test-build: | all build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests build-ffi-tests ## Build all tests.
556573

557574
.PHONY: test-build-js-native-api
558575
test-build-js-native-api: all build-js-native-api-tests ## Build JS Native-API tests.
@@ -591,7 +608,7 @@ endif
591608

592609
# Related CI job: node-test-commit-arm-fanned
593610
test-ci-native: LOGLEVEL := info ## Build and test addons without building anything else.
594-
test-ci-native: | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp test/sqlite/.buildstamp
611+
test-ci-native: | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp test/sqlite/.buildstamp test/ffi/.buildstamp
595612
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
596613
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
597614
$(TEST_CI_ARGS) $(CI_NATIVE_SUITES)
@@ -614,7 +631,7 @@ test-ci-js: | clear-stalled ## Build and test JavaScript with building anything
614631
.PHONY: test-ci
615632
# Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
616633
test-ci: LOGLEVEL := info ## Build and test everything (CI).
617-
test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests doc-only
634+
test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests build-sqlite-tests build-ffi-tests doc-only
618635
out/Release/cctest --gtest_output=xml:out/junit/cctest.xml
619636
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
620637
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \

configure.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,12 @@
10171017
default=None,
10181018
help='build without SQLite (disables SQLite and Web Storage API)')
10191019

1020+
parser.add_argument('--with-ffi',
1021+
action='store_true',
1022+
dest='with_ffi',
1023+
default=None,
1024+
help='build with FFI (Foreign Function Interface) support')
1025+
10201026
parser.add_argument('--experimental-quic',
10211027
action='store_true',
10221028
dest='experimental_quic',
@@ -2182,6 +2188,12 @@ def without_sqlite_error(option):
21822188

21832189
configure_library('sqlite', o, pkgname='sqlite3')
21842190

2191+
def configure_ffi(o):
2192+
o['variables']['node_use_ffi'] = b(options.with_ffi)
2193+
return
2194+
2195+
configure_library('ffi', o, pkgname='libffi')
2196+
21852197
def configure_quic(o):
21862198
o['variables']['node_use_quic'] = b(options.experimental_quic and
21872199
not options.without_ssl)
@@ -2635,6 +2647,7 @@ def make_bin_override():
26352647
configure_library('ngtcp2', output, pkgname='libngtcp2')
26362648
configure_lief(output);
26372649
configure_sqlite(output);
2650+
configure_ffi(output);
26382651
configure_library('temporal_capi', output)
26392652
configure_library('uvwasi', output)
26402653
configure_library('zstd', output, pkgname='libzstd')

0 commit comments

Comments
 (0)