1# Remove this legacy folder when we drop SDK 47 2 3# Copyright (c) Meta Platforms, Inc. and affiliates. 4# 5# This source code is licensed under the MIT license found in the 6# LICENSE file in the root directory of this source tree. 7 8# This configuration provides access to most common React Native prebuilt .so files 9# to avoid recompiling each of the libraries outside of ReactAndroid NDK compilation. 10# Hosting app's/library's CMakeLists.txt can include this Android-prebuilt.cmake file to 11# get access to those libraries to depend on. 12# NOTES: 13# * Currently, it assumes building React Native from source. 14# * Not every .so is listed here (yet). 15# * Static libs are not covered here (yet). 16 17cmake_minimum_required(VERSION 3.13) 18set(CMAKE_VERBOSE_MAKEFILE on) 19 20# FIRST_PARTY_NDK_DIR contains vendored source code from other FB frameworks 21# like Yoga, FBJNI, etc. 22set(FIRST_PARTY_NDK_DIR ${REACT_ANDROID_DIR}/src/main/jni/first-party) 23# THIRD_PARTY_NDK_DIR is where we're downloading third-party native 24# frameworks such as libevent, boost, etc. 25set(THIRD_PARTY_NDK_DIR ${REACT_ANDROID_BUILD_DIR}/third-party-ndk) 26# REACT_ANDROID_SRC_DIR is the root of ReactAndroid source code (Java & JNI) 27set(REACT_ANDROID_SRC_DIR ${REACT_ANDROID_DIR}/src/main) 28# REACT_COMMON_DIR is the root of ReactCommon source code (C++ only) 29set(REACT_COMMON_DIR ${REACT_ANDROID_DIR}/../ReactCommon) 30# REACT_GENERATED_SRC_DIR is the folder where the codegen for rncore will output 31set(REACT_GENERATED_SRC_DIR ${REACT_ANDROID_BUILD_DIR}/generated/source) 32# REACT_NDK_EXPORT_DIR is the folder where the .so will be copied for being inported 33# in the local project by the packageReactDebugNdkLibs/packageReactReleaseNdkLibs 34set(REACT_NDK_EXPORT_DIR ${PROJECT_BUILD_DIR}/react-ndk/exported) 35 36## fb 37add_library(fb SHARED IMPORTED GLOBAL) 38set_target_properties(fb 39 PROPERTIES 40 IMPORTED_LOCATION 41 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libfb.so) 42target_include_directories(fb 43 INTERFACE 44 ${FIRST_PARTY_NDK_DIR}/fb/include) 45 46## folly_runtime 47add_library(folly_runtime SHARED IMPORTED GLOBAL) 48set_target_properties(folly_runtime 49 PROPERTIES 50 IMPORTED_LOCATION 51 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libfolly_runtime.so) 52target_include_directories(folly_runtime 53 INTERFACE 54 ${THIRD_PARTY_NDK_DIR}/boost/boost_1_76_0 55 ${THIRD_PARTY_NDK_DIR}/double-conversion 56 ${THIRD_PARTY_NDK_DIR}/folly) 57target_compile_options(folly_runtime 58 INTERFACE 59 -DFOLLY_NO_CONFIG=1 60 -DFOLLY_HAVE_CLOCK_GETTIME=1 61 -DFOLLY_HAVE_MEMRCHR=1 62 -DFOLLY_USE_LIBCPP=1 63 -DFOLLY_MOBILE=1 64 -DFOLLY_HAVE_XSI_STRERROR_R=1) 65 66## glog 67add_library(glog SHARED IMPORTED GLOBAL) 68set_target_properties(glog 69 PROPERTIES 70 IMPORTED_LOCATION 71 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libglog.so) 72target_include_directories(glog INTERFACE ${THIRD_PARTY_NDK_DIR}/glog/exported) 73 74## yoga 75add_library(yoga SHARED IMPORTED GLOBAL) 76set_target_properties(yoga 77 PROPERTIES 78 IMPORTED_LOCATION 79 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libyoga.so) 80target_include_directories(yoga 81 INTERFACE 82 ${FIRST_PARTY_NDK_DIR}/yogajni/jni 83 ${REACT_COMMON_DIR}/yoga) 84target_compile_options(yoga 85 INTERFACE 86 -fvisibility=hidden 87 -fexceptions 88 -frtti 89 -O3) 90target_link_libraries(yoga INTERFACE log android) 91 92## react_nativemodule_core 93add_library(react_nativemodule_core SHARED IMPORTED GLOBAL) 94set_target_properties(react_nativemodule_core 95 PROPERTIES 96 IMPORTED_LOCATION 97 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_nativemodule_core.so) 98target_include_directories(react_nativemodule_core 99 INTERFACE 100 ${REACT_ANDROID_SRC_DIR}/jni 101 ${REACT_COMMON_DIR} 102 ${REACT_COMMON_DIR}/callinvoker 103 ${REACT_COMMON_DIR}/jsi 104 ${REACT_COMMON_DIR}/react/nativemodule/core 105 ${REACT_COMMON_DIR}/react/nativemodule/core/platform/android) 106target_link_libraries(react_nativemodule_core INTERFACE folly_runtime) 107 108## turbomodulejsijni 109add_library(turbomodulejsijni SHARED IMPORTED GLOBAL) 110set_target_properties(turbomodulejsijni 111 PROPERTIES 112 IMPORTED_LOCATION 113 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libturbomodulejsijni.so) 114target_include_directories(turbomodulejsijni 115 INTERFACE 116 ${REACT_ANDROID_SRC_DIR}/java/com/facebook/react/turbomodule/core/jni) 117 118## react_render_core 119add_library(react_render_core SHARED IMPORTED GLOBAL) 120set_target_properties(react_render_core 121 PROPERTIES 122 IMPORTED_LOCATION 123 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_render_core.so) 124target_include_directories(react_render_core 125 INTERFACE 126 ${REACT_COMMON_DIR} 127 ${REACT_COMMON_DIR}/react/renderer/core) 128 129## react_render_debug 130add_library(react_render_debug SHARED IMPORTED GLOBAL) 131set_target_properties(react_render_debug 132 PROPERTIES 133 IMPORTED_LOCATION 134 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_render_debug.so) 135target_include_directories(react_render_debug INTERFACE ${REACT_COMMON_DIR}/react/renderer/debug) 136 137## react_debug 138add_library(react_debug SHARED IMPORTED GLOBAL) 139set_target_properties(react_debug 140 PROPERTIES 141 IMPORTED_LOCATION 142 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_debug.so) 143target_include_directories(react_debug INTERFACE ${REACT_COMMON_DIR}/react/debug) 144target_link_libraries(react_nativemodule_core INTERFACE folly_runtime) 145 146## react_render_graphics 147add_library(react_render_graphics SHARED IMPORTED GLOBAL) 148set_target_properties(react_render_graphics 149 PROPERTIES 150 IMPORTED_LOCATION 151 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_render_graphics.so) 152target_include_directories(react_render_graphics 153 INTERFACE 154 ${REACT_COMMON_DIR}/react/renderer/graphics 155 ${REACT_COMMON_DIR}/react/renderer/graphics/platform/cxx) 156 157## react_render_imagemanager 158add_library(react_render_imagemanager SHARED IMPORTED GLOBAL) 159set_target_properties(react_render_imagemanager 160 PROPERTIES 161 IMPORTED_LOCATION 162 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_render_imagemanager.so) 163target_include_directories(react_render_imagemanager 164 INTERFACE 165 ${REACT_COMMON_DIR}/react/renderer/imagemanager 166 ${REACT_COMMON_DIR}/react/renderer/imagemanager/platform/cxx) 167 168## react_render_mounting 169add_library(react_render_mounting SHARED IMPORTED GLOBAL) 170set_target_properties(react_render_mounting 171 PROPERTIES 172 IMPORTED_LOCATION 173 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_render_mounting.so) 174target_include_directories(react_render_mounting INTERFACE ${REACT_COMMON_DIR}/react/renderer/mounting) 175 176## react_render_mapbuffer 177add_library(react_render_mapbuffer SHARED IMPORTED GLOBAL) 178set_target_properties(react_render_mapbuffer 179 PROPERTIES 180 IMPORTED_LOCATION 181 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_render_mapbuffer.so) 182target_include_directories(react_render_mapbuffer INTERFACE ${REACT_COMMON_DIR}/react/renderer/mapbuffer) 183 184## rrc_view 185add_library(rrc_view SHARED IMPORTED GLOBAL) 186set_target_properties(rrc_view 187 PROPERTIES 188 IMPORTED_LOCATION 189 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/librrc_view.so) 190target_include_directories(rrc_view INTERFACE ${REACT_COMMON_DIR}/react/renderer/components/view) 191 192## fabricjni 193add_library(fabricjni SHARED IMPORTED GLOBAL) 194set_target_properties(fabricjni 195 PROPERTIES 196 IMPORTED_LOCATION 197 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libfabricjni.so) 198target_include_directories(fabricjni INTERFACE ${REACT_ANDROID_SRC_DIR}/java/com/facebook/react/fabric/jni) 199 200## react_render_componentregistry 201add_library(react_render_componentregistry SHARED IMPORTED GLOBAL) 202set_target_properties(react_render_componentregistry 203 PROPERTIES 204 IMPORTED_LOCATION 205 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_render_componentregistry.so) 206target_include_directories(react_render_componentregistry INTERFACE ${REACT_COMMON_DIR}/react/renderer/componentregistry) 207 208## jsi 209add_library(jsi SHARED IMPORTED GLOBAL) 210set_target_properties(jsi 211 PROPERTIES 212 IMPORTED_LOCATION 213 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libjsi.so) 214target_include_directories(jsi INTERFACE ${REACT_COMMON_DIR}/jsi) 215 216## react_codegen_rncore 217add_library(react_codegen_rncore SHARED IMPORTED GLOBAL) 218set_target_properties(react_codegen_rncore 219 PROPERTIES 220 IMPORTED_LOCATION 221 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libreact_codegen_rncore.so) 222target_include_directories(react_codegen_rncore INTERFACE ${REACT_GENERATED_SRC_DIR}/codegen/jni) 223 224## runtimeexecutor 225add_library(runtimeexecutor SHARED IMPORTED GLOBAL) 226set_target_properties(runtimeexecutor 227 PROPERTIES 228 IMPORTED_LOCATION 229 ${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libruntimeexecutor.so) 230target_include_directories(runtimeexecutor INTERFACE ${REACT_COMMON_DIR}/runtimeexecutor) 231 232## fbjni 233add_subdirectory(${FIRST_PARTY_NDK_DIR}/fbjni fbjni_build) 234