diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index 11759aae9580a0..4c3d5dcb052c94 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -117,8 +117,6 @@ val preparePrefab by PrefabPreprocessingEntry("jsi", Pair("../ReactCommon/jsi/", "")), PrefabPreprocessingEntry( "fabricjni", Pair("src/main/jni/react/fabric", "react/fabric/")), - PrefabPreprocessingEntry( - "mapbufferjni", Pair("src/main/jni/react/mapbuffer", "react/mapbuffer/")), PrefabPreprocessingEntry( "react_render_mapbuffer", Pair("../ReactCommon/react/renderer/mapbuffer/", "react/renderer/mapbuffer/")), @@ -264,6 +262,8 @@ val preparePrefab by Pair("../ReactCommon/react/renderer/imagemanager/platform/cxx/", ""), // react_render_mapbuffer Pair("../ReactCommon/react/renderer/mapbuffer/", "react/renderer/mapbuffer/"), + // mapbufferjni + Pair("src/main/jni/react/mapbuffer", "react/mapbuffer/"), // react_utils Pair("../ReactCommon/react/utils/", "react/utils/"), // rrc_image @@ -632,7 +632,6 @@ android { "rrc_root", "jsi", "fabricjni", - "mapbufferjni", "react_render_mapbuffer", "react_render_textlayoutmanager", "yoga", @@ -748,7 +747,6 @@ android { create("rrc_root") { headers = File(prefabHeadersDir, "rrc_root").absolutePath } create("jsi") { headers = File(prefabHeadersDir, "jsi").absolutePath } create("fabricjni") { headers = File(prefabHeadersDir, "fabricjni").absolutePath } - create("mapbufferjni") { headers = File(prefabHeadersDir, "mapbufferjni").absolutePath } create("react_render_mapbuffer") { headers = File(prefabHeadersDir, "react_render_mapbuffer").absolutePath } diff --git a/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake b/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake index 87684b25c76f43..d86165cedfbfd8 100644 --- a/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake +++ b/packages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake @@ -66,7 +66,6 @@ target_compile_options(${CMAKE_PROJECT_NAME} find_package(ReactAndroid REQUIRED CONFIG) add_library(fabricjni ALIAS ReactAndroid::fabricjni) add_library(jsi ALIAS ReactAndroid::jsi) -add_library(mapbufferjni ALIAS ReactAndroid::mapbufferjni) add_library(react_render_mapbuffer ALIAS ReactAndroid::react_render_mapbuffer) add_library(react_render_textlayoutmanager ALIAS ReactAndroid::react_render_textlayoutmanager) add_library(reactnative ALIAS ReactAndroid::reactnative) @@ -78,7 +77,6 @@ add_library(fbjni ALIAS fbjni::fbjni) target_link_libraries(${CMAKE_PROJECT_NAME} fabricjni # prefab ready - mapbufferjni # prefab ready fbjni # via 3rd party prefab jsi # prefab ready reactnative # prefab ready diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/MapBufferSoLoader.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/MapBufferSoLoader.kt index 1c9536cc3fb0b0..a1e8af79239cc7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/MapBufferSoLoader.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/MapBufferSoLoader.kt @@ -9,8 +9,8 @@ package com.facebook.react.common.mapbuffer import com.facebook.react.bridge.ReactMarker import com.facebook.react.bridge.ReactMarkerConstants +import com.facebook.react.common.ReactNativeSoLoader import com.facebook.react.common.annotations.StableReactNativeAPI -import com.facebook.soloader.SoLoader import com.facebook.systrace.Systrace @StableReactNativeAPI @@ -28,7 +28,7 @@ public object MapBufferSoLoader { Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReadableMapBufferSoLoader.staticInit::load:mapbufferjni") ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_MAPBUFFER_SO_FILE_START) - SoLoader.loadLibrary("mapbufferjni") + ReactNativeSoLoader.loadLibrary("mapbufferjni") ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_MAPBUFFER_SO_FILE_END) Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE) } diff --git a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt index 3ed2471f96b139..d5b8f5d4f325b1 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt @@ -299,6 +299,7 @@ add_executable(reactnative_unittest hermes-engine::libhermes hermes_inspector_modern jsi + mapbufferjni react_cxxreact react_codegen_rncore react_debug diff --git a/packages/react-native/ReactAndroid/src/main/jni/OnLoad.cpp b/packages/react-native/ReactAndroid/src/main/jni/OnLoad.cpp index 6b70cf2c50c73a..ec2c127ed88f7f 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/OnLoad.cpp @@ -9,6 +9,8 @@ #include JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) { - return facebook::jni::initialize( - vm, [] { facebook::react::OnLoad_react_newarchdefaults(); }); + return facebook::jni::initialize(vm, [] { + facebook::react::OnLoad_mapbufferjni(); + facebook::react::OnLoad_react_newarchdefaults(); + }); } diff --git a/packages/react-native/ReactAndroid/src/main/jni/OnLoad.h b/packages/react-native/ReactAndroid/src/main/jni/OnLoad.h index ff0ed0f72c67de..40c0c1c2c74d79 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/OnLoad.h +++ b/packages/react-native/ReactAndroid/src/main/jni/OnLoad.h @@ -10,5 +10,6 @@ namespace facebook { namespace react { JNIEXPORT void OnLoad_react_newarchdefaults(); -} +JNIEXPORT void OnLoad_mapbufferjni(); +} // namespace react } // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/mapbuffer/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/react/mapbuffer/CMakeLists.txt index 2694a9cd06783b..eb672c11734650 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/mapbuffer/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/react/mapbuffer/CMakeLists.txt @@ -11,7 +11,7 @@ add_compile_options(-fexceptions -frtti -std=c++20 -Wall -DLOG_TAG=\"Fabric\") file(GLOB mapbuffer_SRC CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/react/common/mapbuffer/*.cpp) -add_library(mapbufferjni SHARED ${mapbuffer_SRC}) +add_library(mapbufferjni OBJECT ${mapbuffer_SRC}) target_include_directories(mapbufferjni PUBLIC diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/OnLoad.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/OnLoad.cpp index 3a1ec41a161c5e..99f278b3b8dd5f 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/OnLoad.cpp @@ -10,7 +10,17 @@ #include "JReadableMapBuffer.h" #include "JWritableMapBuffer.h" +namespace facebook { +namespace react { +JNIEXPORT void OnLoad_mapbufferjni() { + facebook::react::JReadableMapBuffer::registerNatives(); +} +} // namespace react +} // namespace facebook + +#ifndef REACT_NATIVE_OPEN_SOURCE JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) { return facebook::jni::initialize( - vm, [] { facebook::react::JReadableMapBuffer::registerNatives(); }); + vm, [] { facebook::react::OnLoad_mapbufferjni(); }); } +#endif