Skip to content

Commit f8e92ab

Browse files
committed
feat(hermes): host objects
1 parent 3330c49 commit f8e92ab

18 files changed

Lines changed: 26 additions & 11 deletions

File tree

test-app/runtime/CMakeLists.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,26 @@ target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/common/${
291291
#target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/common/${ANDROID_ABI}/libclang_rt.asan-aarch64-android.so)
292292

293293
if (HERMES)
294-
# libhermesvm.so (+ libjsi.so) are extracted from the hermes-engine AAR into
295-
# src/main/libs/hermes/<abi>.
296-
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/hermes/${ANDROID_ABI}/libhermesvm.so)
297-
target_link_libraries(NativeScript ${PROJECT_SOURCE_DIR}/src/main/libs/hermes/${ANDROID_ABI}/libjsi.so)
294+
# Select debug or release Hermes .so files based on build type.
295+
# Optimized builds use the MinSizeRel release libraries; all other builds
296+
# (including regular debug and debugOptimized-with-inspector) use the debug
297+
# libraries, which include HERMES_ENABLE_DEBUGGER and full debug info.
298+
if (OPTIMIZED_BUILD OR OPTIMIZED_WITH_INSPECTOR_BUILD)
299+
set(HERMES_LIB_VARIANT release)
300+
else ()
301+
set(HERMES_LIB_VARIANT debug)
302+
endif ()
303+
304+
set(HERMES_LIB_DIR ${PROJECT_SOURCE_DIR}/src/main/libs/hermes/${HERMES_LIB_VARIANT}/${ANDROID_ABI})
305+
MESSAGE(STATUS "# Hermes lib variant: ${HERMES_LIB_VARIANT} (${HERMES_LIB_DIR})")
306+
307+
target_link_libraries(NativeScript ${HERMES_LIB_DIR}/libhermesvm.so)
308+
target_link_libraries(NativeScript ${HERMES_LIB_DIR}/libjsi.so)
298309
add_compile_definitions(NativeScript, PRIVATE __HERMES__)
310+
311+
# napi_create_host_object / napi_get_host_object_data / napi_is_host_object
312+
# are compiled into libhermesvm.so (via hermesNapi) when USE_HOST_OBJECT is
313+
# set at Hermes build time. No separate .so to link here.
299314
endif ()
300315

301316
if (JSC)

test-app/runtime/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
apply plugin: 'com.android.library'
22

3-
// can be: "V8-11", "V8-10","V8-13", "JSC", "HERMES", "QUICKJS", "QUICKJS_NG", "SHERMES", "PRIMJS"
3+
// can be: "V8-11", "V8-10","V8-13", "JSC", "HERMES", "QUICKJS", "QUICKJS_NG", "PRIMJS"
44

5-
def jsEngine = "V8-13"
5+
def jsEngine = "HERMES"
66

77
def hasEngine = project.hasProperty("engine")
88
if (hasEngine) {
99
jsEngine = engine
1010
}
1111

12-
def hasHostObjects = project.hasProperty("useHostObjects")
12+
def hasHostObjects = true //project.hasProperty("useHostObjects")
1313
def isNapiModule = project.hasProperty("asNapiModule");
1414

1515
printf("Compiling NativeScript with %s.\n", jsEngine)
@@ -141,9 +141,9 @@ android {
141141
arguments.add("-DQUICKJS_NG=1")
142142
}
143143
} else if (jsEngine == "HERMES") {
144+
// SHERMES is kept as an alias for the static-hermes (hermesvm)
145+
// engine, which is now the canonical HERMES engine.
144146
arguments.add("-DHERMES=1")
145-
} else if (jsEngine == "SHERMES") {
146-
arguments.add("-DSHERMES=1")
147147
} else if (jsEngine == "PRIMJS") {
148148
arguments.add("-DPRIMJS=1")
149149
}else if (jsEngine == "JSC") {
@@ -215,7 +215,7 @@ android {
215215
exclude "**/libjsi.so"
216216
exclude "**/libfbjni.so"
217217
}
218-
} else if (jsEngine == "HERMES" || jsEngine == "SHERMES") {
218+
} else if (jsEngine == "HERMES") {
219219
packagingOptions {
220220
exclude "**/libjsc.so"
221221
exclude '**/libfbjni.so'
@@ -251,7 +251,7 @@ dependencies {
251251
implementation fileTree(include: ['*.jar'], dir: 'libs')
252252
testImplementation "junit:junit:${ns_default_junit_version}"
253253
testImplementation "org.mockito:mockito-core:${ns_default_mockito_core_version}"
254-
if (jsEngine == "HERMES" || jsEngine == "SHERMES") {
254+
if (jsEngine == "HERMES") {
255255
implementation 'com.facebook.fbjni:fbjni:0.7.0'
256256
}
257257
}

test-app/runtime/src/main/libs/hermes/arm64-v8a/libhermesvm.so renamed to test-app/runtime/src/main/libs/hermes/debug/arm64-v8a/libhermesvm.so

4.13 MB
Binary file not shown.

test-app/runtime/src/main/libs/hermes/arm64-v8a/libjsi.so renamed to test-app/runtime/src/main/libs/hermes/debug/arm64-v8a/libjsi.so

113 KB
Binary file not shown.

test-app/runtime/src/main/libs/hermes/armeabi-v7a/libhermesvm.so renamed to test-app/runtime/src/main/libs/hermes/debug/armeabi-v7a/libhermesvm.so

3.01 MB
Binary file not shown.

test-app/runtime/src/main/libs/hermes/armeabi-v7a/libjsi.so renamed to test-app/runtime/src/main/libs/hermes/debug/armeabi-v7a/libjsi.so

59.1 KB
Binary file not shown.

test-app/runtime/src/main/libs/hermes/x86/libhermesvm.so renamed to test-app/runtime/src/main/libs/hermes/debug/x86/libhermesvm.so

5.31 MB
Binary file not shown.

test-app/runtime/src/main/libs/hermes/x86/libjsi.so renamed to test-app/runtime/src/main/libs/hermes/debug/x86/libjsi.so

109 KB
Binary file not shown.

test-app/runtime/src/main/libs/hermes/x86_64/libhermesvm.so renamed to test-app/runtime/src/main/libs/hermes/debug/x86_64/libhermesvm.so

4.47 MB
Binary file not shown.

test-app/runtime/src/main/libs/hermes/x86_64/libjsi.so renamed to test-app/runtime/src/main/libs/hermes/debug/x86_64/libjsi.so

110 KB
Binary file not shown.

0 commit comments

Comments
 (0)