Skip to content

Commit 9d9edca

Browse files
committed
refactor: organize direct FFI backends
1 parent f116e29 commit 9d9edca

52 files changed

Lines changed: 1783 additions & 1308 deletions

Some content is hidden

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

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ packages/*/types
6565
SwiftBindgen
6666

6767
# Generated Objective-C/C dispatch wrappers
68-
NativeScript/ffi/napi/GeneratedSignatureDispatch.inc
69-
NativeScript/ffi/napi/GeneratedSignatureDispatch.inc.stamp
68+
NativeScript/ffi/*/GeneratedSignatureDispatch.inc
69+
NativeScript/ffi/*/GeneratedSignatureDispatch.inc.stamp
7070

7171
# React Native TurboModule package staging
7272
packages/react-native/dist/

NativeScript/CMakeLists.txt

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,6 @@ endif()
157157

158158
message(STATUS "NS_FFI_BACKEND = ${NS_FFI_BACKEND} (${NS_EFFECTIVE_FFI_BACKEND})")
159159

160-
if(NS_EFFECTIVE_FFI_BACKEND STREQUAL "direct" AND
161-
NOT (NS_GSD_BACKEND STREQUAL "auto" OR NS_GSD_BACKEND STREQUAL "none"))
162-
message(FATAL_ERROR
163-
"NS_GSD_BACKEND is only used by the Node-API FFI backend. "
164-
"Use NS_GSD_BACKEND=auto or none with NS_FFI_BACKEND=direct.")
165-
endif()
166-
167160
if(NS_GSD_BACKEND STREQUAL "auto")
168161
if(NS_EFFECTIVE_FFI_BACKEND STREQUAL "direct")
169162
set(NS_EFFECTIVE_GSD_BACKEND "none")
@@ -200,6 +193,12 @@ if(NS_EFFECTIVE_FFI_BACKEND STREQUAL "napi" AND
200193
"NS_FFI_BACKEND=napi is the pure Node-API FFI backend and only supports "
201194
"NS_GSD_BACKEND=napi or none.")
202195
endif()
196+
if(NS_EFFECTIVE_FFI_BACKEND STREQUAL "direct" AND
197+
NS_EFFECTIVE_GSD_BACKEND STREQUAL "napi")
198+
message(FATAL_ERROR
199+
"NS_FFI_BACKEND=direct cannot use NS_GSD_BACKEND=napi. "
200+
"Use the matching engine backend or none.")
201+
endif()
203202

204203
message(STATUS "NS_GSD_BACKEND = ${NS_GSD_BACKEND} (${NS_EFFECTIVE_GSD_BACKEND})")
205204

@@ -240,12 +239,12 @@ set(FFI_NAPI_SOURCE_FILES
240239
)
241240

242241
set(FFI_DIRECT_SHARED_SOURCE_FILES
243-
ffi/shared/direct/EmbeddedMetadata.mm
242+
ffi/direct/EmbeddedMetadata.mm
244243
)
245244

246245
set(FFI_HERMES_DIRECT_SOURCE_FILES
247246
${FFI_DIRECT_SHARED_SOURCE_FILES}
248-
ffi/hermes/jsi/NativeApiJsi.mm
247+
ffi/hermes/NativeApiJsi.mm
249248
)
250249

251250
set(FFI_V8_DIRECT_SOURCE_FILES
@@ -516,15 +515,31 @@ set(NS_GSD_BACKEND_JSC_VALUE 0)
516515
set(NS_GSD_BACKEND_QUICKJS_VALUE 0)
517516
set(NS_GSD_BACKEND_HERMES_VALUE 0)
518517
set(NS_GSD_BACKEND_NAPI_VALUE 0)
518+
set(NS_GSD_BACKEND_ENGINE_DIRECT_VALUE 0)
519+
set(NS_GSD_BACKEND_DIRECT_PREPARED_VALUE 0)
519520
set(NS_FFI_BACKEND_DIRECT_VALUE 0)
520521
set(NS_FFI_BACKEND_NAPI_VALUE 0)
521522

522523
if(NS_EFFECTIVE_GSD_BACKEND STREQUAL "v8")
523-
set(NS_GSD_BACKEND_V8_VALUE 1)
524+
if(NS_EFFECTIVE_FFI_BACKEND STREQUAL "direct")
525+
set(NS_GSD_BACKEND_DIRECT_PREPARED_VALUE 1)
526+
else()
527+
set(NS_GSD_BACKEND_V8_VALUE 1)
528+
endif()
524529
elseif(NS_EFFECTIVE_GSD_BACKEND STREQUAL "jsc")
525-
set(NS_GSD_BACKEND_JSC_VALUE 1)
530+
if(NS_EFFECTIVE_FFI_BACKEND STREQUAL "direct")
531+
set(NS_GSD_BACKEND_DIRECT_PREPARED_VALUE 1)
532+
else()
533+
set(NS_GSD_BACKEND_JSC_VALUE 1)
534+
set(NS_GSD_BACKEND_ENGINE_DIRECT_VALUE 1)
535+
endif()
526536
elseif(NS_EFFECTIVE_GSD_BACKEND STREQUAL "quickjs")
527-
set(NS_GSD_BACKEND_QUICKJS_VALUE 1)
537+
if(NS_EFFECTIVE_FFI_BACKEND STREQUAL "direct")
538+
set(NS_GSD_BACKEND_DIRECT_PREPARED_VALUE 1)
539+
else()
540+
set(NS_GSD_BACKEND_QUICKJS_VALUE 1)
541+
set(NS_GSD_BACKEND_ENGINE_DIRECT_VALUE 1)
542+
endif()
528543
elseif(NS_EFFECTIVE_GSD_BACKEND STREQUAL "hermes")
529544
set(NS_GSD_BACKEND_HERMES_VALUE 1)
530545
elseif(NS_EFFECTIVE_GSD_BACKEND STREQUAL "napi")
@@ -543,6 +558,8 @@ target_compile_definitions(${NAME} PRIVATE
543558
NS_GSD_BACKEND_QUICKJS=${NS_GSD_BACKEND_QUICKJS_VALUE}
544559
NS_GSD_BACKEND_HERMES=${NS_GSD_BACKEND_HERMES_VALUE}
545560
NS_GSD_BACKEND_NAPI=${NS_GSD_BACKEND_NAPI_VALUE}
561+
NS_GSD_BACKEND_ENGINE_DIRECT=${NS_GSD_BACKEND_ENGINE_DIRECT_VALUE}
562+
NS_GSD_BACKEND_DIRECT_PREPARED=${NS_GSD_BACKEND_DIRECT_PREPARED_VALUE}
546563
NS_FFI_BACKEND_DIRECT=${NS_FFI_BACKEND_DIRECT_VALUE}
547564
NS_FFI_BACKEND_NAPI=${NS_FFI_BACKEND_NAPI_VALUE}
548565
)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)