Skip to content

Commit

Permalink
Create the libreactnative.so dependency (#43908)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #43908

This creates a new dynamic library that we want to be the only .so that is loaded from apps/libraries.

Changelog:
[Internal] [Changed] - Create the libreactnative.so dependency

Reviewed By: cipolleschi

Differential Revision: D55751682

fbshipit-source-id: 50f4167dc2f9953a8673b28dba3357e19fe88d6b
  • Loading branch information
cortinico authored and facebook-github-bot committed Jul 26, 2024
1 parent 9bddcde commit 68453a1
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 1 deletion.
97 changes: 96 additions & 1 deletion packages/react-native/ReactAndroid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,99 @@ val preparePrefab by
"jsinspector",
Pair("../ReactCommon/jsinspector-modern/", "jsinspector-modern/"),
),
PrefabPreprocessingEntry(
"reactnative",
listOf(
// glog
Pair(File(buildDir, "third-party-ndk/glog/exported/").absolutePath, ""),
// jsi
Pair("../ReactCommon/jsi/", ""),
// react_codegen_rncore
Pair(File(buildDir, "generated/source/codegen/jni/").absolutePath, ""),
// react_debug
Pair("../ReactCommon/react/debug/", "react/debug/"),
// react_render_componentregistry
Pair(
"../ReactCommon/react/renderer/componentregistry/",
"react/renderer/componentregistry/"),
// react_render_core
Pair("../ReactCommon/react/renderer/core/", "react/renderer/core/"),
// react_render_debug
Pair("../ReactCommon/react/renderer/debug/", "react/renderer/debug/"),
// react_render_graphics
Pair("../ReactCommon/react/renderer/graphics/", "react/renderer/graphics/"),
Pair("../ReactCommon/react/renderer/graphics/platform/android/", ""),
// react_render_imagemanager
Pair(
"../ReactCommon/react/renderer/imagemanager/",
"react/renderer/imagemanager/"),
Pair("../ReactCommon/react/renderer/imagemanager/platform/cxx/", ""),
// react_render_mapbuffer
Pair("../ReactCommon/react/renderer/mapbuffer/", "react/renderer/mapbuffer/"),
// react_utils
Pair("../ReactCommon/react/utils/", "react/utils/"),
// rrc_image
Pair(
"../ReactCommon/react/renderer/components/image/",
"react/renderer/components/image/"),
// rrc_legacyviewmanagerinterop
Pair(
"../ReactCommon/react/renderer/components/legacyviewmanagerinterop/",
"react/renderer/components/legacyviewmanagerinterop/"),
// rrc_view
Pair(
"../ReactCommon/react/renderer/components/view/",
"react/renderer/components/view/"),
Pair("../ReactCommon/react/renderer/components/view/platform/android/", ""),
// runtimeexecutor
Pair("../ReactCommon/runtimeexecutor/", ""),
// react_render_textlayoutmanager
Pair(
"../ReactCommon/react/renderer/textlayoutmanager/",
"react/renderer/textlayoutmanager/"),
Pair("../ReactCommon/react/renderer/textlayoutmanager/platform/android/", ""),
// rrc_text
Pair(
"../ReactCommon/react/renderer/components/text/",
"react/renderer/components/text/"),
Pair(
"../ReactCommon/react/renderer/attributedstring",
"react/renderer/attributedstring"),
// rrc_textinput
Pair(
"../ReactCommon/react/renderer/components/textinput/",
"react/renderer/components/textinput/"),
Pair(
"../ReactCommon/react/renderer/components/textinput/platform/android/",
""),
// react_nativemodule_core
Pair(File(buildDir, "third-party-ndk/boost/boost_1_83_0/").absolutePath, ""),
Pair(File(buildDir, "third-party-ndk/double-conversion/").absolutePath, ""),
Pair(File(buildDir, "third-party-ndk/fmt/include/").absolutePath, ""),
Pair(File(buildDir, "third-party-ndk/folly/").absolutePath, ""),
Pair("../ReactCommon/callinvoker/", ""),
Pair("../ReactCommon/cxxreact/", "cxxreact/"),
Pair("../ReactCommon/react/bridging/", "react/bridging/"),
Pair("../ReactCommon/react/config/", "react/config/"),
Pair("../ReactCommon/react/nativemodule/core/", ""),
Pair("../ReactCommon/react/nativemodule/core/platform/android/", ""),
Pair(
"../ReactCommon/react/renderer/components/root/",
"react/renderer/components/root/"),
Pair("../ReactCommon/react/renderer/debug/", "react/renderer/debug/"),
Pair(
"../ReactCommon/react/renderer/leakchecker/",
"react/renderer/leakchecker/"),
Pair("../ReactCommon/react/renderer/mounting/", "react/renderer/mounting/"),
Pair(
"../ReactCommon/react/renderer/runtimescheduler/",
"react/renderer/runtimescheduler/"),
Pair("../ReactCommon/react/renderer/scheduler/", "react/renderer/scheduler/"),
Pair("../ReactCommon/react/renderer/telemetry/", "react/renderer/telemetry/"),
Pair("../ReactCommon/react/renderer/uimanager/", "react/renderer/uimanager/"),
Pair("../ReactCommon/react/utils/", "react/utils/"),
Pair("src/main/jni/react/jni", "react/jni/"),
)),
))
outputDir.set(prefabHeadersDir)
}
Expand Down Expand Up @@ -607,7 +700,8 @@ android {
"react_render_mounting",
"hermes_executor",
"jscexecutor",
"jsinspector")
"jsinspector",
"reactnative")
}
}
ndk { abiFilters.addAll(reactNativeArchitectures()) }
Expand Down Expand Up @@ -762,6 +856,7 @@ android {
create("hermes_executor") { headers = File(prefabHeadersDir, "hermes_executor").absolutePath }
create("jscexecutor") { headers = File(prefabHeadersDir, "jscexecutor").absolutePath }
create("jsinspector") { headers = File(prefabHeadersDir, "jsinspector").absolutePath }
create("reactnative") { headers = File(prefabHeadersDir, "reactnative").absolutePath }
}

publishing {
Expand Down
28 changes: 28 additions & 0 deletions packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,34 @@ add_react_android_subdir(src/main/jni/react/runtime/hermes/jni)
add_react_android_subdir(src/main/jni/react/runtime/jsc/jni)
add_react_android_subdir(src/main/jni/react/devsupport)

# libreactnative.so Dependency
#
# The React Native Android Library (the .aar) should expose headers only via this target.
# This is needed in order to reduce the number of .so files that we ship in the final library
add_library(reactnative SHARED OnLoad.cpp)
target_link_libraries(reactnative
folly_runtime
glog
jsi
react_codegen_rncore
react_debug
react_nativemodule_core
react_render_componentregistry
react_render_core
react_render_debug
react_render_graphics
react_render_imagemanager
react_render_mapbuffer
react_render_textlayoutmanager
react_utils
rrc_image
rrc_legacyviewmanagerinterop
rrc_text
rrc_textinput
rrc_view
runtimeexecutor
)

# GTest dependencies
add_executable(reactnative_unittest
${REACT_COMMON_DIR}/cxxreact/tests/jsarg_helpers.cpp
Expand Down
14 changes: 14 additions & 0 deletions packages/react-native/ReactAndroid/src/main/jni/OnLoad.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#include <fbjni/fbjni.h>

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
return facebook::jni::initialize(vm, [] {

});
}

0 comments on commit 68453a1

Please sign in to comment.