Skip to content

Commit 57a6821

Browse files
committed
ffi: initial ffi implementation
1 parent 3abbc38 commit 57a6821

File tree

584 files changed

+186508
-7
lines changed

Some content is hidden

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

584 files changed

+186508
-7
lines changed

LICENSE

+25
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,31 @@ The externally maintained libraries used by Node.js are:
13601360
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13611361
"""
13621362

1363+
- libffi, located at deps/libffi, is licensed as follows:
1364+
"""
1365+
libffi - Copyright (c) 1996-2022 Anthony Green, Red Hat, Inc and others.
1366+
See source files for details.
1367+
1368+
Permission is hereby granted, free of charge, to any person obtaining
1369+
a copy of this software and associated documentation files (the
1370+
``Software''), to deal in the Software without restriction, including
1371+
without limitation the rights to use, copy, modify, merge, publish,
1372+
distribute, sublicense, and/or sell copies of the Software, and to
1373+
permit persons to whom the Software is furnished to do so, subject to
1374+
the following conditions:
1375+
1376+
The above copyright notice and this permission notice shall be
1377+
included in all copies or substantial portions of the Software.
1378+
1379+
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
1380+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1381+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1382+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1383+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1384+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1385+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1386+
"""
1387+
13631388
- npm, located at deps/npm, is licensed as follows:
13641389
"""
13651390
The npm application

Makefile

+44-6
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ with-code-cache test-code-cache:
170170

171171
out/Makefile: config.gypi common.gypi node.gyp \
172172
deps/uv/uv.gyp deps/llhttp/llhttp.gyp deps/zlib/zlib.gyp \
173-
deps/simdutf/simdutf.gyp deps/ada/ada.gyp \
173+
deps/simdutf/simdutf.gyp deps/ada/ada.gyp deps/libffi/libffi.gyp \
174174
tools/v8_gypfiles/toolchain.gypi tools/v8_gypfiles/features.gypi \
175175
tools/v8_gypfiles/inspector.gypi tools/v8_gypfiles/v8.gyp
176176
$(PYTHON) tools/gyp_node.py -f make
@@ -421,6 +421,30 @@ test/addons/.buildstamp: $(ADDONS_PREREQS) \
421421
# TODO(bnoordhuis) Force rebuild after gyp update.
422422
build-addons: | $(NODE_EXE) test/addons/.buildstamp
423423

424+
FFI_BINDING_GYPS := \
425+
$(filter-out test/ffi/??_*/binding.gyp, \
426+
$(wildcard test/ffi/*/binding.gyp))
427+
428+
FFI_BINDING_SOURCES := \
429+
$(filter-out test/ffi/??_*/*.c, $(wildcard test/ffi/*/*.c)) \
430+
$(filter-out test/ffi/??_*/*.h, $(wildcard test/ffi/*/*.h))
431+
432+
# Implicitly depends on $(NODE_EXE), see the build-ffi-tests rule for rationale.
433+
# Depends on node-gyp package.json so that build-ffi-tests is (re)executed when
434+
# node-gyp is updated as part of an npm update.
435+
test/ffi/.buildstamp: $(ADDONS_PREREQS) \
436+
$(FFI_BINDING_GYPS) $(FFI_BINDING_SOURCES)
437+
@$(call run_build_addons,"$$PWD/test/ffi",$@)
438+
439+
.PHONY: build-ffi-tests
440+
# .buildstamp needs $(NODE_EXE) but cannot depend on it
441+
# directly because it calls make recursively. The parent make cannot know
442+
# if the subprocess touched anything so it pessimistically assumes that
443+
# .buildstamp is out of date and need a rebuild.
444+
# Just goes to show that recursive make really is harmful...
445+
# TODO(bnoordhuis) Force rebuild after gyp update.
446+
build-ffi-tests: | $(NODE_EXE) test/ffi/.buildstamp
447+
424448
JS_NATIVE_API_BINDING_GYPS := \
425449
$(filter-out test/js-native-api/??_*/binding.gyp, \
426450
$(wildcard test/js-native-api/*/binding.gyp))
@@ -492,7 +516,10 @@ clear-stalled:
492516
fi
493517

494518
.PHONY: test-build
495-
test-build: | all build-addons build-js-native-api-tests build-node-api-tests
519+
test-build: | all build-addons build-ffi-tests build-js-native-api-tests build-node-api-tests
520+
521+
.PHONY: test-build-ffi
522+
test-build-ffi: all build-ffi-tests
496523

497524
.PHONY: test-build-js-native-api
498525
test-build-js-native-api: all build-js-native-api-tests
@@ -513,7 +540,7 @@ test-all-suites: | clear-stalled test-build bench-addons-build doc-only ## Run a
513540
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) test/*
514541

515542
JS_SUITES ?= default
516-
NATIVE_SUITES ?= addons js-native-api node-api
543+
NATIVE_SUITES ?= addons ffi js-native-api node-api
517544
# CI_* variables should be kept synchronized with the ones in vcbuild.bat
518545
CI_NATIVE_SUITES ?= $(NATIVE_SUITES) benchmark
519546
CI_JS_SUITES ?= $(JS_SUITES) pummel
@@ -527,7 +554,7 @@ endif
527554
# Build and test addons without building anything else
528555
# Related CI job: node-test-commit-arm-fanned
529556
test-ci-native: LOGLEVEL := info
530-
test-ci-native: | benchmark/napi/.buildstamp test/addons/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp
557+
test-ci-native: | benchmark/napi/.buildstamp test/addons/.buildstamp test/ffi/.buildstamp test/js-native-api/.buildstamp test/node-api/.buildstamp
531558
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
532559
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
533560
$(TEST_CI_ARGS) $(CI_NATIVE_SUITES)
@@ -549,7 +576,7 @@ test-ci-js: | clear-stalled
549576
.PHONY: test-ci
550577
# Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
551578
test-ci: LOGLEVEL := info
552-
test-ci: | clear-stalled bench-addons-build build-addons build-js-native-api-tests build-node-api-tests doc-only
579+
test-ci: | clear-stalled bench-addons-build build-addons build-ffi-tests build-js-native-api-tests build-node-api-tests doc-only
553580
out/Release/cctest --gtest_output=xml:out/junit/cctest.xml
554581
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
555582
--mode=$(BUILDTYPE_LOWER) --flaky-tests=$(FLAKY_TESTS) \
@@ -664,6 +691,16 @@ test-js-native-api-clean:
664691
$(RM) -r test/js-native-api/*/build
665692
$(RM) test/js-native-api/.buildstamp
666693

694+
.PHONY: test-ffi
695+
test-ffi: test-build-ffi
696+
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) ffi
697+
698+
.PHONY: test-ffi-clean
699+
.NOTPARALLEL: test-ffi-clean
700+
test-ffi-clean:
701+
$(RM) -r test/ffi/*/build
702+
$(RM) test/ffi/.buildstamp
703+
667704
.PHONY: test-node-api
668705
test-node-api: test-build-node-api
669706
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) node-api
@@ -675,7 +712,7 @@ test-node-api-clean:
675712
$(RM) test/node-api/.buildstamp
676713

677714
.PHONY: test-addons
678-
test-addons: test-build test-js-native-api test-node-api
715+
test-addons: test-build test-ffi test-js-native-api test-node-api
679716
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) addons
680717

681718
.PHONY: test-addons-clean
@@ -684,6 +721,7 @@ test-addons-clean:
684721
$(RM) -r test/addons/??_*/
685722
$(RM) -r test/addons/*/build
686723
$(RM) test/addons/.buildstamp test/addons/.docbuildstamp
724+
$(MAKE) test-ffi-clean
687725
$(MAKE) test-js-native-api-clean
688726
$(MAKE) test-node-api-clean
689727

deps/libffi/.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.libs
2+
.deps
3+
*.o
4+
*.lo
5+
.dirstamp
6+
*.la
7+
*.pdb
8+
*.obj
9+
Makefile
10+
config.log
11+
config.status
12+
*~
13+
libffi.pc
14+
libtool
15+
stamp-h1
16+
libffi*gz
17+
autom4te.cache

0 commit comments

Comments
 (0)